Spaces:
Sleeping
Sleeping
Commit
·
b72e9aa
1
Parent(s):
54c820e
changed the gradio input format
Browse files
app.py
CHANGED
@@ -324,9 +324,14 @@ full_pipeline = (
|
|
324 |
import gradio as gr
|
325 |
|
326 |
def chat_interface(message, history):
|
|
|
|
|
|
|
|
|
|
|
327 |
inputs = {
|
328 |
-
"query":
|
329 |
-
"all_queries": [
|
330 |
"all_texts": all_chunks,
|
331 |
"k_per_query": 3,
|
332 |
"alpha": 0.7,
|
@@ -337,10 +342,10 @@ def chat_interface(message, history):
|
|
337 |
for chunk in full_pipeline.stream(inputs):
|
338 |
if isinstance(chunk, str):
|
339 |
response += chunk
|
340 |
-
yield response
|
341 |
elif isinstance(chunk, dict) and "answer" in chunk:
|
342 |
response += chunk["answer"]
|
343 |
-
|
|
|
344 |
|
345 |
with gr.Blocks(css="""
|
346 |
html, body, .gradio-container {
|
@@ -385,11 +390,11 @@ with gr.Blocks(css="""
|
|
385 |
chatbot=chatbot,
|
386 |
textbox=textbox,
|
387 |
examples=[
|
388 |
-
"What are Krishna's research interests?",
|
389 |
-
"Where did Krishna work?",
|
390 |
-
"What did he study at Virginia Tech?"
|
391 |
],
|
392 |
-
type= "messages"
|
393 |
)
|
394 |
|
395 |
demo.launch()
|
|
|
324 |
import gradio as gr
|
325 |
|
326 |
def chat_interface(message, history):
|
327 |
+
if isinstance(message, list) and len(message) > 0 and isinstance(message[-1], dict):
|
328 |
+
user_input = message[-1].get("content", "")
|
329 |
+
else:
|
330 |
+
user_input = message # fallback if plain string
|
331 |
+
|
332 |
inputs = {
|
333 |
+
"query": user_input,
|
334 |
+
"all_queries": [user_input],
|
335 |
"all_texts": all_chunks,
|
336 |
"k_per_query": 3,
|
337 |
"alpha": 0.7,
|
|
|
342 |
for chunk in full_pipeline.stream(inputs):
|
343 |
if isinstance(chunk, str):
|
344 |
response += chunk
|
|
|
345 |
elif isinstance(chunk, dict) and "answer" in chunk:
|
346 |
response += chunk["answer"]
|
347 |
+
|
348 |
+
yield [{"role": "assistant", "content": response}]
|
349 |
|
350 |
with gr.Blocks(css="""
|
351 |
html, body, .gradio-container {
|
|
|
390 |
chatbot=chatbot,
|
391 |
textbox=textbox,
|
392 |
examples=[
|
393 |
+
{"role": "user", "content": "What are Krishna's research interests?"},
|
394 |
+
{"role": "user", "content": "Where did Krishna work?"},
|
395 |
+
{"role": "user", "content": "What did he study at Virginia Tech?"},
|
396 |
],
|
397 |
+
type= "messages"
|
398 |
)
|
399 |
|
400 |
demo.launch()
|