mghfuran commited on
Commit
6655bba
·
1 Parent(s): fc6bf70

improved UI

Browse files
app/db/chroma_db/23f2383a-bc2a-4575-b666-457f51e5ace2/data_level0.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f184fcd1ad26216dcd4cb25b3d8c7102ce8bdac472f9123d7a0bd690cb16203e
3
  size 167600
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:449f4c7300e27db7cc31b150d55bfea03a4a0063336dfe82708a66dbf29155c0
3
  size 167600
app/db/chroma_db/23f2383a-bc2a-4575-b666-457f51e5ace2/length.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b436d17e60e5190e774a48dd8dc933612d97f4ff534c4abefd3bbe2749a26e07
3
  size 400
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:801a6a4d727650a6001fa2c76d01e392fc1b8a6eb5cbd421874f275396c94d66
3
  size 400
app/db/chroma_db/chroma.sqlite3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c71970583f1119e810a22d5d7429a8ce940e4852e67d71d22c0f83928776ae10
3
  size 253952
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1eb6c5e4f4c5657fba85680c82e04a6b3732f5e3265480ddbe24a256b183b823
3
  size 253952
app/main.py CHANGED
@@ -1,61 +1,157 @@
1
  import uvicorn
2
  from fastapi import FastAPI, Form
3
  from fastapi.responses import HTMLResponse
 
4
  from app.services.llm_service import ask_llm
5
 
6
  app = FastAPI()
7
 
 
 
 
8
  CHAT_HTML = """
9
  <html>
10
  <head>
11
- <title>Z Logistics Virtual Agent</title>
12
  <style>
13
  body {
14
- font-family: Arial;
15
- background-color: #f4f4f4;
16
  display: flex;
17
  justify-content: center;
18
  align-items: center;
19
  height: 100vh;
 
20
  }
21
  .chat-container {
22
- width: 500px;
23
  background: white;
24
- padding: 20px;
25
- border-radius: 10px;
26
- box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
  .messages {
29
- height: 300px;
30
  overflow-y: auto;
31
- border: 1px solid #ddd;
32
- padding: 10px;
33
- margin-bottom: 10px;
 
 
 
 
 
 
 
34
  }
35
  .user {
36
- color: blue;
37
- margin-bottom: 10px;
38
  }
39
  .bot {
40
- color: green;
41
- margin-bottom: 10px;
 
 
 
 
 
 
 
 
42
  }
43
  input {
44
- width: 75%;
45
- padding: 10px;
 
 
 
 
 
 
 
 
46
  }
47
  button {
48
- padding: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
  </style>
51
  </head>
52
  <body>
53
  <div class="chat-container">
54
- <h2>ZTranAgent Chat</h2>
 
 
 
 
 
 
 
55
  <div class="messages" id="messages"></div>
56
- <input type="text" id="messageInput" placeholder="Type message">
57
- <button onclick="sendMessage()">Send</button>
 
 
 
 
 
 
 
58
  </div>
 
59
  <script>
60
  async function sendMessage() {
61
  let input = document.getElementById("messageInput");
@@ -64,29 +160,30 @@ async function sendMessage() {
64
 
65
  let messages = document.getElementById("messages");
66
  messages.innerHTML += `
67
- <div class="user">
68
  <b>You:</b> ${message}
69
  </div>
70
  `;
71
 
 
 
 
72
  let response = await fetch('/api/chat', {
73
  method: 'POST',
74
  headers: {
75
  'Content-Type': 'application/x-www-form-urlencoded'
76
  },
77
- body: `message=${message}`
78
  });
79
 
80
  let data = await response.json();
81
 
82
- // Fixed: Changed "ZBot" to "bot" to match your CSS class rules
83
  messages.innerHTML += `
84
- <div class="bot">
85
  <b>Z:</b> ${data.response}
86
  </div>
87
  `;
88
 
89
- input.value = "";
90
  messages.scrollTop = messages.scrollHeight;
91
  }
92
 
@@ -115,12 +212,11 @@ def chat_page():
115
 
116
  @app.post("/api/chat")
117
  def api_chat(message: str = Form(...)):
118
- # Activated: Now using the real model response from your service
119
  bot_response = ask_llm(message)
120
  return {
121
  "response": bot_response
122
  }
123
 
124
- # Replace your original execution block at the bottom of main.py with this:
125
  if __name__ == "__main__":
126
  uvicorn.run("app.main:app", host="0.0.0.0", port=7860, reload=False)
 
1
  import uvicorn
2
  from fastapi import FastAPI, Form
3
  from fastapi.responses import HTMLResponse
4
+ from fastapi.staticfiles import StaticFiles
5
  from app.services.llm_service import ask_llm
6
 
7
  app = FastAPI()
8
 
9
+ # Mount the static directory to serve local image assets securely
10
+ app.mount("/static", StaticFiles(directory="app/static"), name="static")
11
+
12
  CHAT_HTML = """
13
  <html>
14
  <head>
15
+ <title>Virtual Agent</title>
16
  <style>
17
  body {
18
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
19
+ background-color: #f0f2f5;
20
  display: flex;
21
  justify-content: center;
22
  align-items: center;
23
  height: 100vh;
24
+ margin: 0;
25
  }
