Spaces:
Runtime error
Runtime error
| class CitationManager: | |
| def add_citations(self, analysis, search_results): | |
| """ | |
| Add citations to the analysis based on source URLs | |
| """ | |
| if not search_results: | |
| return analysis | |
| # Create a simple citation mapping | |
| citations = {} | |
| for i, result in enumerate(search_results): | |
| citation_id = f"[{i+1}]" | |
| citations[citation_id] = { | |
| 'url': result.get('url', ''), | |
| 'title': result.get('title', 'Untitled'), | |
| 'source': result.get('source', 'Unknown') | |
| } | |
| # Add citation references to analysis | |
| cited_analysis = analysis | |
| # In a more sophisticated implementation, we would match claims to sources | |
| # For now, we'll just append the citation list | |
| return cited_analysis, citations | |
| def format_bibliography(self, citations): | |
| """ | |
| Format citations into a bibliography | |
| """ | |
| bib_items = [] | |
| for cite_id, info in citations.items(): | |
| bib_item = f"{cite_id} {info['title']}. {info['source']}. Retrieved from: {info['url']}" | |
| bib_items.append(bib_item) | |
| return "\n".join(bib_items) |