Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -58,61 +58,6 @@ def format_prompt(message, history):
|
|
58 |
prompt += f"[INST] {message} [/INST]"
|
59 |
return prompt
|
60 |
|
61 |
-
def call_search(purpose, task, history, action_input):
|
62 |
-
return_list=[]
|
63 |
-
print (action_input)
|
64 |
-
#if action_input in query.tasks:
|
65 |
-
print ("trying")
|
66 |
-
try:
|
67 |
-
if action_input != "" and action_input != None:
|
68 |
-
action_input.strip('""')
|
69 |
-
#model_list = api.list_models(filter=f"{action_input}",sort="last_modified",limit=1000,direction=-1)
|
70 |
-
#model_list = api.list_models(filter=f"{action_input}",limit=1000)
|
71 |
-
model_list = api.list_models(filter=f"{action_input}")
|
72 |
-
this_obj = list(model_list)
|
73 |
-
print(f'THIS_OBJ :: {this_obj[0]}')
|
74 |
-
for i,eb in enumerate(this_obj):
|
75 |
-
#return_list.append(this_obj[i].id)
|
76 |
-
return_list.append({"id":this_obj[i].id,
|
77 |
-
"author":this_obj[i].author,
|
78 |
-
"created_at":this_obj[i].created_at,
|
79 |
-
"last_modified":this_obj[i].last_modified,
|
80 |
-
"private":this_obj[i].private,
|
81 |
-
"gated":this_obj[i].gated,
|
82 |
-
"disabled":this_obj[i].disabled,
|
83 |
-
"downloads":this_obj[i].downloads,
|
84 |
-
"likes":this_obj[i].likes,
|
85 |
-
"library_name":this_obj[i].library_name,
|
86 |
-
"tags":this_obj[i].tags,
|
87 |
-
"pipeline_tag":this_obj[i].pipeline_tag,
|
88 |
-
})
|
89 |
-
#print (return_list)
|
90 |
-
c=0
|
91 |
-
rl = len(return_list)
|
92 |
-
print(rl)
|
93 |
-
for i in str(return_list):
|
94 |
-
if i == " " or i==",":
|
95 |
-
c +=1
|
96 |
-
|
97 |
-
print (c)
|
98 |
-
if rl > MAX_DATA:
|
99 |
-
print("compressing...")
|
100 |
-
return_list = compress_data(rl,purpose,task,return_list)
|
101 |
-
history = "observation: the search results are:\n {}\n".format(return_list)
|
102 |
-
return "MAIN", None, history, task
|
103 |
-
else:
|
104 |
-
history = "observation: I need to trigger a search using the following syntax:\naction: SEARCH action_input=URL\n"
|
105 |
-
return "UPDATE-TASK", None, history, task
|
106 |
-
except Exception as e:
|
107 |
-
print (e)
|
108 |
-
history = "observation: I need to trigger a search using the following syntax:\naction: SEARCH action_input=URL\n"
|
109 |
-
return "UPDATE-TASK", None, history, task
|
110 |
-
|
111 |
-
#else:
|
112 |
-
# history = "observation: The search query I used did not return a valid response"
|
113 |
-
|
114 |
-
return "MAIN", None, history, task
|
115 |
-
|
116 |
|
117 |
def run_gpt(
|
118 |
prompt_template,
|
@@ -422,7 +367,7 @@ def run(purpose,history):
|
|
422 |
|
423 |
examples =[
|
424 |
"What is the current weather in Florida?",
|
425 |
-
"
|
426 |
"Find the best deals on flippers for scuba diving",
|
427 |
"Teach me to fly a helicopter"
|
428 |
]
|
@@ -430,11 +375,10 @@ examples =[
|
|
430 |
|
431 |
gr.ChatInterface(
|
432 |
fn=run,
|
433 |
-
chatbot=gr.Chatbot(show_label=False, show_share_button=
|
434 |
title="Mixtral 46.7B Powered <br> Search",
|
435 |
examples=examples,
|
436 |
concurrency_limit=20,
|
437 |
-
css="height:600px;"
|
438 |
).launch()
|
439 |
'''
|
440 |
with gr.Blocks() as app:
|
@@ -457,5 +401,4 @@ with gr.Blocks() as app:
|
|
457 |
find_btn.click(find_it,[inp,q,num],[outp,outl])
|
458 |
|
459 |
app.launch()
|
460 |
-
|
461 |
'''
|
|
|
58 |
prompt += f"[INST] {message} [/INST]"
|
59 |
return prompt
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
def run_gpt(
|
63 |
prompt_template,
|
|
|
367 |
|
368 |
examples =[
|
369 |
"What is the current weather in Florida?",
|
370 |
+
"Find breaking news about Texas",
|
371 |
"Find the best deals on flippers for scuba diving",
|
372 |
"Teach me to fly a helicopter"
|
373 |
]
|
|
|
375 |
|
376 |
gr.ChatInterface(
|
377 |
fn=run,
|
378 |
+
chatbot=gr.Chatbot(show_label=False, show_share_button=True, show_copy_button=True, likeable=True, layout="panel", height="800px"),
|
379 |
title="Mixtral 46.7B Powered <br> Search",
|
380 |
examples=examples,
|
381 |
concurrency_limit=20,
|
|
|
382 |
).launch()
|
383 |
'''
|
384 |
with gr.Blocks() as app:
|
|
|
401 |
find_btn.click(find_it,[inp,q,num],[outp,outl])
|
402 |
|
403 |
app.launch()
|
|
|
404 |
'''
|