Spaces:
Runtime error
Runtime error
brian-yu-nexusflow
commited on
Commit
β’
ff53a6a
1
Parent(s):
289ada1
Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,8 @@ import gradio as gr
|
|
20 |
|
21 |
from huggingface_hub import InferenceClient
|
22 |
|
|
|
|
|
23 |
from constants import *
|
24 |
from config import DemoConfig
|
25 |
from tools import Tools
|
@@ -168,6 +170,8 @@ class RavenDemo(gr.Blocks):
|
|
168 |
self.config = config
|
169 |
self.tools = Tools(config)
|
170 |
self.functions_helper = FunctionsHelper(self.tools)
|
|
|
|
|
171 |
|
172 |
self.raven_client = InferenceClient(
|
173 |
model=config.raven_endpoint, token=config.hf_token
|
@@ -318,7 +322,8 @@ class RavenDemo(gr.Blocks):
|
|
318 |
raven_function_call = raven_function_call.removesuffix("<bot_end>")
|
319 |
yield get_returns()
|
320 |
|
321 |
-
|
|
|
322 |
|
323 |
r_calls = [c.strip() for c in raven_function_call.split(";") if c.strip()]
|
324 |
f_r_calls = []
|
@@ -408,6 +413,14 @@ class RavenDemo(gr.Blocks):
|
|
408 |
|
409 |
break
|
410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
user_input = gr.Textbox(interactive=True, autofocus=False)
|
412 |
yield get_returns()
|
413 |
|
|
|
20 |
|
21 |
from huggingface_hub import InferenceClient
|
22 |
|
23 |
+
from pymongo import MongoClient
|
24 |
+
|
25 |
from constants import *
|
26 |
from config import DemoConfig
|
27 |
from tools import Tools
|
|
|
170 |
self.config = config
|
171 |
self.tools = Tools(config)
|
172 |
self.functions_helper = FunctionsHelper(self.tools)
|
173 |
+
mongo_client = MongoClient(host=config.mongo_endpoint)
|
174 |
+
self.collection = mongo_client[config.mongo_collection]["logs"]
|
175 |
|
176 |
self.raven_client = InferenceClient(
|
177 |
model=config.raven_endpoint, token=config.hf_token
|
|
|
322 |
raven_function_call = raven_function_call.removesuffix("<bot_end>")
|
323 |
yield get_returns()
|
324 |
|
325 |
+
raw_raven_response = raven_function_call
|
326 |
+
print(f"Raw Raven response before formatting: {raw_raven_response}")
|
327 |
|
328 |
r_calls = [c.strip() for c in raven_function_call.split(";") if c.strip()]
|
329 |
f_r_calls = []
|
|
|
413 |
|
414 |
break
|
415 |
|
416 |
+
self.collection.insert_one(
|
417 |
+
{
|
418 |
+
"query": query,
|
419 |
+
"raven_output": raw_raven_response,
|
420 |
+
"summary_output": summary_model_summary,
|
421 |
+
}
|
422 |
+
)
|
423 |
+
|
424 |
user_input = gr.Textbox(interactive=True, autofocus=False)
|
425 |
yield get_returns()
|
426 |
|