Omnibus commited on
Commit
5039147
1 Parent(s): 5d28c4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -28,10 +28,19 @@ client = InferenceClient(
28
  )
29
 
30
  def parse_action(string: str):
 
 
31
  assert string.startswith("action:")
32
  idx = string.find("action_input=")
 
33
  if idx == -1:
 
 
34
  return string[8:], None
 
 
 
 
35
  return string[8 : idx - 1], string[idx + 13 :].strip("'").strip('"')
36
 
37
 
@@ -89,7 +98,7 @@ def call_search(purpose, task, history, action_input):
89
  print("compressing...")
90
  return_list = compress_data(rl,purpose,task,return_list)
91
  history = "observation: the search results are:\n {}\n".format(return_list)
92
- return "COMPLETE", None, history, task
93
  else:
94
  history = "observation: I need to trigger a search using the following syntax:\naction: SEARCH action_input=SEARCH_QUERY\n"
95
  return "UPDATE-TASK", None, history, task
@@ -309,11 +318,11 @@ def find_all(purpose,task,history, url):
309
  task = "complete?"
310
  return "MAIN", None, history, task
311
  else:
312
- history += "observation: I need to trigger a search using the following syntax:\naction: WEBSITE_SCRAPE action_input=SEARCH_QUERY\n"
313
  return "MAIN", None, history, task
314
  except Exception as e:
315
  print (e)
316
- history += "observation: I need to trigger a search using the following syntax:\naction: WEBSITE_SCRAPE action_input=SEARCH_QUERY\n"
317
  return "MAIN", None, history, task
318
 
319
  #else:
 
28
  )
29
 
30
  def parse_action(string: str):
31
+ print("PARSING:")
32
+ print(string)
33
  assert string.startswith("action:")
34
  idx = string.find("action_input=")
35
+ print(idx)
36
  if idx == -1:
37
+ print ("idx == -1")
38
+ print (string[8:])
39
  return string[8:], None
40
+
41
+ print ("last return:")
42
+ print (string[8 : idx - 1])
43
+ print (string[idx + 13 :].strip("'").strip('"'))
44
  return string[8 : idx - 1], string[idx + 13 :].strip("'").strip('"')
45
 
46
 
 
98
  print("compressing...")
99
  return_list = compress_data(rl,purpose,task,return_list)
100
  history = "observation: the search results are:\n {}\n".format(return_list)
101
+ return "MAIN", None, history, task
102
  else:
103
  history = "observation: I need to trigger a search using the following syntax:\naction: SEARCH action_input=SEARCH_QUERY\n"
104
  return "UPDATE-TASK", None, history, task
 
318
  task = "complete?"
319
  return "MAIN", None, history, task
320
  else:
321
+ history += "observation: I need to trigger a search using the following syntax:\naction: SCRAPE_WEBSITE action_input=SEARCH_QUERY\n"
322
  return "MAIN", None, history, task
323
  except Exception as e:
324
  print (e)
325
+ history += "observation: I need to trigger a search using the following syntax:\naction: SCRAPE_WEBSITE action_input=SEARCH_QUERY\n"
326
  return "MAIN", None, history, task
327
 
328
  #else: