Frankie-walsh4 commited on
Commit
e09ca8b
·
1 Parent(s): edd54ad

change for AI thinking

Browse files
Files changed (1) hide show
  1. app.py +1 -78
app.py CHANGED
@@ -39,10 +39,7 @@ def respond(
39
  token = message.choices[0].delta.content
40
  if token:
41
  response += token
42
- # Store intermediate responses in thinking process
43
- if len(response) % 100 == 0: # Increased to 100 characters to reduce frequency
44
- thinking_process.append(response)
45
- yield f"{response}<thinking>{','.join(thinking_process)}</thinking>"
46
 
47
 
48
  # Custom CSS for Plant Wisdom.AI styling
@@ -154,41 +151,6 @@ custom_css = """
154
  border-radius: 12px;
155
  background-color: #ffffff;
156
  }
157
-
158
- .message thinking {
159
- display: none;
160
- }
161
-
162
- .message.show-thinking thinking {
163
- display: block;
164
- margin-top: 8px;
165
- padding: 8px;
166
- background: #f8f9fa;
167
- border-radius: 4px;
168
- font-size: 14px;
169
- color: #666;
170
- border: 1px solid #e0ede0;
171
- }
172
-
173
- .toggle-thinking-btn {
174
- position: absolute;
175
- bottom: 8px;
176
- right: 8px;
177
- background: none;
178
- border: none;
179
- color: #2e7d32;
180
- cursor: pointer;
181
- font-size: 12px;
182
- padding: 4px 8px;
183
- border-radius: 4px;
184
- opacity: 0.7;
185
- transition: all 0.2s ease;
186
- }
187
-
188
- .toggle-thinking-btn:hover {
189
- opacity: 1;
190
- background: rgba(46,125,50,0.1);
191
- }
192
  """
193
 
194
  """
@@ -231,45 +193,6 @@ demo = gr.ChatInterface(
231
  font=["Source Sans Pro", "Helvetica Neue", "Arial", "sans-serif"],
232
  ),
233
  css=custom_css,
234
- js="""
235
- function addThinkingButtons() {
236
- document.querySelectorAll('.message.assistant').forEach(msg => {
237
- // Only add button if message has thinking content and doesn't already have a button
238
- const thinking = msg.querySelector('thinking');
239
- if (thinking && !msg.querySelector('.toggle-thinking-btn')) {
240
- const btn = document.createElement('button');
241
- btn.className = 'toggle-thinking-btn';
242
- btn.textContent = 'Show thinking process';
243
- btn.onclick = function(e) {
244
- e.preventDefault();
245
- msg.classList.toggle('show-thinking');
246
- btn.textContent = msg.classList.contains('show-thinking')
247
- ? 'Hide thinking process'
248
- : 'Show thinking process';
249
- };
250
- msg.appendChild(btn);
251
- }
252
- });
253
- }
254
-
255
- // Add buttons when new messages appear
256
- const observer = new MutationObserver((mutations) => {
257
- mutations.forEach((mutation) => {
258
- if (mutation.addedNodes.length) {
259
- addThinkingButtons();
260
- }
261
- });
262
- });
263
-
264
- // Start observing after the page loads
265
- document.addEventListener('DOMContentLoaded', () => {
266
- observer.observe(document.body, {
267
- childList: true,
268
- subtree: true
269
- });
270
- addThinkingButtons();
271
- });
272
- """,
273
  additional_inputs=[
274
  gr.Textbox(
275
  value="""You are a specialized AI assistant made by Plant Wisdom.AI with deep knowledge of Microsoft 365 services—including SharePoint Online, OneDrive, Teams, Exchange, and the Microsoft Purview (Compliance) ecosystem—as well as general records management and data governance best practices.
 
39
  token = message.choices[0].delta.content
40
  if token:
41
  response += token
42
+ yield response
 
 
 
43
 
44
 
45
  # Custom CSS for Plant Wisdom.AI styling
 
151
  border-radius: 12px;
152
  background-color: #ffffff;
153
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  """
155
 
156
  """
 
193
  font=["Source Sans Pro", "Helvetica Neue", "Arial", "sans-serif"],
194
  ),
195
  css=custom_css,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  additional_inputs=[
197
  gr.Textbox(
198
  value="""You are a specialized AI assistant made by Plant Wisdom.AI with deep knowledge of Microsoft 365 services—including SharePoint Online, OneDrive, Teams, Exchange, and the Microsoft Purview (Compliance) ecosystem—as well as general records management and data governance best practices.