Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,14 +40,14 @@ def predict(text, url_params):
|
|
| 40 |
if load_game != None:
|
| 41 |
try:
|
| 42 |
|
| 43 |
-
return "" + text + ""
|
| 44 |
except Exception as e:
|
| 45 |
print(f"cannot load game. Error::{e}")
|
| 46 |
pass
|
| 47 |
-
|
| 48 |
else:
|
| 49 |
pass
|
| 50 |
-
return ["" + text + ""]
|
|
|
|
| 51 |
def parse_action(string: str):
|
| 52 |
print("PARSING:")
|
| 53 |
print(string)
|
|
@@ -338,44 +338,46 @@ def run_action(purpose, task, history, action_name, action_input,result):
|
|
| 338 |
|
| 339 |
return "MAIN", None, history, task, result
|
| 340 |
|
| 341 |
-
def run(purpose,history):
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
history=str(history)
|
| 350 |
-
action_name = "MAIN"
|
| 351 |
-
action_input = None
|
| 352 |
-
while True:
|
| 353 |
-
print("")
|
| 354 |
-
print("")
|
| 355 |
-
print("---")
|
| 356 |
-
#print("purpose:", purpose)
|
| 357 |
-
print("task:", task)
|
| 358 |
-
print("---")
|
| 359 |
-
#print(history)
|
| 360 |
-
print("---")
|
| 361 |
-
|
| 362 |
-
action_name, action_input, history, task, result = run_action(
|
| 363 |
-
purpose,
|
| 364 |
-
task,
|
| 365 |
-
history,
|
| 366 |
-
action_name,
|
| 367 |
-
action_input,
|
| 368 |
-
result
|
| 369 |
-
)
|
| 370 |
-
|
| 371 |
-
if not result:
|
| 372 |
-
yield "More Searching..."
|
| 373 |
else:
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
|
| 381 |
|
|
@@ -386,10 +388,13 @@ examples =[
|
|
| 386 |
"Teach me to fly a helicopter"
|
| 387 |
]
|
| 388 |
with gr.Blocks() as app:
|
|
|
|
|
|
|
| 389 |
gr.ChatInterface(
|
| 390 |
fn=run,
|
| 391 |
-
chatbot=gr.Chatbot(show_label=False, show_share_button=True, show_copy_button=True, layout="panel", height="500px"),
|
| 392 |
title="<center>Mixtral 46.7B Powered <br>Financial Demo<br>This demo is not a Financial Advisor</center>",
|
|
|
|
|
|
|
| 393 |
examples=examples,
|
| 394 |
concurrency_limit=20,
|
| 395 |
)
|
|
|
|
| 40 |
if load_game != None:
|
| 41 |
try:
|
| 42 |
|
| 43 |
+
return "" + text + "", "True"
|
| 44 |
except Exception as e:
|
| 45 |
print(f"cannot load game. Error::{e}")
|
| 46 |
pass
|
|
|
|
| 47 |
else:
|
| 48 |
pass
|
| 49 |
+
return ["" + text + "", "False"]
|
| 50 |
+
|
| 51 |
def parse_action(string: str):
|
| 52 |
print("PARSING:")
|
| 53 |
print(string)
|
|
|
|
| 338 |
|
| 339 |
return "MAIN", None, history, task, result
|
| 340 |
|
| 341 |
+
def run(purpose,history,key_inp):
|
| 342 |
+
if key_inp=="True":
|
| 343 |
+
yield "Searching..."
|
| 344 |
+
task=None
|
| 345 |
+
result=""
|
| 346 |
+
#history = ""
|
| 347 |
+
if not history:
|
| 348 |
+
history = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
else:
|
| 350 |
+
history=str(history)
|
| 351 |
+
action_name = "MAIN"
|
| 352 |
+
action_input = None
|
| 353 |
+
while True:
|
| 354 |
+
print("")
|
| 355 |
+
print("")
|
| 356 |
+
print("---")
|
| 357 |
+
#print("purpose:", purpose)
|
| 358 |
+
print("task:", task)
|
| 359 |
+
print("---")
|
| 360 |
+
#print(history)
|
| 361 |
+
print("---")
|
| 362 |
+
|
| 363 |
+
action_name, action_input, history, task, result = run_action(
|
| 364 |
+
purpose,
|
| 365 |
+
task,
|
| 366 |
+
history,
|
| 367 |
+
action_name,
|
| 368 |
+
action_input,
|
| 369 |
+
result
|
| 370 |
+
)
|
| 371 |
+
|
| 372 |
+
if not result:
|
| 373 |
+
yield "More Searching..."
|
| 374 |
+
else:
|
| 375 |
+
yield result
|
| 376 |
+
if action_name == "COMPLETE":
|
| 377 |
+
break
|
| 378 |
+
return result
|
| 379 |
+
else:
|
| 380 |
+
return "Invalid Key"
|
| 381 |
|
| 382 |
|
| 383 |
|
|
|
|
| 388 |
"Teach me to fly a helicopter"
|
| 389 |
]
|
| 390 |
with gr.Blocks() as app:
|
| 391 |
+
key_inp=gr.Textbox()
|
| 392 |
+
add_in=[key_inp]
|
| 393 |
gr.ChatInterface(
|
| 394 |
fn=run,
|
|
|
|
| 395 |
title="<center>Mixtral 46.7B Powered <br>Financial Demo<br>This demo is not a Financial Advisor</center>",
|
| 396 |
+
chatbot=gr.Chatbot(show_label=False, show_share_button=True, show_copy_button=True, layout="panel", height="500px"),
|
| 397 |
+
additional_inputs=add_in,
|
| 398 |
examples=examples,
|
| 399 |
concurrency_limit=20,
|
| 400 |
)
|