OuroborosM commited on
Commit
3b25af6
·
1 Parent(s): 46f4c4b

correct QA math

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -574,18 +574,27 @@ llm = chat
574
 
575
  llm_math = LLMMathChain.from_llm(llm)
576
 
 
 
577
  math_tool = Tool(
578
  name ='Calculator',
579
  func = llm_math.run,
580
  description ='Useful for when you need to answer questions about math.'
581
  )
582
 
 
 
 
 
 
583
 
584
  # openai
585
  tools = [DB_Search(), duckduckgo_tool, python_tool, math_tool, Text2Sound_tool]
586
 
587
  tools2 = [DB_Search2(), duckduckgo_tool2, wikipedia_tool2, python_tool2, math_tool, Text2Sound_tool2]
588
 
 
 
589
  # tools = load_tools(["Vector Database Search","Wikipedia Search","Python REPL","llm-math"], llm=llm)
590
 
591
  # Openai embedding
@@ -733,7 +742,7 @@ agent_ZEROSHOT_REACT = initialize_agent(tools2, llm,
733
 
734
  )
735
 
736
- agent_ZEROSHOT_REACT_2 = initialize_agent(tools2, GPTfake,
737
  # agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
738
  agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
739
  verbose = True,
@@ -778,7 +787,7 @@ agent_ZEROSHOT_AGENT = AgentExecutor.from_agent_and_tools(
778
 
779
  agent_ZEROSHOT_AGENT_2 = AgentExecutor.from_agent_and_tools(
780
  agent=agent_core_2,
781
- tools=tools2,
782
  verbose=True,
783
  # memory=memory,
784
  handle_parsing_errors = True,
@@ -1409,11 +1418,13 @@ def QAQuery_p(question: str):
1409
  retriever = vectordb_p.as_retriever()
1410
  retriever.search_kwargs['k'] = int(os.environ["search_kwargs_k"])
1411
  # retriever.search_kwargs['fetch_k'] = 100
1412
- if agent == agent_ZEROSHOT_REACT_2:
 
1413
  qa = RetrievalQA.from_chain_type(llm=GPTfake, chain_type="stuff",
1414
  retriever=retriever, return_source_documents = True,
1415
  verbose = True)
1416
  else:
 
1417
  qa = RetrievalQA.from_chain_type(llm=chat, chain_type="stuff",
1418
  retriever=retriever, return_source_documents = True,
1419
  verbose = True)
@@ -1489,7 +1500,7 @@ if __name__ == '__main__':
1489
  # CreatDb()
1490
  # QAQuery("what is COFOR ?")
1491
  # CreatDb_P()
1492
- # QAQuery_p("what is GST ?")
1493
  # question = "what is PDP?"
1494
  # output = asyncio.run(start_playwright(question))
1495
 
 
574
 
575
  llm_math = LLMMathChain.from_llm(llm)
576
 
577
+ llm_math_2 = LLMMathChain.from_llm(GPTfake)
578
+
579
  math_tool = Tool(
580
  name ='Calculator',
581
  func = llm_math.run,
582
  description ='Useful for when you need to answer questions about math.'
583
  )
584
 
585
+ math_tool_2 = Tool(
586
+ name ='Calculator',
587
+ func = llm_math_2.run,
588
+ description ='Useful for when you need to answer questions about math.'
589
+ )
590
 
591
  # openai
592
  tools = [DB_Search(), duckduckgo_tool, python_tool, math_tool, Text2Sound_tool]
593
 
594
  tools2 = [DB_Search2(), duckduckgo_tool2, wikipedia_tool2, python_tool2, math_tool, Text2Sound_tool2]
595
 
596
+ tools_remote = [DB_Search2(), duckduckgo_tool2, wikipedia_tool2, python_tool2, math_tool_2, Text2Sound_tool2]
597
+
598
  # tools = load_tools(["Vector Database Search","Wikipedia Search","Python REPL","llm-math"], llm=llm)
599
 
600
  # Openai embedding
 
742
 
743
  )
744
 
745
+ agent_ZEROSHOT_REACT_2 = initialize_agent(tools_remote, GPTfake,
746
  # agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
747
  agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
748
  verbose = True,
 
787
 
788
  agent_ZEROSHOT_AGENT_2 = AgentExecutor.from_agent_and_tools(
789
  agent=agent_core_2,
790
+ tools=tools_remote,
791
  verbose=True,
792
  # memory=memory,
793
  handle_parsing_errors = True,
 
1418
  retriever = vectordb_p.as_retriever()
1419
  retriever.search_kwargs['k'] = int(os.environ["search_kwargs_k"])
1420
  # retriever.search_kwargs['fetch_k'] = 100
1421
+ if agent == agent_ZEROSHOT_REACT_2 or agent == agent_ZEROSHOT_AGENT_2:
1422
+ print("--------------- QA with Remote --------------")
1423
  qa = RetrievalQA.from_chain_type(llm=GPTfake, chain_type="stuff",
1424
  retriever=retriever, return_source_documents = True,
1425
  verbose = True)
1426
  else:
1427
+ print("--------------- QA with API --------------")
1428
  qa = RetrievalQA.from_chain_type(llm=chat, chain_type="stuff",
1429
  retriever=retriever, return_source_documents = True,
1430
  verbose = True)
 
1500
  # CreatDb()
1501
  # QAQuery("what is COFOR ?")
1502
  # CreatDb_P()
1503
+ QAQuery_p("what is PDP ?")
1504
  # question = "what is PDP?"
1505
  # output = asyncio.run(start_playwright(question))
1506