Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
import os
|
2 |
os.system('pip install curl_cffi tqdm bitsandbytes tiktoken g4f pinecone-client pandas datasets sentence-transformers')
|
3 |
|
|
|
|
|
|
|
4 |
# Setup and load your keys
|
5 |
import os
|
6 |
from g4f import ChatCompletion
|
7 |
-
#from google.colab import userdata
|
8 |
from pinecone import Pinecone
|
9 |
import pandas as pd
|
10 |
from datasets import Dataset
|
11 |
from sentence_transformers import SentenceTransformer
|
12 |
import gradio as gr
|
13 |
|
14 |
-
|
15 |
#TEMA GRADIO
|
16 |
import gradio as gr
|
17 |
|
18 |
theme = gr.themes.Default(
|
19 |
-
primary_hue=
|
20 |
-
secondary_hue=
|
21 |
-
neutral_hue=gr.themes.Color(c100="#
|
22 |
).set(
|
23 |
background_fill_primary='*background_fill_secondary',
|
24 |
border_color_accent_subdued='*border_color_accent',
|
@@ -69,10 +70,6 @@ theme = gr.themes.Default(
|
|
69 |
|
70 |
model_name = "BAAI/bge-m3"
|
71 |
|
72 |
-
# Retrieve the Pinecone API key from the user
|
73 |
-
PINECONE_API_KEY = "3a3e9022-381d-436e-84cb-ba93464d283e" # Use the key you set in the secrets
|
74 |
-
PINECONE_ENVIRONMENT = "us-east-1" # Use the environment you set in the secrets
|
75 |
-
|
76 |
# Initialize Pinecone with the API key
|
77 |
pc = Pinecone(api_key=PINECONE_API_KEY)
|
78 |
|
@@ -92,9 +89,6 @@ def print_current_selection():
|
|
92 |
# Establecer el nombre del 铆ndice autom谩ticamente
|
93 |
INDEX_NAME = 'neonatos'
|
94 |
|
95 |
-
# Obtener la clave API de Pinecone
|
96 |
-
#PINECONE_API_KEY = userdata.get('PINECONE_API_KEY')
|
97 |
-
|
98 |
def connect_to_pinecone(index_name):
|
99 |
global INDEX_NAME
|
100 |
try:
|
@@ -248,7 +242,6 @@ def chat_function(message, history):
|
|
248 |
if filtered_links:
|
249 |
full_response += filtered_links[0] #f".\n\nRespuesta:\n" + filtered_links[0]
|
250 |
|
251 |
-
|
252 |
# Now handle the images based on the detected tags
|
253 |
tags_to_images = {
|
254 |
"rId101": "images/rId101.png",
|
@@ -297,8 +290,6 @@ def chat_function(message, history):
|
|
297 |
"rId97": "images/rId97.png",
|
298 |
}
|
299 |
|
300 |
-
|
301 |
-
|
302 |
for tag in tags_detected:
|
303 |
for key, path in tags_to_images.items():
|
304 |
if key in tag and check_image_exists(path):
|
@@ -314,7 +305,6 @@ def update_image(image_url):
|
|
314 |
else:
|
315 |
return None
|
316 |
|
317 |
-
|
318 |
images = [
|
319 |
{"id": "rId101", "path": "images/rId101.png", "description": "馃搳 El c贸digo UBIGEO muestra que Lima (150101) tiene el mayor n煤mero de registros, seguido por Trujillo (130101) y San Juan de Miraflores (150133), destacando la concentraci贸n de atenci贸n m茅dica en estas zonas. Un gr谩fico de barras visualiza los 10 c贸digos UBIGEO m谩s frecuentes, facilitando la identificaci贸n de las 谩reas con mayor actividad en salud."},
|
320 |
{"id": "rId105", "path": "images/rId105.png", "description": "馃彞 Los establecimientos de nivel 3 son los m谩s representados, con 652,948 registros, seguidos por los de nivel 4 (310,272) y nivel 2 (277,385)."},
|
@@ -362,8 +352,6 @@ images = [
|
|
362 |
{"id": "rId97", "path": "images/rId97.png", "description": ""},
|
363 |
]
|
364 |
|
365 |
-
|
366 |
-
|
367 |
# Gradio layout setup
|
368 |
with gr.Blocks(theme=theme) as demo:
|
369 |
with gr.Row():
|
|
|
1 |
import os
|
2 |
os.system('pip install curl_cffi tqdm bitsandbytes tiktoken g4f pinecone-client pandas datasets sentence-transformers')
|
3 |
|
4 |
+
PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
|
5 |
+
PINECONE_ENVIRONMENT = os.getenv("PINECONE_ENVIRONMENT")
|
6 |
+
|
7 |
# Setup and load your keys
|
8 |
import os
|
9 |
from g4f import ChatCompletion
|
|
|
10 |
from pinecone import Pinecone
|
11 |
import pandas as pd
|
12 |
from datasets import Dataset
|
13 |
from sentence_transformers import SentenceTransformer
|
14 |
import gradio as gr
|
15 |
|
|
|
16 |
#TEMA GRADIO
|
17 |
import gradio as gr
|
18 |
|
19 |
theme = gr.themes.Default(
|
20 |
+
primary_hue="indigo",
|
21 |
+
secondary_hue="indigo",
|
22 |
+
neutral_hue=gr.themes.Color(c100="#384b8f", c200="#d7dbe5", c300="#1d1d20", c400="#1d1d20", c50="#657ed2", c500="#fcfcfc", c600="#3d3e52", c700="#383947", c800="#242429", c900="#29292e", c950="#292932"),
|
23 |
).set(
|
24 |
background_fill_primary='*background_fill_secondary',
|
25 |
border_color_accent_subdued='*border_color_accent',
|
|
|
70 |
|
71 |
model_name = "BAAI/bge-m3"
|
72 |
|
|
|
|
|
|
|
|
|
73 |
# Initialize Pinecone with the API key
|
74 |
pc = Pinecone(api_key=PINECONE_API_KEY)
|
75 |
|
|
|
89 |
# Establecer el nombre del 铆ndice autom谩ticamente
|
90 |
INDEX_NAME = 'neonatos'
|
91 |
|
|
|
|
|
|
|
92 |
def connect_to_pinecone(index_name):
|
93 |
global INDEX_NAME
|
94 |
try:
|
|
|
242 |
if filtered_links:
|
243 |
full_response += filtered_links[0] #f".\n\nRespuesta:\n" + filtered_links[0]
|
244 |
|
|
|
245 |
# Now handle the images based on the detected tags
|
246 |
tags_to_images = {
|
247 |
"rId101": "images/rId101.png",
|
|
|
290 |
"rId97": "images/rId97.png",
|
291 |
}
|
292 |
|
|
|
|
|
293 |
for tag in tags_detected:
|
294 |
for key, path in tags_to_images.items():
|
295 |
if key in tag and check_image_exists(path):
|
|
|
305 |
else:
|
306 |
return None
|
307 |
|
|
|
308 |
images = [
|
309 |
{"id": "rId101", "path": "images/rId101.png", "description": "馃搳 El c贸digo UBIGEO muestra que Lima (150101) tiene el mayor n煤mero de registros, seguido por Trujillo (130101) y San Juan de Miraflores (150133), destacando la concentraci贸n de atenci贸n m茅dica en estas zonas. Un gr谩fico de barras visualiza los 10 c贸digos UBIGEO m谩s frecuentes, facilitando la identificaci贸n de las 谩reas con mayor actividad en salud."},
|
310 |
{"id": "rId105", "path": "images/rId105.png", "description": "馃彞 Los establecimientos de nivel 3 son los m谩s representados, con 652,948 registros, seguidos por los de nivel 4 (310,272) y nivel 2 (277,385)."},
|
|
|
352 |
{"id": "rId97", "path": "images/rId97.png", "description": ""},
|
353 |
]
|
354 |
|
|
|
|
|
355 |
# Gradio layout setup
|
356 |
with gr.Blocks(theme=theme) as demo:
|
357 |
with gr.Row():
|