cryptocalypse commited on
Commit
088992d
·
verified ·
1 Parent(s): 5109ae6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -3
app.py CHANGED
@@ -1,6 +1,26 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
@@ -43,7 +63,10 @@ def respond(
43
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
44
  """
45
  css = "#component-2 {height: 350px}"
 
46
 
 
 
47
  with gr.Blocks(title="Sophia, Torah Codes",css=css) as app:
48
  #with gr.Blocks(theme='gradio/soft') as demo:
49
  #with gr.Blocks(title="Sophia, Torah Codes") as app:
@@ -67,11 +90,11 @@ with gr.Blocks(title="Sophia, Torah Codes",css=css) as app:
67
  search_els = gr.Button("Search",scale=1)
68
  with gr.Row():
69
  #els_results = gr.JSON(label="Results")
70
- els_results = gr.Dataframe(type="pandas")
71
  search_els.click(
72
- els_book,
73
  inputs=[to_convert,to_convert],
74
- outputs=els_results
75
  )
76
 
77
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ import csv
5
+ import json
6
+
7
+ def buscar_en_csv_y_generar_json(archivo_csv, valor_busqueda):
8
+ resultados = []
9
+
10
+ with open(archivo_csv, mode='r', encoding='utf-8') as file:
11
+ reader = csv.reader(file)
12
+
13
+ for fila in reader:
14
+ linea_completa = ','.join(fila)
15
+ if valor_busqueda in linea_completa:
16
+ resultados.append(fila)
17
+
18
+ if resultados:
19
+ return json.dumps(resultados, indent=4, ensure_ascii=False)
20
+ else:
21
+ return json.dumps({"mensaje": "No se encontraron coincidencias."}, indent=4, ensure_ascii=False)
22
+
23
+
24
  """
25
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
26
  """
 
63
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
64
  """
65
  css = "#component-2 {height: 350px}"
66
+ def search(term):
67
 
68
+ return buscar_en_csv_y_generar_json("proyectos_empresas.csv", term)
69
+
70
  with gr.Blocks(title="Sophia, Torah Codes",css=css) as app:
71
  #with gr.Blocks(theme='gradio/soft') as demo:
72
  #with gr.Blocks(title="Sophia, Torah Codes") as app:
 
90
  search_els = gr.Button("Search",scale=1)
91
  with gr.Row():
92
  #els_results = gr.JSON(label="Results")
93
+ results = gr.JSON()
94
  search_els.click(
95
+ search,
96
  inputs=[to_convert,to_convert],
97
+ outputs= results
98
  )
99
 
100