Spaces:
Runtime error
Runtime error
Commit
·
5630d67
1
Parent(s):
8f7d06e
change analysis
Browse files
app.py
CHANGED
@@ -1041,9 +1041,6 @@ from langchain.chains import LLMChain
|
|
1041 |
from langchain_google_genai import GoogleGenerativeAI, GoogleGenerativeAIEmbeddings
|
1042 |
|
1043 |
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
class EnhancedLegalSearchSystem:
|
1048 |
def __init__(
|
1049 |
self,
|
@@ -1895,44 +1892,15 @@ class LegalSearchSystem:
|
|
1895 |
}
|
1896 |
))
|
1897 |
|
1898 |
-
return
|
1899 |
-
|
1900 |
-
def _format_documents(self, results: List[Dict]) -> str:
|
1901 |
-
"""
|
1902 |
-
Format search results as markdown.
|
1903 |
-
"""
|
1904 |
-
markdown = "### Retrieved Documents\n\n"
|
1905 |
-
for i, result in enumerate(results, 1):
|
1906 |
-
markdown += f"**Document {i}** (Page {result['metadata']['page_number']})\n"
|
1907 |
-
markdown += f"```\n{result['metadata']['text']}\n```\n\n"
|
1908 |
-
return markdown
|
1909 |
|
1910 |
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
try:
|
1922 |
-
# Graph search (asynchronous)
|
1923 |
-
graph_results = await graph_search_system.process_legal_query(query)
|
1924 |
-
graph_documents = graph_results.get('documents', "Error processing graph search")
|
1925 |
-
graph_concepts = graph_results.get('related_concepts', {})
|
1926 |
-
|
1927 |
-
# Prepare graph context for LLM
|
1928 |
-
graph_context = graph_search_system._prepare_context(
|
1929 |
-
[Document(page_content=d, metadata={}) for d in graph_documents.split("```\n\n```")], # This is a crude split, needs improvement
|
1930 |
-
graph_concepts['related_concepts'] if isinstance(graph_concepts, dict) and 'related_concepts' in graph_concepts else []
|
1931 |
-
)
|
1932 |
-
|
1933 |
-
except Exception as e:
|
1934 |
-
graph_documents = f"Error processing graph search: {str(e)}"
|
1935 |
-
graph_concepts = {}
|
1936 |
-
graph_context = ""
|
1937 |
-
|
1938 |
-
graph_data = graph_search_system.generate_document_graph(query)
|
|
|
1041 |
from langchain_google_genai import GoogleGenerativeAI, GoogleGenerativeAIEmbeddings
|
1042 |
|
1043 |
|
|
|
|
|
|
|
1044 |
class EnhancedLegalSearchSystem:
|
1045 |
def __init__(
|
1046 |
self,
|
|
|
1892 |
}
|
1893 |
))
|
1894 |
|
1895 |
+
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1896 |
|
1897 |
|
1898 |
+
if __name__ == "__main__":
|
1899 |
+
graph_search_system = EnhancedLegalSearchSystem(
|
1900 |
+
google_api_key="AIzaSyDWHGMd8a70RbL3EBenfUwimcAHjhvgM6M",
|
1901 |
+
neo4j_url="neo4j+s://a63462d0.databases.neo4j.io",
|
1902 |
+
neo4j_username="neo4j",
|
1903 |
+
neo4j_password="nU8Ut5N8k7LmQzNPe7vUbpZxMirK8rHrmLuzPc2G_Zc"
|
1904 |
+
)
|
1905 |
+
demo = create_interface(graph_search_system)
|
1906 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|