OuroborosM commited on
Commit
914a721
·
1 Parent(s): 90bffa6

Add new agent openai multiple

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -461,6 +461,8 @@ def UpdateDb():
461
  print("Pinecone Updated Done")
462
  print(index.describe_index_stats())
463
 
 
 
464
  def SummarizeDoc():
465
  global vectordb_p
466
  global Choice
@@ -473,7 +475,7 @@ def SummarizeDoc():
473
  print(split_docs[tt-1])
474
  sum_text=""
475
  try:
476
- if Choice == 'Zero Short React 2' or Choice == "Zero Short Agent 2":
477
  sum_chain = load_summarize_chain(GPTfake, chain_type='refine', verbose=True)
478
  else:
479
  sum_chain = load_summarize_chain(llm, chain_type='refine', verbose=True)
@@ -925,6 +927,8 @@ agent_core_2 = ZeroShotAgent(llm_chain=llm_chain_2, tools=tools2, verbose=True)
925
 
926
  agent_core_openai = OpenAIMultiFunctionsAgent(llm=llm, tools=tools, prompt=prompt_openai, verbose=True)
927
 
 
 
928
  agent_ZEROSHOT_AGENT = AgentExecutor.from_agent_and_tools(
929
  agent=agent_core,
930
  tools=tools2,
@@ -956,6 +960,17 @@ agent_OPENAI_MULTI = AgentExecutor.from_agent_and_tools(
956
  early_stopping_method="generate",
957
  )
958
 
 
 
 
 
 
 
 
 
 
 
 
959
  # agent.max_execution_time = int(os.getenv("max_iterations"))
960
  # agent.handle_parsing_errors = True
961
  # agent.early_stopping_method = "generate"
@@ -980,6 +995,9 @@ def SetAgent(Choice):
980
  elif Choice == "None":
981
  agent = None
982
  print("Set to:", Choice)
 
 
 
983
 
984
  global agent
985
  Choice = os.environ["agent_type"]
@@ -1468,7 +1486,8 @@ with gr.Blocks() as demo:
1468
  with gr.Row():
1469
 
1470
  agentchoice = gr.Dropdown(
1471
- choices=['Zero Short Agent','Zero Short React','OpenAI Multi','Zero Short React 2','Zero Short Agent 2','None'],
 
1472
  label="SELECT AI AGENT",
1473
  scale= 2,
1474
  show_label = True,
@@ -1585,7 +1604,7 @@ def QAQuery_p(question: str):
1585
  retriever.search_kwargs['k'] = int(os.environ["search_kwargs_k"])
1586
  # retriever.search_kwargs['fetch_k'] = 100
1587
  # if agent == agent_ZEROSHOT_REACT_2 or agent == agent_ZEROSHOT_AGENT_2:
1588
- if Choice == 'Zero Short React 2' or Choice == "Zero Short Agent 2":
1589
  print("--------------- QA with Remote --------------")
1590
  qa = RetrievalQA.from_chain_type(llm=GPTfake, chain_type="stuff",
1591
  retriever=retriever, return_source_documents = True,
 
461
  print("Pinecone Updated Done")
462
  print(index.describe_index_stats())
463
 
464
+ ListAgentWithRemoteGPT = ['Zero Short React 2', 'Zero Short Agent 2', 'OpenAI Multi 2']
465
+
466
  def SummarizeDoc():
467
  global vectordb_p
468
  global Choice
 
475
  print(split_docs[tt-1])
476
  sum_text=""
477
  try:
478
+ if Choice in ListAgentWithRemoteGPT:
479
  sum_chain = load_summarize_chain(GPTfake, chain_type='refine', verbose=True)
480
  else:
481
  sum_chain = load_summarize_chain(llm, chain_type='refine', verbose=True)
 
927
 
928
  agent_core_openai = OpenAIMultiFunctionsAgent(llm=llm, tools=tools, prompt=prompt_openai, verbose=True)
929
 
930
+ agent_core_openai_2 = OpenAIMultiFunctionsAgent(llm=GPTfake, tools=tools, prompt=prompt_openai, verbose=True)
931
+
932
  agent_ZEROSHOT_AGENT = AgentExecutor.from_agent_and_tools(
933
  agent=agent_core,
934
  tools=tools2,
 
960
  early_stopping_method="generate",
961
  )
962
 
963
+ agent_OPENAI_MULTI_2 = AgentExecutor.from_agent_and_tools(
964
+ agent=agent_core_openai_2,
965
+ tools=tools,
966
+ verbose=True,
967
+ # memory=memory_openai,
968
+ handle_parsing_errors = True,
969
+ max_iterations = int(os.environ["max_iterations"]),
970
+ early_stopping_method="generate",
971
+ )
972
+
973
+
974
  # agent.max_execution_time = int(os.getenv("max_iterations"))
975
  # agent.handle_parsing_errors = True
976
  # agent.early_stopping_method = "generate"
 
995
  elif Choice == "None":
996
  agent = None
997
  print("Set to:", Choice)
998
+ elif Choice =='OpenAI Multi 2':
999
+ agent = agent_OPENAI_MULTI_2
1000
+ print("Set to:", Choice)
1001
 
1002
  global agent
1003
  Choice = os.environ["agent_type"]
 
1486
  with gr.Row():
1487
 
1488
  agentchoice = gr.Dropdown(
1489
+ choices=['Zero Short Agent','Zero Short React','OpenAI Multi',
1490
+ 'Zero Short React 2','Zero Short Agent 2','None','OpenAI Multi 2'],
1491
  label="SELECT AI AGENT",
1492
  scale= 2,
1493
  show_label = True,
 
1604
  retriever.search_kwargs['k'] = int(os.environ["search_kwargs_k"])
1605
  # retriever.search_kwargs['fetch_k'] = 100
1606
  # if agent == agent_ZEROSHOT_REACT_2 or agent == agent_ZEROSHOT_AGENT_2:
1607
+ if Choice in ListAgentWithRemoteGPT:
1608
  print("--------------- QA with Remote --------------")
1609
  qa = RetrievalQA.from_chain_type(llm=GPTfake, chain_type="stuff",
1610
  retriever=retriever, return_source_documents = True,