OuroborosM commited on
Commit
247e008
·
1 Parent(s): f2a5c78

update app.py

Browse files
Files changed (2) hide show
  1. app.py +38 -48
  2. requirements.txt +1 -0
app.py CHANGED
@@ -868,12 +868,8 @@ Only when there is no information available from vector database, you can search
868
  When the final answer has output files, you must output the **name** of the file.
869
  You have access to the following tools:"""
870
 
871
- PREFIX_2 = """You are a helpful AI assistant. You are capable to handle **any** task.\n\
872
- Your mission is to answer the following request as best as you can with detail information and explanation.\n\
873
- When you need information, you must always check vector database first and try to answer the question based on the information found in vector database only.\n\
874
- Only when there is no information available from vector database, you can search information by using other tools.\n\
875
- ---\n\
876
- You have access to the following tools:\n\
877
  """
878
 
879
 
@@ -906,38 +902,22 @@ When you don't have enough information, you can use tools and you must define **
906
  FORMAT_INSTRUCTIONS_3 = """
907
  When you don't have enough information, you can use tools and you must use the following format to define **Thought**, **Action** and **Action Input**:\n\
908
  '''
909
- "Thought": you should always think about what to do\n
910
- "Action": the action to take, should be one of [{tool_names}]\n
911
- "Action Input": the input to the action\n
912
- "Observation": the result of the action\n
913
- '''\n\
914
- If **Thought**, **Action**, **Action Input** is missing in the response, you must re-write the response.\n\
915
-
916
  ---\n\
917
  When you are able to provide final answer, you must use the following format to define **Final Answer** after **Thought**:\n\
918
  '''
919
- "Thought": I now know the final answer\n
920
- "Final Answer": the final answer to the original input question\n
921
- '''\n\
922
- If **Thought**, **Final Answer** is missing in the response, you must re-write the response.\n\
923
 
924
  ---\n\
925
  Example of using tools:\n\
926
- ```\n\
927
- Question: what is architecture ?\n
928
- ---\n
929
- Thought: I need to check the definition of architecture in Vector Database\n
930
- Action: Vector Database Search\n
931
- Action Input: architecture\n
932
- ```\n\
933
 
934
  Example of final answer:\n\
 
935
  ```\n
936
- Question: Good morning\n
937
- ---\n
938
- Thought: I need to make a greeting to user\n
939
- Final Answer: Hello, how can I do for you ?\n
940
- ```\n\
941
  """
942
 
943
  SUFFIX = """
@@ -1354,12 +1334,16 @@ def chathmi3(message, history2):
1354
  # print("real_content", real_content)
1355
  try:
1356
  # temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
1357
- file_name = CheckFileinResp(response)
1358
- print("file_name:", file_name)
1359
- if file_name != "N/A":
1360
- history2 = history2 + [(None, (file_name,))]
1361
- Filename_Chatbot = file_name
1362
- yield ["", history2]
 
 
 
 
1363
  except Exception as e:
1364
  print("No need to add file in chatbot:", e)
1365
 
@@ -1373,25 +1357,31 @@ def chathmi3(message, history2):
1373
  print("-" * 20)
1374
 
1375
  def CheckFileinResp(response):
 
1376
  try:
1377
  pattern = r'sample-(?:\d{8})-(?:\d{6})\.wav'
1378
  result = re.findall(pattern, response)
1379
  print("result of check file in response:", result)
1380
- return result[-1]
 
1381
  except Exception as e:
1382
  print("No wav found:", e)
1383
- try:
1384
- listWord = ['(https://example.com/', '(sandbox:/']
1385
- for item in listWord:
1386
- if item in response:
1387
- file = response.split(item)[-1].split(")")[0]
1388
- print("File found:", file)
1389
- return file
1390
- else:
1391
- continue
1392
- return "N/A"
1393
- except Exception as e:
1394
- return "N/A"
 
 
 
 
1395
 
1396
  def chathmi4(message, history2):
1397
  global last_request
 
868
  When the final answer has output files, you must output the **name** of the file.
