matiasbonfanti commited on
Commit
da5c532
1 Parent(s): 49162c6

modelos 2.1

Browse files
Files changed (1) hide show
  1. app.py +52 -14
app.py CHANGED
@@ -11,6 +11,10 @@ link = None
11
  response2 = None
12
  response3 = None
13
  traductor = GoogleTranslator(source='en', target='es')
 
 
 
 
14
 
15
  def generate_text(text):
16
  url = f"https://api.yelp.com/v3/businesses/{text}/reviews?limit=1&sort_by=yelp_sort"
@@ -26,6 +30,8 @@ def generate_text(text):
26
  user = response['reviews'][0]['user']['name']
27
  image = response['reviews'][0]['user']['image_url']
28
  link = response['reviews'][0]['url']
 
 
29
  openai.api_key = "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"
30
  traduccion = traductor.translate(review)
31
  response2 = openai.Completion.create(
@@ -41,12 +47,38 @@ def generate_text(text):
41
 
42
 
43
 
44
- return review,user,image,response2,traduccion
45
 
46
 
47
 
48
 
49
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  with gr.Column():
51
  seed = gr.Textbox(label="Introducir el nombre de la empresa o su Id")
52
  with gr.Row():
@@ -54,32 +86,38 @@ with gr.Blocks() as demo:
54
  gr.Examples(["versailles-miami-4"], inputs=[seed])
55
  gr.Examples(["la-casa-de-toño-ciudad-de-méxico-4"], inputs=[seed])
56
  gr.Examples(["osteria-del-bugiardo-verona"], inputs=[seed])
57
- gr.Examples(["arume-barcelona"], inputs=[seed])
58
-
59
 
 
 
 
 
60
 
61
 
62
  with gr.Row():
63
- review = gr.Text(label="Generated English Text")
64
- image = gr.Image(label="Avatar", height= 20, width=20)
65
- user = gr.Text(label="Generated English Text")
 
 
 
 
 
 
66
 
67
 
68
-
69
  with gr.Row():
70
  traduccion = gr.Textbox(label="Traduccion Review")
 
 
71
  with gr.Row():
72
  response2 = gr.Textbox(label="Respuesta GPT-3")
73
 
74
-
75
-
76
  with gr.Row():
77
  btn = gr.Button("Iniciar Modelo")
78
- btn.click(generate_text, inputs=[seed], outputs=[review,user,image,response2,traduccion])
79
-
80
-
81
-
82
-
83
 
84
  if __name__ == "__main__":
85
  demo.launch()
 
11
  response2 = None
12
  response3 = None
13
  traductor = GoogleTranslator(source='en', target='es')
14
+ traduccion = None
15
+ calificacion = None
16
+ creacion = None
17
+
18
 
19
  def generate_text(text):
20
  url = f"https://api.yelp.com/v3/businesses/{text}/reviews?limit=1&sort_by=yelp_sort"
 
30
  user = response['reviews'][0]['user']['name']
31
  image = response['reviews'][0]['user']['image_url']
32
  link = response['reviews'][0]['url']
33
+ calificacion = response['reviews'][0]['rating']
34
+ creacion = response['reviews'][0]['time_created']
35
  openai.api_key = "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"
36
  traduccion = traductor.translate(review)
37
  response2 = openai.Completion.create(
 
47
 
48
 
49
 
50
+ return review,user,image,response2,traduccion,calificacion,creacion
51
 
52
 
53
 
54
 
55
  with gr.Blocks() as demo:
56
+ gr.Markdown(
57
+ """
58
+ <p align="center">
59
+ <img src="https://neurona-ba.com/wp-content/uploads/2021/07/HenryLogo.jpg">
60
+ <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/Yelp_Logo.svg/465px-Yelp_Logo.svg.png?20210803213252">
61
+ </p>
62
+ <p align="center">
63
+ <img width=1024 src="https://raw.githubusercontent.com/BonfantiMatias/images/0b4c42f7b313156ea6fb396d32d98221783fb5cc/gradio1.png">
64
+ </p>
65
+ """
66
+ )
67
+ gr.Markdown(
68
+ """
69
+ <p align="center">
70
+ </p>
71
+ <p align="center">
72
+ </p>
73
+ """
74
+ )
75
+ gr.Markdown("# Paso 1: Ingresar el Negocio")
76
+ gr.Markdown(
77
+ """
78
+ - Puede ingresar el Negocio por su Alias o ID de [YELP.com](https://www.yelp.com)
79
+ - Precionar el Boton 'Iniciar Modelo' que se encuentra al final de la pagina
80
+ """
81
+ )
82
  with gr.Column():
83
  seed = gr.Textbox(label="Introducir el nombre de la empresa o su Id")
84
  with gr.Row():
 
86
  gr.Examples(["versailles-miami-4"], inputs=[seed])
87
  gr.Examples(["la-casa-de-toño-ciudad-de-méxico-4"], inputs=[seed])
88
  gr.Examples(["osteria-del-bugiardo-verona"], inputs=[seed])
89
+ gr.Examples(["arume-barcelona"], inputs=[seed])
 
90
 
91
+
92
+
93
+ gr.Markdown("# Mediante la Api Yelp Fusion se obtienen los datos de la ultima review del local seleccionado")
94
+
95
 
96
 
97
  with gr.Row():
98
+
99
+ with gr.Column():
100
+ user = gr.Textbox(label="Id Cliente" )
101
+ review = gr.Textbox(label="Reseña Cliente")
102
+ calificacion = gr.Textbox(label="Calificacion de la reseña")
103
+ creacion = gr.Textbox(label="Fecha de creacion de la reseña")
104
+ with gr.Column():
105
+ image = gr.Image(label="Avatar Cliente", lines= 7, max_lines=10)
106
+
107
 
108
 
109
+ gr.Markdown("# Traduccion de la review al idioma español")
110
  with gr.Row():
111
  traduccion = gr.Textbox(label="Traduccion Review")
112
+
113
+ gr.Markdown("# Respuesta a la review implementando el modelo GPT-3 de OpenAi")
114
  with gr.Row():
115
  response2 = gr.Textbox(label="Respuesta GPT-3")
116
 
 
 
117
  with gr.Row():
118
  btn = gr.Button("Iniciar Modelo")
119
+ btn.click(generate_text, inputs=[seed], outputs=[review,user,image,response2,traduccion,calificacion,creacion])
120
+
 
 
 
121
 
122
  if __name__ == "__main__":
123
  demo.launch()