Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|