addaweathers commited on
Commit
988a763
Β·
verified Β·
1 Parent(s): f732d40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -23
app.py CHANGED
@@ -10,8 +10,8 @@ from langchain_huggingface import HuggingFaceEmbeddings
10
  from langchain_community.document_loaders import UnstructuredMarkdownLoader
11
  from langchain_text_splitters import MarkdownHeaderTextSplitter
12
  from langchain_community.vectorstores import Chroma
13
- from langchain_classic.chains.combine_documents import create_stuff_documents_chain
14
- from langchain_classic.chains.retrieval import create_retrieval_chain
15
  from langchain_core.prompts import PromptTemplate
16
  from huggingface_hub import InferenceClient
17
  from langchain_core.language_models.llms import LLM
@@ -53,11 +53,8 @@ except FileNotFoundError:
53
  # Create prompt template
54
  template = """
55
  {system_prompt}
56
-
57
  Context: {context}
58
-
59
  Question: {input}
60
-
61
  Answer:"""
62
 
63
  prompt = PromptTemplate(
@@ -119,14 +116,14 @@ def chat_with_portfolio(message, history):
119
  except Exception as e:
120
  return f"Error: {str(e)}"
121
 
122
- # Aesthetics
123
- # Purple Gradient
124
- # Modern Glassmorphism CSS for Gradio 5
125
  custom_css = """
126
  @import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap');
127
 
128
  /* Global Font and Body */
129
- * { font-family: 'Quicksand', sans-serif !important; }
 
 
130
 
131
  /* The Main Background */
132
  .gradio-container {
@@ -135,52 +132,96 @@ custom_css = """
135
  }
136
 
137
  /* Glassmorphism for the Chat bubbles */
138
- .message {
139
  background: rgba(255, 255, 255, 0.15) !important;
140
  backdrop-filter: blur(12px) !important;
141
  -webkit-backdrop-filter: blur(12px) !important;
142
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
143
  border-radius: 20px !important;
144
- color: white !important;
145
  }
146
 
147
- /* Fix the Input Box so it's also Glassy */
148
- footer { display: none !important; } /* Hides the 'built with Gradio' footer */
 
149
 
150
- #input-box textarea {
 
 
151
  background: rgba(255, 255, 255, 0.1) !important;
152
  backdrop-filter: blur(8px) !important;
153
  color: white !important;
154
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
 
155
  }
156
 
157
- /* IMPORTANT: Fixes the "Giant Icon" bug by containing the button size */
158
- button.primary {
159
- max-width: 150px !important;
160
- height: auto !important;
161
  }
162
 
