Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,43 +7,13 @@ client = InferenceClient("lambdaindie/lambdai")
|
|
7 |
css = """
|
8 |
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
9 |
|
|
|
|
|
|
|
|
|
10 |
body {
|
11 |
background-color: #111;
|
12 |
color: #e0e0e0;
|
13 |
-
font-family: 'JetBrains Mono', monospace;
|
14 |
-
margin: 0;
|
15 |
-
padding: 0;
|
16 |
-
width: 100vw;
|
17 |
-
overflow-x: hidden;
|
18 |
-
}
|
19 |
-
|
20 |
-
.gradio-container, .gr-block.gr-box {
|
21 |
-
width: 100vw !important;
|
22 |
-
max-width: 100vw !important;
|
23 |
-
box-sizing: border-box;
|
24 |
-
}
|
25 |
-
|
26 |
-
.gr-button {
|
27 |
-
background: linear-gradient(to right, #2a2a2a, #1f1f1f);
|
28 |
-
color: white;
|
29 |
-
border-radius: 10px;
|
30 |
-
padding: 8px 16px;
|
31 |
-
font-weight: bold;
|
32 |
-
font-family: 'JetBrains Mono', monospace;
|
33 |
-
}
|
34 |
-
.gr-button:hover {
|
35 |
-
background: #333;
|
36 |
-
}
|
37 |
-
.gr-textbox textarea {
|
38 |
-
background-color: #181818 !important;
|
39 |
-
color: #fff !important;
|
40 |
-
font-family: 'JetBrains Mono', monospace !important;
|
41 |
-
border-radius: 8px;
|
42 |
-
}
|
43 |
-
.gr-chat-message, .gr-chatbot {
|
44 |
-
font-family: 'JetBrains Mono', monospace !important;
|
45 |
-
width: 100% !important;
|
46 |
-
max-width: 100% !important;
|
47 |
}
|
48 |
|
49 |
.markdown-think {
|
@@ -53,9 +23,9 @@ body {
|
|
53 |
margin-bottom: 8px;
|
54 |
font-style: italic;
|
55 |
white-space: pre-wrap;
|
56 |
-
font-family: 'JetBrains Mono', monospace;
|
57 |
animation: pulse 1.5s infinite ease-in-out;
|
58 |
}
|
|
|
59 |
@keyframes pulse {
|
60 |
0% { opacity: 0.6; }
|
61 |
50% { opacity: 1.0; }
|
@@ -72,12 +42,10 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
72 |
if assistant:
|
73 |
messages.append({"role": "assistant", "content": assistant})
|
74 |
|
75 |
-
thinking_prompt = messages + [
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
}
|
80 |
-
]
|
81 |
|
82 |
reasoning = ""
|
83 |
yield '<div class="markdown-think">Thinking...</div>'
|
@@ -94,39 +62,17 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
94 |
styled_thought = f'<div class="markdown-think">{reasoning.strip()}</div>'
|
95 |
yield styled_thought
|
96 |
|
97 |
-
time.sleep(0.5)
|
98 |
-
|
99 |
-
final_prompt = messages + [
|
100 |
-
{"role": "user", "content": message},
|
101 |
-
{"role": "assistant", "content": reasoning.strip()},
|
102 |
-
{"role": "user", "content": "Now answer based on your reasoning above."}
|
103 |
-
]
|
104 |
-
|
105 |
-
final_answer = ""
|
106 |
-
for chunk in client.chat_completion(
|
107 |
-
final_prompt,
|
108 |
-
max_tokens=max_tokens,
|
109 |
-
stream=True,
|
110 |
-
temperature=temperature,
|
111 |
-
top_p=top_p,
|
112 |
-
):
|
113 |
-
token = chunk.choices[0].delta.content or ""
|
114 |
-
final_answer += token
|
115 |
-
yield final_answer.strip()
|
116 |
-
|
117 |
demo = gr.ChatInterface(
|
118 |
fn=respond,
|
119 |
-
title="位mabdAI",
|
120 |
-
theme=gr.themes.Base(
|
121 |
css=css,
|
122 |
additional_inputs=[
|
123 |
-
gr.Textbox(
|
124 |
-
|
125 |
-
|
126 |
-
),
|
127 |
-
gr.Slider(
|
128 |
-
gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature"),
|
129 |
-
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p")
|
130 |
]
|
131 |
)
|
132 |
|
|
|
7 |
css = """
|
8 |
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
9 |
|
10 |
+
* {
|
11 |
+
font-family: 'JetBrains Mono', monospace !important;
|
12 |
+
}
|
13 |
+
|
14 |
body {
|
15 |
background-color: #111;
|
16 |
color: #e0e0e0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
|
19 |
.markdown-think {
|
|
|
23 |
margin-bottom: 8px;
|
24 |
font-style: italic;
|
25 |
white-space: pre-wrap;
|
|
|
26 |
animation: pulse 1.5s infinite ease-in-out;
|
27 |
}
|
28 |
+
|
29 |
@keyframes pulse {
|
30 |
0% { opacity: 0.6; }
|
31 |
50% { opacity: 1.0; }
|
|
|
42 |
if assistant:
|
43 |
messages.append({"role": "assistant", "content": assistant})
|
44 |
|
45 |
+
thinking_prompt = messages + [{
|
46 |
+
"role": "user",
|
47 |
+
"content": f"{message}\n\nThink step-by-step before answering."
|
48 |
+
}]
|
|
|
|
|
49 |
|
50 |
reasoning = ""
|
51 |
yield '<div class="markdown-think">Thinking...</div>'
|
|
|
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="位mabdAI",
|
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", elem_classes=["jetbrains"]),
|
73 |
+
gr.Slider(64, 2048, value=512, step=1, label="Max Tokens", elem_classes=["jetbrains"]),
|
74 |
+
gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature", elem_classes=["jetbrains"]),
|
75 |
+
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p", elem_classes=["jetbrains"])
|
|
|
|
|
76 |
]
|
77 |
)
|
78 |
|