Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from duckduckgo_search import DDGS
|
|
4 |
import re
|
5 |
|
6 |
client = InferenceClient("Pinkstack/Superthoughts-lite-v1")
|
|
|
7 |
def format_search_results(query, results, result_type):
|
8 |
formatted = f"{result_type} search results for '{query}':\n"
|
9 |
for i, result in enumerate(results):
|
@@ -67,6 +68,9 @@ def respond(
|
|
67 |
if token:
|
68 |
response += token
|
69 |
|
|
|
|
|
|
|
70 |
# Process response to convert tags to HTML divs
|
71 |
formatted_response = response
|
72 |
formatted_response = formatted_response.replace("<think>", '<div class="thinking">').replace("</think>", "</div>")
|
@@ -84,10 +88,13 @@ css = """
|
|
84 |
}
|
85 |
.output {
|
86 |
background-color: #f0f0f0;
|
87 |
-
color: black;
|
88 |
padding: 15px;
|
89 |
border-radius: 8px;
|
90 |
}
|
|
|
|
|
|
|
91 |
.gr-chatbot {
|
92 |
background-color: #f5f5f5;
|
93 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
@@ -107,6 +114,9 @@ css = """
|
|
107 |
align-self: flex-start;
|
108 |
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
109 |
}
|
|
|
|
|
|
|
110 |
"""
|
111 |
|
112 |
system_message_default = """
|
@@ -119,7 +129,7 @@ Your thought process here...
|
|
119 |
<output>
|
120 |
Your final answer here...
|
121 |
|
122 |
-
If search results are provided, cite relevant sources at the end of this section as a numbered list in the format:
|
123 |
1. [Title](URL)
|
124 |
2. [Title](URL)
|
125 |
</output>
|
@@ -129,7 +139,7 @@ demo = gr.ChatInterface(
|
|
129 |
respond,
|
130 |
additional_inputs=[
|
131 |
gr.Textbox(value=system_message_default, label="System message", lines=8),
|
132 |
-
gr.Slider(minimum=1, maximum=
|
133 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
134 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p"),
|
135 |
gr.Dropdown(
|
@@ -141,7 +151,8 @@ demo = gr.ChatInterface(
|
|
141 |
],
|
142 |
css=css,
|
143 |
title="Pinkchat - Superthoughts lite v1 (Just 1.7B parameters!)",
|
144 |
-
description="Chat with an AI that thinks step-by-step and
|
|
|
145 |
)
|
146 |
|
147 |
if __name__ == "__main__":
|
|
|
4 |
import re
|
5 |
|
6 |
client = InferenceClient("Pinkstack/Superthoughts-lite-v1")
|
7 |
+
|
8 |
def format_search_results(query, results, result_type):
|
9 |
formatted = f"{result_type} search results for '{query}':\n"
|
10 |
for i, result in enumerate(results):
|
|
|
68 |
if token:
|
69 |
response += token
|
70 |
|
71 |
+
# Clean response: normalize line breaks to prevent extra <p> tags
|
72 |
+
response = re.sub(r'\n\s*\n+', '\n', response.strip())
|
73 |
+
|
74 |
# Process response to convert tags to HTML divs
|
75 |
formatted_response = response
|
76 |
formatted_response = formatted_response.replace("<think>", '<div class="thinking">').replace("</think>", "</div>")
|
|
|
88 |
}
|
89 |
.output {
|
90 |
background-color: #f0f0f0;
|
91 |
+
color: black !important;
|
92 |
padding: 15px;
|
93 |
border-radius: 8px;
|
94 |
}
|
95 |
+
.output * {
|
96 |
+
color: black !important;
|
97 |
+
}
|
98 |
.gr-chatbot {
|
99 |
background-color: #f5f5f5;
|
100 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
|
114 |
align-self: flex-start;
|
115 |
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
116 |
}
|
117 |
+
.gr-chatbot .message.assistant * {
|
118 |
+
color: inherit;
|
119 |
+
}
|
120 |
"""
|
121 |
|
122 |
system_message_default = """
|
|
|
129 |
<output>
|
130 |
Your final answer here...
|
131 |
|
132 |
+
If search results are provided, you must cite relevant sources at the end of this section as a numbered list in the format:
|
133 |
1. [Title](URL)
|
134 |
2. [Title](URL)
|
135 |
</output>
|
|
|
139 |
respond,
|
140 |
additional_inputs=[
|
141 |
gr.Textbox(value=system_message_default, label="System message", lines=8),
|
142 |
+
gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max new tokens"),
|
143 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
144 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p"),
|
145 |
gr.Dropdown(
|
|
|
151 |
],
|
152 |
css=css,
|
153 |
title="Pinkchat - Superthoughts lite v1 (Just 1.7B parameters!)",
|
154 |
+
description="""Chat with an AI that thinks step-by-step and has web search.
|
155 |
+
BETA:Added deep research."""
|
156 |
)
|
157 |
|
158 |
if __name__ == "__main__":
|