163
- /* Glass effect for the examples buttons */
164
- .load-example-btn {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  background: rgba(255, 255, 255, 0.1) !important;
166
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
167
  color: white !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
169
  """
170
 
171
  with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
172
  # Title with specific white color for contrast
173
- gr.Markdown("<h1 style='text-align: center; color: white;'>πŸˆβ€β¬› Chat with Adda-Bot</h1>")
 
 
174
 
175
  gr.ChatInterface(
176
  fn=chat_with_portfolio,
177
- description="<span style='color: white;'>Ask me anything about Adda's portfolio!</span>",
178
  examples=[
179
  "What is Adda's experience with Python?",
180
  "Tell me about her education.",
181
  "What projects has Adda worked on?"
182
  ],
183
- type="messages", # Ensures modern formatting
 
 
184
  )
185
 
186
  if __name__ == "__main__":
 
10
  from langchain_community.document_loaders import UnstructuredMarkdownLoader
11
  from langchain_text_splitters import MarkdownHeaderTextSplitter
12
  from langchain_community.vectorstores import Chroma
13
+ from langchain.chains.combine_documents import create_stuff_documents_chain
14
+ from langchain.chains.retrieval import create_retrieval_chain
15
  from langchain_core.prompts import PromptTemplate
16
  from huggingface_hub import InferenceClient
17
  from langchain_core.language_models.llms import LLM
 
53
  # Create prompt template
54
  template = """
55
  {system_prompt}
 
56
  Context: {context}
 
57
  Question: {input}
 
58
  Answer:"""
59
 
60
  prompt = PromptTemplate(
 
116
  except Exception as e:
117
  return f"Error: {str(e)}"
118
 
119
+ # Aesthetics - Fixed CSS for proper icon sizing
 
 
120
  custom_css = """
121
  @import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap');
122
 
123
  /* Global Font and Body */
124
+ * {
125
+ font-family: 'Quicksand', sans-serif !important;
126
+ }
127
 
128
  /* The Main Background */
129
  .gradio-container {
 
132
  }
133
 
134
  /* Glassmorphism for the Chat bubbles */
135
+ .message-wrap {
136
  background: rgba(255, 255, 255, 0.15) !important;
137
  backdrop-filter: blur(12px) !important;
138
  -webkit-backdrop-filter: blur(12px) !important;
139
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
140
  border-radius: 20px !important;
 
141
  }
142
 
143
+ .message {
144
+ color: white !important;
145
+ }
146
 
147
+ /* Input Box Styling */
148
+ .input-wrap textarea,
149
+ textarea {
150
  background: rgba(255, 255, 255, 0.1) !important;
151
  backdrop-filter: blur(8px) !important;
152
  color: white !important;
153
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
154
+ border-radius: 12px !important;
155
  }
156
 
157
+ textarea::placeholder {
158
+ color: rgba(255, 255, 255, 0.6) !important;
 
 
159
  }
160
 
161
+ /* FIX FOR HUGE ICONS - Constrain all buttons and icons */
162
+ button {
163
+ max-width: 100px !important;
164
+ max-height: 44px !important;
165
+ min-width: 40px !important;
166
+ padding: 8px 16px !important;
167
+ }
168
+
169
+ button svg {
170
+ width: 20px !important;
171
+ height: 20px !important;
172
+ max-width: 20px !important;
173
+ max-height: 20px !important;
174
+ }
175
+
176
+ /* Specific fix for send button */
177
+ .submit-btn,
178
+ button[aria-label="Submit"] {
179
+ max-width: 60px !important;
180
+ width: 60px !important;
181
+ }
182
+
183
+ /* Example buttons styling */
184
+ .examples button {
185
  background: rgba(255, 255, 255, 0.1) !important;
186
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
187
  color: white !important;
188
+ max-width: 100% !important;
189
+ border-radius: 12px !important;
190
+ }
191
+
192
+ .examples button:hover {
193
+ background: rgba(255, 255, 255, 0.2) !important;
194
+ }
195
+
196
+ /* Hide Gradio footer */
197
+ footer {
198
+ display: none !important;
199
+ }
200
+
201
+ /* Chatbot container styling */
202
+ .chatbot {
203
+ background: rgba(255, 255, 255, 0.05) !important;
204
+ border-radius: 20px !important;
205
  }
206
  """
207
 
208
  with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
209
  # Title with specific white color for contrast
210
+ gr.Markdown(
211
+ "<h1 style='text-align: center; color: white; text-shadow: 2px 2px 4px rgba(0,0,0,0.3);'>πŸˆβ€β¬› Chat with Adda-Bot</h1>"
212
+ )
213
 
214
  gr.ChatInterface(
215
  fn=chat_with_portfolio,
216
+ description="<span style='color: white; font-weight: 600;'>Ask me anything about Adda's portfolio!</span>",
217
  examples=[
218
  "What is Adda's experience with Python?",
219
  "Tell me about her education.",
220
  "What projects has Adda worked on?"
221
  ],
222
+ type="messages",
223
+ textbox=gr.Textbox(placeholder="Ask about Adda's portfolio...", scale=7),
224
+ submit_btn="Send",
225
  )
226
 
227
  if __name__ == "__main__":