Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,37 +22,43 @@ openai.api_key = api_key
|
|
| 22 |
|
| 23 |
# Custom CSS for better styling
|
| 24 |
custom_css = """
|
| 25 |
-
.gradio-container {
|
| 26 |
-
max-width: 1200px !important;
|
| 27 |
-
margin: 0 auto !important;
|
| 28 |
-
font-family: 'Inter', sans-serif;
|
| 29 |
height: 100vh !important;
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
|
|
|
| 32 |
.container {
|
| 33 |
max-width: 1200px;
|
| 34 |
margin: 0 auto;
|
| 35 |
padding: 20px;
|
| 36 |
height: 100%;
|
| 37 |
}
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
border-radius: 16px;
|
| 41 |
-
padding: 24px;
|
| 42 |
background: white;
|
| 43 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.
|
| 44 |
margin-bottom: 20px;
|
| 45 |
-
|
| 46 |
-
overflow-y: auto;
|
| 47 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
.file-upload {
|
| 49 |
border: 2px dashed #e0e0e0;
|
| 50 |
-
border-radius: 16px;
|
| 51 |
padding: 24px;
|
| 52 |
text-align: center;
|
| 53 |
-
background: #f8f9fa;
|
| 54 |
transition: all 0.3s ease;
|
| 55 |
-
margin-bottom: 20px;
|
| 56 |
}
|
| 57 |
.file-upload:hover {
|
| 58 |
border-color: #4CAF50;
|
|
@@ -60,13 +66,11 @@ custom_css = """
|
|
| 60 |
transform: translateY(-2px);
|
| 61 |
}
|
| 62 |
.audio-recorder {
|
| 63 |
-
background: #f8f9fa;
|
| 64 |
-
border-radius: 16px;
|
| 65 |
padding: 24px;
|
| 66 |
text-align: center;
|
| 67 |
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 68 |
-
margin-bottom: 20px;
|
| 69 |
}
|
|
|
|
| 70 |
.record-button {
|
| 71 |
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
|
| 72 |
color: white;
|
|
@@ -129,8 +133,9 @@ custom_css = """
|
|
| 129 |
border-radius: 12px !important;
|
| 130 |
border: 2px solid #e0e0e0 !important;
|
| 131 |
padding: 16px !important;
|
| 132 |
-
|
| 133 |
-
|
|
|
|
| 134 |
}
|
| 135 |
@keyframes pulse {
|
| 136 |
0% { transform: scale(1); box-shadow: 0 4px 6px rgba(244, 67, 54, 0.2); }
|
|
@@ -138,41 +143,17 @@ custom_css = """
|
|
| 138 |
100% { transform: scale(1); box-shadow: 0 4px 6px rgba(244, 67, 54, 0.2); }
|
| 139 |
}
|
| 140 |
|
| 141 |
-
/*
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
}
|
| 146 |
-
#component-1 {
|
| 147 |
-
height: 100% !important;
|
| 148 |
-
overflow-y: auto !important;
|
| 149 |
-
}
|
| 150 |
-
#component-2 {
|
| 151 |
-
height: 100% !important;
|
| 152 |
-
overflow-y: auto !important;
|
| 153 |
-
}
|
| 154 |
-
|
| 155 |
-
/* Ensure the chat interface takes full height */
|
| 156 |
-
#chat-interface {
|
| 157 |
-
height: 100% !important;
|
| 158 |
-
display: flex !important;
|
| 159 |
-
flex-direction: column !important;
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
-
/* Make sure the chat messages container scrolls */
|
| 163 |
-
#chat-messages {
|
| 164 |
-
flex: 1 !important;
|
| 165 |
-
overflow-y: auto !important;
|
| 166 |
-
padding: 20px !important;
|
| 167 |
}
|
| 168 |
|
| 169 |
-
/*
|
| 170 |
-
#chat-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
padding: 20px !important;
|
| 175 |
-
border-top: 1px solid #e0e0e0 !important;
|
| 176 |
}
|
| 177 |
"""
|
| 178 |
|
|
@@ -281,12 +262,12 @@ class AdvancedRAG:
|
|
| 281 |
if not self.thread_id:
|
| 282 |
self.create_thread()
|
| 283 |
|
| 284 |
-
# Add the file to the thread with the required tools
|
| 285 |
openai.beta.threads.messages.create(
|
| 286 |
thread_id=self.thread_id,
|
| 287 |
role="user",
|
| 288 |
content="I have uploaded a document. Please analyze it.",
|
| 289 |
-
attachments=[{"file_id": file_obj.id, "tools": ["file_search"]}]
|
| 290 |
)
|
| 291 |
|
| 292 |
return file_obj.id
|
|
|
|
| 22 |
|
| 23 |
# Custom CSS for better styling
|
| 24 |
custom_css = """
|
| 25 |
+
html, body, .gradio-container {
|
|
|
|
|
|
|
|
|
|
| 26 |
height: 100vh !important;
|
| 27 |
+
min-height: 100vh !important;
|
| 28 |
+
max-width: 100vw !important;
|
| 29 |
+
margin: 0 !important;
|
| 30 |
+
padding: 0 !important;
|
| 31 |
+
font-family: 'Inter', sans-serif;
|
| 32 |
+
overflow: auto !important;
|
| 33 |
+
background: #fafbfc;
|
| 34 |
}
|
| 35 |
+
|
| 36 |
.container {
|
| 37 |
max-width: 1200px;
|
| 38 |
margin: 0 auto;
|
| 39 |
padding: 20px;
|
| 40 |
height: 100%;
|
| 41 |
}
|
| 42 |
+
|
| 43 |
+
.chat-container, .file-upload, .audio-recorder {
|
| 44 |
+
box-sizing: border-box;
|
| 45 |
border-radius: 16px;
|
|
|
|
| 46 |
background: white;
|
| 47 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.07);
|
| 48 |
margin-bottom: 20px;
|
| 49 |
+
width: 100%;
|
|
|
|
| 50 |
}
|
| 51 |
+
|
| 52 |
+
.chat-container {
|
| 53 |
+
border: 1px solid #e0e0e0;
|
| 54 |
+
padding: 24px;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
.file-upload {
|
| 58 |
border: 2px dashed #e0e0e0;
|
|
|
|
| 59 |
padding: 24px;
|
| 60 |
text-align: center;
|
|
|
|
| 61 |
transition: all 0.3s ease;
|
|
|
|
| 62 |
}
|
| 63 |
.file-upload:hover {
|
| 64 |
border-color: #4CAF50;
|
|
|
|
| 66 |
transform: translateY(-2px);
|
| 67 |
}
|
| 68 |
.audio-recorder {
|
|
|
|
|
|
|
| 69 |
padding: 24px;
|
| 70 |
text-align: center;
|
| 71 |
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
|
|
|
| 72 |
}
|
| 73 |
+
|
| 74 |
.record-button {
|
| 75 |
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
|
| 76 |
color: white;
|
|
|
|
| 133 |
border-radius: 12px !important;
|
| 134 |
border: 2px solid #e0e0e0 !important;
|
| 135 |
padding: 16px !important;
|
| 136 |
+
width: 100% !important;
|
| 137 |
+
box-sizing: border-box !important;
|
| 138 |
+
background: #fff !important;
|
| 139 |
}
|
| 140 |
@keyframes pulse {
|
| 141 |
0% { transform: scale(1); box-shadow: 0 4px 6px rgba(244, 67, 54, 0.2); }
|
|
|
|
| 143 |
100% { transform: scale(1); box-shadow: 0 4px 6px rgba(244, 67, 54, 0.2); }
|
| 144 |
}
|
| 145 |
|
| 146 |
+
/* Remove extra scrollbars and ensure only one main scroll */
|
| 147 |
+
body, .gradio-container, #root, #app {
|
| 148 |
+
overflow: auto !important;
|
| 149 |
+
height: 100vh !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
+
/* Remove scroll from inner components */
|
| 153 |
+
#component-0, #component-1, #component-2, .chatbot, .chat-container {
|
| 154 |
+
overflow: visible !important;
|
| 155 |
+
height: auto !important;
|
| 156 |
+
max-height: none !important;
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
"""
|
| 159 |
|
|
|
|
| 262 |
if not self.thread_id:
|
| 263 |
self.create_thread()
|
| 264 |
|
| 265 |
+
# Add the file to the thread with the required tools object
|
| 266 |
openai.beta.threads.messages.create(
|
| 267 |
thread_id=self.thread_id,
|
| 268 |
role="user",
|
| 269 |
content="I have uploaded a document. Please analyze it.",
|
| 270 |
+
attachments=[{"file_id": file_obj.id, "tools": [{"type": "file_search"}]}]
|
| 271 |
)
|
| 272 |
|
| 273 |
return file_obj.id
|