Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ import modelscope_studio.components.antdx as antdx
|
|
| 7 |
import modelscope_studio.components.base as ms
|
| 8 |
from openai import OpenAI
|
| 9 |
|
|
|
|
|
|
|
| 10 |
# =========== Configuration
|
| 11 |
# API KEY
|
| 12 |
client = OpenAI(
|
|
@@ -143,6 +145,9 @@ class Gradio_Events:
|
|
| 143 |
thought_done = True
|
| 144 |
history[-1]["meta"]["reason_content"] = history[-1][
|
| 145 |
"content"]
|
|
|
|
|
|
|
|
|
|
| 146 |
history[-1]["content"] = ""
|
| 147 |
history[-1]["meta"]["thought_end_message"] = get_text(
|
| 148 |
"End of Thought", "已深度思考")
|
|
@@ -156,6 +161,9 @@ class Gradio_Events:
|
|
| 156 |
state: gr.update(value=state_value)
|
| 157 |
}
|
| 158 |
history[-1]["meta"]["end"] = True
|
|
|
|
|
|
|
|
|
|
| 159 |
yield {
|
| 160 |
chatbot: gr.update(items=history),
|
| 161 |
state: gr.update(value=state_value),
|
|
@@ -169,6 +177,7 @@ class Gradio_Events:
|
|
| 169 |
chatbot: gr.update(items=history),
|
| 170 |
state: gr.update(value=state_value)
|
| 171 |
}
|
|
|
|
| 172 |
raise e
|
| 173 |
|
| 174 |
|
|
@@ -198,6 +207,8 @@ class Gradio_Events:
|
|
| 198 |
try:
|
| 199 |
for chunk in Gradio_Events._submit(state_value):
|
| 200 |
yield chunk
|
|
|
|
|
|
|
| 201 |
finally:
|
| 202 |
# postprocess submit
|
| 203 |
yield Gradio_Events.postprocess_submit(state_value)
|
|
@@ -228,6 +239,8 @@ class Gradio_Events:
|
|
| 228 |
try:
|
| 229 |
for chunk in Gradio_Events._submit(state_value):
|
| 230 |
yield chunk
|
|
|
|
|
|
|
| 231 |
finally:
|
| 232 |
# postprocess submit
|
| 233 |
yield Gradio_Events.postprocess_submit(state_value)
|
|
@@ -427,8 +440,16 @@ class Gradio_Events:
|
|
| 427 |
|
| 428 |
|
| 429 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 430 |
#chatbot {
|
| 431 |
-
height: calc(100vh -
|
| 432 |
}
|
| 433 |
|
| 434 |
#chatbot .chatbot-conversations {
|
|
@@ -922,4 +943,4 @@ with gr.Blocks(css=css, fill_width=True) as demo:
|
|
| 922 |
])
|
| 923 |
|
| 924 |
if __name__ == "__main__":
|
| 925 |
-
demo.queue(default_concurrency_limit=
|
|
|
|
| 7 |
import modelscope_studio.components.base as ms
|
| 8 |
from openai import OpenAI
|
| 9 |
|
| 10 |
+
# Qwen/QwQ-32B
|
| 11 |
+
|
| 12 |
# =========== Configuration
|
| 13 |
# API KEY
|
| 14 |
client = OpenAI(
|
|
|
|
| 145 |
thought_done = True
|
| 146 |
history[-1]["meta"]["reason_content"] = history[-1][
|
| 147 |
"content"]
|
| 148 |
+
|
| 149 |
+
print("Reason: ",history[-1]["meta"]["reason_content"])
|
| 150 |
+
|
| 151 |
history[-1]["content"] = ""
|
| 152 |
history[-1]["meta"]["thought_end_message"] = get_text(
|
| 153 |
"End of Thought", "已深度思考")
|
|
|
|
| 161 |
state: gr.update(value=state_value)
|
| 162 |
}
|
| 163 |
history[-1]["meta"]["end"] = True
|
| 164 |
+
|
| 165 |
+
print("Answer: ",history[-1]["content"])
|
| 166 |
+
|
| 167 |
yield {
|
| 168 |
chatbot: gr.update(items=history),
|
| 169 |
state: gr.update(value=state_value),
|
|
|
|
| 177 |
chatbot: gr.update(items=history),
|
| 178 |
state: gr.update(value=state_value)
|
| 179 |
}
|
| 180 |
+
print('Error: ',e)
|
| 181 |
raise e
|
| 182 |
|
| 183 |
|
|
|
|
| 207 |
try:
|
| 208 |
for chunk in Gradio_Events._submit(state_value):
|
| 209 |
yield chunk
|
| 210 |
+
except Exception as e:
|
| 211 |
+
raise e
|
| 212 |
finally:
|
| 213 |
# postprocess submit
|
| 214 |
yield Gradio_Events.postprocess_submit(state_value)
|
|
|
|
| 239 |
try:
|
| 240 |
for chunk in Gradio_Events._submit(state_value):
|
| 241 |
yield chunk
|
| 242 |
+
except Exception as e:
|
| 243 |
+
raise e
|
| 244 |
finally:
|
| 245 |
# postprocess submit
|
| 246 |
yield Gradio_Events.postprocess_submit(state_value)
|
|
|
|
| 440 |
|
| 441 |
|
| 442 |
css = """
|
| 443 |
+
.gradio-container {
|
| 444 |
+
padding: 0 !important;
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
.gradio-container > main.fillable {
|
| 448 |
+
padding: 0 !important;
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
#chatbot {
|
| 452 |
+
height: calc(100vh - 21px - 16px);
|
| 453 |
}
|
| 454 |
|
| 455 |
#chatbot .chatbot-conversations {
|
|
|
|
| 943 |
])
|
| 944 |
|
| 945 |
if __name__ == "__main__":
|
| 946 |
+
demo.queue(default_concurrency_limit=200).launch(ssr_mode=False, max_threads=200)
|