Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -62,17 +62,37 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
62 |
styled_thought = f'<div class="markdown-think">{reasoning.strip()}</div>'
|
63 |
yield styled_thought
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
demo = gr.ChatInterface(
|
66 |
fn=respond,
|
67 |
-
title="位
|
68 |
theme=gr.themes.Base(),
|
69 |
css=css,
|
70 |
additional_inputs=[
|
71 |
gr.Textbox(value="You are a concise, logical AI that explains its reasoning clearly before answering.",
|
72 |
-
label="System Message"
|
73 |
-
gr.Slider(64, 2048, value=512, step=1, label="Max Tokens"
|
74 |
-
gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature"
|
75 |
-
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p"
|
76 |
]
|
77 |
)
|
78 |
|
|
|
62 |
styled_thought = f'<div class="markdown-think">{reasoning.strip()}</div>'
|
63 |
yield styled_thought
|
64 |
|
65 |
+
time.sleep(0.5)
|
66 |
+
|
67 |
+
final_prompt = messages + [
|
68 |
+
{"role": "user", "content": message},
|
69 |
+
{"role": "assistant", "content": reasoning.strip()},
|
70 |
+
{"role": "user", "content": "Now answer based on your reasoning above."}
|
71 |
+
]
|
72 |
+
|
73 |
+
final_answer = ""
|
74 |
+
for chunk in client.chat_completion(
|
75 |
+
final_prompt,
|
76 |
+
max_tokens=max_tokens,
|
77 |
+
stream=True,
|
78 |
+
temperature=temperature,
|
79 |
+
top_p=top_p,
|
80 |
+
):
|
81 |
+
token = chunk.choices[0].delta.content or ""
|
82 |
+
final_answer += token
|
83 |
+
yield final_answer.strip()
|
84 |
+
|
85 |
demo = gr.ChatInterface(
|
86 |
fn=respond,
|
87 |
+
title="位ambdAI",
|
88 |
theme=gr.themes.Base(),
|
89 |
css=css,
|
90 |
additional_inputs=[
|
91 |
gr.Textbox(value="You are a concise, logical AI that explains its reasoning clearly before answering.",
|
92 |
+
label="System Message"),
|
93 |
+
gr.Slider(64, 2048, value=512, step=1, label="Max Tokens"),
|
94 |
+
gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature"),
|
95 |
+
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p")
|
96 |
]
|
97 |
)
|
98 |
|