Omnibus commited on
Commit
c149909
·
1 Parent(s): 1c7926b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -17
app.py CHANGED
@@ -46,24 +46,28 @@ def format_prompt(message, history):
46
 
47
  def call_search(purpose, task, history, action_input):
48
  return_list=[]
49
- try:
50
- if action_input != "" and action_input != None:
51
- action_input.strip('""')
52
- model_list = api.list_models(task=f"{action_input}")
53
- this_obj = list(model_list)
54
- print(f'THIS_OBJ :: {this_obj[0]}')
55
- for i,eb in enumerate(this_obj):
56
- #return_list.append(this_obj[i].id)
57
- return_list.append(this_obj[i])
58
- #json_obj=json.dumps(return_list, indent=4)
59
- print (return_list)
60
- history = "observation: the search results are:\n {}\n".format(return_list)
61
- else:
62
- history = "observation: I need to trigger a search using the following syntax:\naction: SEARCH action_input SEARCH_QUERY"
63
- except Exception as e:
64
- print (e)
 
 
 
 
65
  history = "observation: The search query I used did not return a valid response, I should try a different query"
66
-
67
  return "MAIN", None, history, task
68
 
69
 
 
46
 
47
  def call_search(purpose, task, history, action_input):
48
  return_list=[]
49
+ if action_input in tasks:
50
+
51
+ try:
52
+ if action_input != "" and action_input != None:
53
+ action_input.strip('""')
54
+ model_list = api.list_models(task=f"{action_input}")
55
+ this_obj = list(model_list)
56
+ print(f'THIS_OBJ :: {this_obj[0]}')
57
+ for i,eb in enumerate(this_obj):
58
+ #return_list.append(this_obj[i].id)
59
+ return_list.append(this_obj[i])
60
+ #json_obj=json.dumps(return_list, indent=4)
61
+ print (return_list)
62
+ history = "observation: the search results are:\n {}\n".format(return_list)
63
+ else:
64
+ history = "observation: I need to trigger a search using the following syntax:\naction: SEARCH action_input SEARCH_QUERY"
65
+ except Exception as e:
66
+ print (e)
67
+ history = "observation: The search query I used did not return a valid response, I should try a different query"
68
+ else:
69
  history = "observation: The search query I used did not return a valid response, I should try a different query"
70
+
71
  return "MAIN", None, history, task
72
 
73