26
  .chat-container {
27
+ width: 520px;
28
  background: white;
29
+ padding: 30px;
30
+ border-radius: 16px;
31
+ box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.08);
32
+ display: flex;
33
+ flex-direction: column;
34
+ }
35
+ .brand-header {
36
+ display: flex;
37
+ align-items: center;
38
+ gap: 15px;
39
+ margin-bottom: 5px;
40
+ }
41
+ .logo-img {
42
+ width: 50px;
43
+ height: 50px;
44
+ object-fit: contain;
45
+ border-radius: 50%;
46
+ }
47
+ .brand-title {
48
+ font-size: 24px;
49
+ font-weight: 700;
50
+ color: #1e293b;
51
+ margin: 0;
52
+ }
53
+ .brand-description {
54
+ font-size: 13px;
55
+ color: #64748b;
56
+ margin: 0 0 20px 0;
57
+ line-height: 1.5;
58
+ border-bottom: 1px solid #e2e8f0;
59
+ padding-bottom: 15px;
60
  }
61
  .messages {
62
+ height: 330px;
63
  overflow-y: auto;
64
+ border: 1px solid #e2e8f0;
65
+ border-radius: 10px;
66
+ padding: 15px;
67
+ margin-bottom: 15px;
68
+ background-color: #fafafa;
69
+ }
70
+ .message-row {
71
+ margin-bottom: 12px;
72
+ line-height: 1.5;
73
+ font-size: 14px;
74
  }
75
  .user {
76
+ color: #1d4ed8;
 
77
  }
78
  .bot {
79
+ color: #047857;
80
+ background-color: #f0fdf4;
81
+ padding: 8px 12px;
82
+ border-radius: 8px;
83
+ border-left: 3px solid #10b981;
84
+ }
85
+ .input-group {
86
+ display: flex;
87
+ gap: 10px;
88
+ margin-bottom: 15px;
89
  }
90
  input {
91
+ flex: 1;
92
+ padding: 12px;
93
+ border: 1px solid #cbd5e1;
94
+ border-radius: 8px;
95
+ font-size: 14px;
96
+ outline: none;
97
+ transition: border-color 0.2s;
98
+ }
99
+ input:focus {
100
+ border-color: #3b82f6;
101
  }
102
  button {
103
+ padding: 12px 24px;
104
+ background-color: #2563eb;
105
+ color: white;
106
+ border: none;
107
+ border-radius: 8px;
108
+ font-weight: 600;
109
+ cursor: pointer;
110
+ transition: background-color 0.2s;
111
+ }
112
+ button:hover {
113
+ background-color: #1d4ed8;
114
+ }
115
+ .chat-footer {
116
+ text-align: center;
117
+ font-size: 11px;
118
+ color: #94a3b8;
119
+ margin-top: 5px;
120
+ letter-spacing: 0.3px;
121
+ }
122
+ .chat-footer a {
123
+ color: #64748b;
124
+ text-decoration: none;
125
+ font-weight: 500;
126
+ }
127
+ .chat-footer a:hover {
128
+ text-decoration: underline;
129
+ color: #2563eb;
130
  }
131
  </style>
132
  </head>
133
  <body>
134
  <div class="chat-container">
135
+ <div class="brand-header">
136
+ <img class="logo-img" src="/static/Z_Logo_Circle.png" alt="Z Virtual Agent Logo">
137
+ <h2 class="brand-title">Virtual Agent</h2>
138
+ </div>
139
+ <p class="brand-description">
140
+ Intelligent automation and knowledge retrieval framework for Z Logistics operations. Ask questions regarding company SOPs, driver policies, onboarding protocols, and compliance directives.
141
+ </p>
142
+
143
  <div class="messages" id="messages"></div>
144
+
145
+ <div class="input-group">
146
+ <input type="text" id="messageInput" placeholder="Ask Z Virtual Agent...">
147
+ <button onclick="sendMessage()">Send</button>
148
+ </div>
149
+
150
+ <div class="chat-footer">
151
+ Powered by <b>Z Consulting</b> &bull; <a href="https://www.zedtex.us" target="_blank">www.zedtex.us</a>
152
+ </div>
153
  </div>
154
+
155
  <script>
156
  async function sendMessage() {
157
  let input = document.getElementById("messageInput");
 
160
 
161
  let messages = document.getElementById("messages");
162
  messages.innerHTML += `
163
+ <div class="message-row user">
164
  <b>You:</b> ${message}
165
  </div>
166
  `;
167
 
168
+ messages.scrollTop = messages.scrollHeight;
169
+ input.value = "";
170
+
171
  let response = await fetch('/api/chat', {
172
  method: 'POST',
173
  headers: {
174
  'Content-Type': 'application/x-www-form-urlencoded'
175
  },
176
+ body: `message=${encodeURIComponent(message)}`
177
  });
178
 
179
  let data = await response.json();
180
 
 
181
  messages.innerHTML += `
182
+ <div class="message-row bot">
183
  <b>Z:</b> ${data.response}
184
  </div>
185
  `;
186
 
 
187
  messages.scrollTop = messages.scrollHeight;
188
  }
189
 
 
212
 
213
  @app.post("/api/chat")
214
  def api_chat(message: str = Form(...)):
 
215
  bot_response = ask_llm(message)
216
  return {
217
  "response": bot_response
218
  }
219
 
220
+
221
  if __name__ == "__main__":
222
  uvicorn.run("app.main:app", host="0.0.0.0", port=7860, reload=False)
app/static/Z_Logo_Circle.png ADDED