Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
-
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from minivectordb.embedding_model import EmbeddingModel
|
3 |
from minivectordb.vector_database import VectorDatabase
|
4 |
from text_util_en_pt.cleaner import structurize_text, detect_language, Language
|
@@ -24,12 +31,12 @@ def index_and_search(query, text):
|
|
24 |
|
25 |
# Indexing
|
26 |
vector_db = VectorDatabase()
|
27 |
-
sentences = [
|
28 |
|
29 |
for idx, sentence in enumerate(sentences):
|
30 |
sentence_embedding = model.extract_embeddings(sentence)
|
31 |
vector_db.store_embedding(idx + 1, sentence_embedding, {'sentence': sentence})
|
32 |
-
|
33 |
embedding_time = time.time() - start
|
34 |
|
35 |
# Retrieval
|
@@ -168,10 +175,9 @@ async def predict(message, history):
|
|
168 |
|
169 |
# Define a custom theme with colors similar to the provided image
|
170 |
custom_theme = gr.themes.Default(
|
171 |
-
primary_hue="
|
172 |
-
secondary_hue="
|
173 |
font="Roboto", # Custom font
|
174 |
-
font_size="16px", # Custom font size
|
175 |
rounded_corners=True, # Enable rounded corners
|
176 |
background_color="#1a1a2e", # Custom dark background color
|
177 |
text_color="#f0f0f0" # Custom text color for better contrast
|
@@ -180,13 +186,13 @@ custom_theme = gr.themes.Default(
|
|
180 |
# Apply the custom theme to the Gradio interface
|
181 |
gr.ChatInterface(
|
182 |
predict,
|
183 |
-
title="Assistant
|
184 |
retry_btn=None,
|
185 |
undo_btn=None,
|
186 |
examples=[
|
187 |
'What is the current sentiment of the Brazil election?',
|
188 |
'Compare the current economies of China and India?',
|
189 |
-
'What are new shoe design trends in 2024',
|
190 |
],
|
191 |
theme=custom_theme # Apply the custom theme
|
192 |
-
).launch()
|
|
|
1 |
+
import time
|
2 |
+
import os
|
3 |
+
import multiprocessing
|
4 |
+
import torch
|
5 |
+
import requests
|
6 |
+
import asyncio
|
7 |
+
import json
|
8 |
+
import aiohttp
|
9 |
from minivectordb.embedding_model import EmbeddingModel
|
10 |
from minivectordb.vector_database import VectorDatabase
|
11 |
from text_util_en_pt.cleaner import structurize_text, detect_language, Language
|
|
|
31 |
|
32 |
# Indexing
|
33 |
vector_db = VectorDatabase()
|
34 |
+
sentences = [s['sentence'] for s in structurize_text(text)]
|
35 |
|
36 |
for idx, sentence in enumerate(sentences):
|
37 |
sentence_embedding = model.extract_embeddings(sentence)
|
38 |
vector_db.store_embedding(idx + 1, sentence_embedding, {'sentence': sentence})
|
39 |
+
|
40 |
embedding_time = time.time() - start
|
41 |
|
42 |
# Retrieval
|
|
|
175 |
|
176 |
# Define a custom theme with colors similar to the provided image
|
177 |
custom_theme = gr.themes.Default(
|
178 |
+
primary_hue="purple", # Custom primary color (similar to the purple in the image)
|
179 |
+
secondary_hue="indigo", # Custom secondary color
|
180 |
font="Roboto", # Custom font
|
|
|
181 |
rounded_corners=True, # Enable rounded corners
|
182 |
background_color="#1a1a2e", # Custom dark background color
|
183 |
text_color="#f0f0f0" # Custom text color for better contrast
|
|
|
186 |
# Apply the custom theme to the Gradio interface
|
187 |
gr.ChatInterface(
|
188 |
predict,
|
189 |
+
title="Assistant Pro",
|
190 |
retry_btn=None,
|
191 |
undo_btn=None,
|
192 |
examples=[
|
193 |
'What is the current sentiment of the Brazil election?',
|
194 |
'Compare the current economies of China and India?',
|
195 |
+
'What are new shoe design trends in 2024?',
|
196 |
],
|
197 |
theme=custom_theme # Apply the custom theme
|
198 |
+
).launch()
|