codebyam commited on
Commit
4a30c01
·
verified ·
1 Parent(s): e0fb7c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -39,6 +39,14 @@ async def read_root(response: Response):
39
  box-sizing: border-box;
40
  color: #e2e8f0; /* Light text color for general body text */
41
  }
 
 
 
 
 
 
 
 
42
  .chat-container {
43
  display: flex;
44
  flex-direction: column;
@@ -52,7 +60,7 @@ async def read_root(response: Response):
52
  border: 1px solid #4a5568; /* Subtle border for dark mode */
53
  }
54
  .chat-header {
55
- background: linear-gradient(to right, #2c5282, #4c78a8); /* Darker blue gradient header */
56
  color: #ffffff;
57
  padding: 1.5rem;
58
  text-align: center;
@@ -79,7 +87,7 @@ async def read_root(response: Response):
79
  animation: fadeIn 0.3s ease-out;
80
  }
81
  .user-message {
82
- background-color: #4299e1; /* Blue for user messages in dark mode */
83
  align-self: flex-end;
84
  color: #ffffff; /* White text for user messages */
85
  border-bottom-right-radius: 0.5rem;
@@ -333,8 +341,8 @@ async def read_root(response: Response):
333
  throw new Error(`HTTP error! status: ${response.status}`);
334
  }
335
 
336
- const data = await response.text();
337
- addMessage(data || "Sorry, I couldn't get a response.", 'assistant');
338
  } catch (error) {
339
  console.error('Error sending message:', error);
340
  addMessage('Error: Could not connect to the assistant. Please try again.', 'assistant');
@@ -394,7 +402,7 @@ async def handle_chat(chat_request: ChatRequest, token: str = Cookie(None)):
394
  messages=History[i],
395
  )
396
  History[i].append({"role": "assistant", "content": chat_request.prompt})
397
- return stream.choices[0].message.content
398
  else: return 'Please stop. Just refresh the page.'
399
 
400
  @app.post("/history")
 
39
  box-sizing: border-box;
40
  color: #e2e8f0; /* Light text color for general body text */
41
  }
42
+ code {
43
+ margin: 6px 0px;
44
+ display: block;
45
+ border-radius: 12px;
46
+ overflow-x: scroll;
47
+ background-color: #1e1e1e;
48
+ padding: 12px;
49
+ }
50
  .chat-container {
51
  display: flex;
52
  flex-direction: column;
 
60
  border: 1px solid #4a5568; /* Subtle border for dark mode */
61
  }
62
  .chat-header {
63
+ background: linear-gradient(to right, #6a0076, #12327a); /* Darker blue gradient header */
64
  color: #ffffff;
65
  padding: 1.5rem;
66
  text-align: center;
 
87
  animation: fadeIn 0.3s ease-out;
88
  }
89
  .user-message {
90
+ background-color: #12327a; /* Blue for user messages in dark mode */
91
  align-self: flex-end;
92
  color: #ffffff; /* White text for user messages */
93
  border-bottom-right-radius: 0.5rem;
 
341
  throw new Error(`HTTP error! status: ${response.status}`);
342
  }
343
 
344
+ const data = await response.json();
345
+ addMessage(data.text || "Sorry, I couldn't get a response.", 'assistant');
346
  } catch (error) {
347
  console.error('Error sending message:', error);
348
  addMessage('Error: Could not connect to the assistant. Please try again.', 'assistant');
 
402
  messages=History[i],
403
  )
404
  History[i].append({"role": "assistant", "content": chat_request.prompt})
405
+ return {"text": stream.choices[0].message.content}
406
  else: return 'Please stop. Just refresh the page.'
407
 
408
  @app.post("/history")