Update app.py
Browse files
app.py
CHANGED
|
@@ -14,6 +14,7 @@ CHAT_URL = BASE_URL + "/conversation"
|
|
| 14 |
# Initialize the token and message history
|
| 15 |
token = ""
|
| 16 |
messHistory: list = []
|
|
|
|
| 17 |
async def chat(messList):
|
| 18 |
"""Async function to send and receive messages with the server."""
|
| 19 |
global token
|
|
@@ -62,7 +63,6 @@ async def chat(messList):
|
|
| 62 |
messHistory.append({"role": "assistant", "content": fullmessage}) # Append assistant response
|
| 63 |
return fullmessage
|
| 64 |
|
| 65 |
-
|
| 66 |
def gradio_chat(user_input, mode):
|
| 67 |
"""Synchronous wrapper for the async chat function, integrated with Gradio."""
|
| 68 |
messHistory.append({"role": "user", "content": f"[{mode}] {user_input}"})
|
|
@@ -85,7 +85,7 @@ with gr.Blocks() as demo:
|
|
| 85 |
chatbot = gr.Interface(
|
| 86 |
fn=lambda user_input: chat_interface(user_input, radio_mode.value),
|
| 87 |
inputs=[gr.Textbox(label="Your message")],
|
| 88 |
-
outputs=[gr.
|
| 89 |
)
|
| 90 |
|
| 91 |
# Launch the Gradio app
|
|
|
|
| 14 |
# Initialize the token and message history
|
| 15 |
token = ""
|
| 16 |
messHistory: list = []
|
| 17 |
+
|
| 18 |
async def chat(messList):
|
| 19 |
"""Async function to send and receive messages with the server."""
|
| 20 |
global token
|
|
|
|
| 63 |
messHistory.append({"role": "assistant", "content": fullmessage}) # Append assistant response
|
| 64 |
return fullmessage
|
| 65 |
|
|
|
|
| 66 |
def gradio_chat(user_input, mode):
|
| 67 |
"""Synchronous wrapper for the async chat function, integrated with Gradio."""
|
| 68 |
messHistory.append({"role": "user", "content": f"[{mode}] {user_input}"})
|
|
|
|
| 85 |
chatbot = gr.Interface(
|
| 86 |
fn=lambda user_input: chat_interface(user_input, radio_mode.value),
|
| 87 |
inputs=[gr.Textbox(label="Your message")],
|
| 88 |
+
outputs=[gr.Markdown(label="Assistant response")] # Use Markdown for the response
|
| 89 |
)
|
| 90 |
|
| 91 |
# Launch the Gradio app
|