Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -900,10 +900,8 @@ logging.basicConfig(level=logging.DEBUG)
|
|
900 |
|
901 |
embeddings = OpenAIEmbeddings(api_key=os.environ['OPENAI_API_KEY'])
|
902 |
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
|
908 |
index_name = "radardata07242024"
|
909 |
vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)
|
@@ -969,20 +967,6 @@ graph = Neo4jGraph(
|
|
969 |
password="B_sZbapCTZoQDWj1JrhwqElsNa-jm5Zq1m_mAnyPYog"
|
970 |
)
|
971 |
|
972 |
-
# Avoid pushing the graph documents to Neo4j every time
|
973 |
-
# Only push the documents once and comment the code below after the initial push
|
974 |
-
# dataset_name = "Pijush2023/birmindata07312024"
|
975 |
-
# page_content_column = 'events_description'
|
976 |
-
# loader = HuggingFaceDatasetLoader(dataset_name, page_content_column)
|
977 |
-
# data = loader.load()
|
978 |
-
|
979 |
-
# text_splitter = CharacterTextSplitter(chunk_size=100, chunk_overlap=50)
|
980 |
-
# documents = text_splitter.split_documents(data)
|
981 |
-
|
982 |
-
# llm_transformer = LLMGraphTransformer(llm=chat_model)
|
983 |
-
# graph_documents = llm_transformer.convert_to_graph_documents(documents)
|
984 |
-
# graph.add_graph_documents(graph_documents, baseEntityLabel=True, include_source=True)
|
985 |
-
|
986 |
class Entities(BaseModel):
|
987 |
names: list[str] = Field(..., description="All the person, organization, or business entities that appear in the text")
|
988 |
|
@@ -1099,9 +1083,11 @@ def generate_answer(message, choice, retrieval_mode):
|
|
1099 |
chain_type_kwargs={"prompt": prompt_template}
|
1100 |
)
|
1101 |
response = qa_chain({"query": message})
|
1102 |
-
|
|
|
1103 |
elif retrieval_mode == "Knowledge-Graph":
|
1104 |
response = chain_neo4j.invoke({"question": message})
|
|
|
1105 |
return response, extract_addresses(response)
|
1106 |
else:
|
1107 |
return "Invalid retrieval mode selected.", []
|
@@ -1687,3 +1673,4 @@ demo.launch(share=True)
|
|
1687 |
|
1688 |
|
1689 |
|
|
|
|
900 |
|
901 |
embeddings = OpenAIEmbeddings(api_key=os.environ['OPENAI_API_KEY'])
|
902 |
|
903 |
+
import pinecone
|
904 |
+
pinecone.init(api_key=os.environ['PINECONE_API_KEY'])
|
|
|
|
|
905 |
|
906 |
index_name = "radardata07242024"
|
907 |
vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)
|
|
|
967 |
password="B_sZbapCTZoQDWj1JrhwqElsNa-jm5Zq1m_mAnyPYog"
|
968 |
)
|
969 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
970 |
class Entities(BaseModel):
|
971 |
names: list[str] = Field(..., description="All the person, organization, or business entities that appear in the text")
|
972 |
|
|
|
1083 |
chain_type_kwargs={"prompt": prompt_template}
|
1084 |
)
|
1085 |
response = qa_chain({"query": message})
|
1086 |
+
logging.debug(f"Vector response: {response}")
|
1087 |
+
return response['result'], extract_addresses(response['result'])
|
1088 |
elif retrieval_mode == "Knowledge-Graph":
|
1089 |
response = chain_neo4j.invoke({"question": message})
|
1090 |
+
logging.debug(f"Knowledge-Graph response: {response}")
|
1091 |
return response, extract_addresses(response)
|
1092 |
else:
|
1093 |
return "Invalid retrieval mode selected.", []
|
|
|
1673 |
|
1674 |
|
1675 |
|
1676 |
+
|