869
  You have access to the following tools:"""
870
 
871
+ PREFIX_2 = """You are a helpful AI assistant. You are capable to handle **any** task.\nYour mission is to answer the following request as best as you can with detail information and explanation.\nWhen you need information, you must always check vector database first and try to answer the question based on the information found in vector database only.\nOnly when there is no information available from vector database, you can search information by using other tools.\nWhen the final answer has output files, you must output the **name** of the file with markdown format.\n
872
+ ---\nYou have access to the following tools:\n
 
 
 
 
873
  """
874
 
875
 
 
902
  FORMAT_INSTRUCTIONS_3 = """
903
  When you don't have enough information, you can use tools and you must use the following format to define **Thought**, **Action** and **Action Input**:\n\
904
  '''
905
+ "Thought": you should always think about what to do\n"Action": the action to take, should be one of [{tool_names}]\n"Action Input": the input to the action\n"Observation": the result of the action\n
906
+ '''\nIf **Thought**, **Action**, **Action Input** is missing in the response of using tools, you must re-write the response.\n
 
 
 
 
 
907
  ---\n\
908
  When you are able to provide final answer, you must use the following format to define **Final Answer** after **Thought**:\n\
909
  '''
910
+ "Thought": I now know the final answer\n"Final Answer": the final answer to the original input question\n
911
+ '''\nIf **Thought**, **Final Answer** is missing in the response of final answer, you must re-write the response.\n\
 
 
912
 
913
  ---\n\
914
  Example of using tools:\n\
915
+ ```\nQuestion: what is architecture ?\n---\nThought: I need to check the definition of architecture in Vector Database\nAction: Vector Database Search\nAction Input: architecture\n
916
+ ```\n
 
 
 
 
 
917
 
918
  Example of final answer:\n\
919
+ ```\nQuestion: Good morning\n---\nThought: I need to make a greeting to user\nFinal Answer: Hello, how can I do for you ?\n
920
  ```\n
 
 
 
 
 
921
  """
922
 
923
  SUFFIX = """
 
1334
  # print("real_content", real_content)
1335
  try:
1336
  # temp = response.split("(sandbox:/")[1] # (sandbox:/sample-20230805-0807.wav)
1337
+ file_names = CheckFileinResp(response)
1338
+ print("file_name:", file_names)
1339
+ if file_names != []:
1340
+ for file_name in file_names:
1341
+ if file_name != "":
1342
+ history2 = history2 + [(None, (file_name,))]
1343
+ Filename_Chatbot = file_name
1344
+ yield ["", history2]
1345
+ else:
1346
+ print("No File Found in Response")
1347
  except Exception as e:
1348
  print("No need to add file in chatbot:", e)
1349
 
 
1357
  print("-" * 20)
1358
 
1359
  def CheckFileinResp(response):
1360
+ Filelist = []
1361
  try:
1362
  pattern = r'sample-(?:\d{8})-(?:\d{6})\.wav'
1363
  result = re.findall(pattern, response)
1364
  print("result of check file in response:", result)
1365
+ Filelist.append(result[-1])
1366
+
1367
  except Exception as e:
1368
  print("No wav found:", e)
1369
+
1370
+ try:
1371
+ listWord = ['(https://example.com/', '(sandbox:/']
1372
+ for item in listWord:
1373
+ if item in response:
1374
+ file = response.split(item)[-1].split(")")[0]
1375
+ print("File found:", file)
1376
+ Filelist.append(file)
1377
+ else:
1378
+ continue
1379
+ # return "N/A"
1380
+ except Exception as e:
1381
+ # return "N/A"
1382
+ pass
1383
+
1384
+ return Filelist
1385
 
1386
  def chathmi4(message, history2):
1387
  global last_request
requirements.txt CHANGED
@@ -26,3 +26,4 @@ codeinterpreterapi
26
  jupyter-kernel-gateway
27
  html2text
28
  open-interpreter
 
 
26
  jupyter-kernel-gateway
27
  html2text
28
  open-interpreter
29
+ pandas