Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import requests
|
@@ -66,11 +67,9 @@ def query_model(model_name: str, messages: List[Dict[str, str]]) -> str:
|
|
66 |
response = requests.post(endpoint, json=payload, headers=headers)
|
67 |
response.raise_for_status()
|
68 |
result = response.json()[0]['generated_text']
|
69 |
-
#
|
70 |
result = result.split('<|')[0] # Remove any remaining special tokens
|
71 |
-
|
72 |
-
result = result.strip() # Remove leading/trailing whitespace
|
73 |
-
return result # Return complete response
|
74 |
except Exception as e:
|
75 |
return f"{model_name} error: {str(e)}"
|
76 |
|
@@ -141,6 +140,17 @@ def respond(message: str, history: List[List[str]], session_id: str) -> Generato
|
|
141 |
# Create the Gradio interface
|
142 |
with gr.Blocks() as demo:
|
143 |
gr.Markdown("## Multi-LLM Collaboration Chat")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
with gr.Row():
|
146 |
session_id = gr.State(session_manager.create_session)
|
|
|
1 |
+
# app.py
|
2 |
import gradio as gr
|
3 |
import os
|
4 |
import requests
|
|
|
67 |
response = requests.post(endpoint, json=payload, headers=headers)
|
68 |
response.raise_for_status()
|
69 |
result = response.json()[0]['generated_text']
|
70 |
+
# Do NOT remove ** or ## so that Markdown (including LaTeX) is preserved
|
71 |
result = result.split('<|')[0] # Remove any remaining special tokens
|
72 |
+
return result.strip() # Return the cleaned response
|
|
|
|
|
73 |
except Exception as e:
|
74 |
return f"{model_name} error: {str(e)}"
|
75 |
|
|
|
140 |
# Create the Gradio interface
|
141 |
with gr.Blocks() as demo:
|
142 |
gr.Markdown("## Multi-LLM Collaboration Chat")
|
143 |
+
gr.Markdown(
|
144 |
+
"""
|
145 |
+
**LaTeX Support:** You can include inline math like `$E = mc^2$` or block math like:
|
146 |
+
```
|
147 |
+
$$
|
148 |
+
\\int_0^1 x^2 \\, dx
|
149 |
+
$$
|
150 |
+
```
|
151 |
+
and it will be rendered correctly below.
|
152 |
+
"""
|
153 |
+
)
|
154 |
|
155 |
with gr.Row():
|
156 |
session_id = gr.State(session_manager.create_session)
|