Spaces:
Runtime error
Runtime error
Ganesh Chintalapati commited on
Commit ·
90da489
1
Parent(s): c28a361
Fix ChatInterface TypeError by removing unsupported parameters
Browse files
app.py
CHANGED
|
@@ -57,7 +57,7 @@ async def ask_openai(query: str, history: List[Dict[str, str]]) -> AsyncGenerato
|
|
| 57 |
break
|
| 58 |
try:
|
| 59 |
json_data = eval(data) # Safely parse JSON
|
| 60 |
-
if "choices" in json_data and json_data["choices"]:
|
| 61 |
delta = json_data["choices"][0].get("delta", {})
|
| 62 |
if "content" in delta:
|
| 63 |
yield delta["content"]
|
|
@@ -162,7 +162,7 @@ async def query_model(query: str, provider: str, history: List[Dict[str, str]]):
|
|
| 162 |
elif provider == "gemini":
|
| 163 |
yield await ask_gemini(query, history)
|
| 164 |
else:
|
| 165 |
-
yield f"Error: Unknown
|
| 166 |
|
| 167 |
# Gradio interface
|
| 168 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
@@ -173,9 +173,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 173 |
chatbot = gr.ChatInterface(
|
| 174 |
fn=query_model,
|
| 175 |
additional_inputs=[provider],
|
| 176 |
-
retry_btn=None,
|
| 177 |
-
undo_btn=None,
|
| 178 |
-
clear_btn="Clear",
|
| 179 |
title="",
|
| 180 |
description=""
|
| 181 |
)
|
|
|
|
| 57 |
break
|
| 58 |
try:
|
| 59 |
json_data = eval(data) # Safely parse JSON
|
| 60 |
+
if "choices" inㅇ json_data and json_data["choices"]:
|
| 61 |
delta = json_data["choices"][0].get("delta", {})
|
| 62 |
if "content" in delta:
|
| 63 |
yield delta["content"]
|
|
|
|
| 162 |
elif provider == "gemini":
|
| 163 |
yield await ask_gemini(query, history)
|
| 164 |
else:
|
| 165 |
+
yield f"Error: Unknown provider: {provider}"
|
| 166 |
|
| 167 |
# Gradio interface
|
| 168 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 173 |
chatbot = gr.ChatInterface(
|
| 174 |
fn=query_model,
|
| 175 |
additional_inputs=[provider],
|
|
|
|
|
|
|
|
|
|
| 176 |
title="",
|
| 177 |
description=""
|
| 178 |
)
|