dromerosm commited on
Commit
e51357b
1 Parent(s): 1153626

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -9,8 +9,12 @@ import requests
9
  import time
10
 
11
 
12
- # define the text summarizer function
13
- def text_prompt(page_url, contraseña, temp):
 
 
 
 
14
  # Reemplazar estas líneas con cadenas de texto fijas
15
  request = """Analizar el siguiente texto de una noticia en prensa y generar un informe tipo KYC (Know Your Customer) para análisis de riesgos, considerando los siguientes aspectos:
16
  1. Identificación de las partes involucradas (personas, empresas, entidades)
@@ -68,7 +72,7 @@ def text_prompt(page_url, contraseña, temp):
68
  start_time = time.time()
69
  try:
70
  response = openai.ChatCompletion.create(
71
- model="gpt-3.5-turbo",
72
  messages=[
73
  {"role": "system", "content": system_role},
74
  {"role": "user", "content": request + "\n\n" + 'Text:\n\n"' + page_text + '\n"'}
@@ -99,15 +103,17 @@ iface = gr.Interface(
99
  fn=text_prompt,
100
  inputs=[
101
  gr.Textbox(lines=1, placeholder="Enter the Article's URL here...", label="Article's URL to analyse:", type="text"),
 
102
  gr.Textbox(lines=1, placeholder="Enter your API-key here...", label="API-Key:", type="password"),
103
  gr.Slider(0.0,1.0, value=0.3, label="Temperature:")
104
  ],
105
  outputs=[gr.Textbox(label="Text from URL:"), gr.Markdown(label="Output from GPT:"), gr.Markdown(label="Total Tokens:")],
106
- examples=[[ "https://www.eleconomista.es/andalucia/noticias/11534190/12/21/Nueva-condena-a-ex-presidente-de-Invercaria-por-dar-300000-euros-a-una-empresa-inviable.html","",0.2],
107
- ["https://www.eleconomista.es/andalucia/noticias/11533733/12/21/El-juez-procesa-a-35-investigados-en-la-pieza-de-las-sobrecomisiones-de-los-ERE-.html","",0.7]
108
  ],
109
  title="ChatGPT - KYC from URL",
110
- description="This tool allows to generate points of a KYC report based on the text retrieved from the URL using the [gpt-3.5-turbo] engine of OpenAI.Provide the url for text retrieval, your api-key and the temperature to process the text."
 
111
  )
112
 
113
  # error capturing in integration as a component
 
9
  import time
10
 
11
 
12
+ # define azure openai context
13
+
14
+ openai.api_type = "azure"
15
+ openai.api_version = "2023-03-15-preview"
16
+
17
+ def text_prompt(page_url, contraseña, temp, azure_endpoint):
18
  # Reemplazar estas líneas con cadenas de texto fijas
19
  request = """Analizar el siguiente texto de una noticia en prensa y generar un informe tipo KYC (Know Your Customer) para análisis de riesgos, considerando los siguientes aspectos:
20
  1. Identificación de las partes involucradas (personas, empresas, entidades)
 
72
  start_time = time.time()
73
  try:
74
  response = openai.ChatCompletion.create(
75
+ engine="gpt-35-turbo-version-0301",
76
  messages=[
77
  {"role": "system", "content": system_role},
78
  {"role": "user", "content": request + "\n\n" + 'Text:\n\n"' + page_text + '\n"'}
 
103
  fn=text_prompt,
104
  inputs=[
105
  gr.Textbox(lines=1, placeholder="Enter the Article's URL here...", label="Article's URL to analyse:", type="text"),
106
+ gr.Textbox(lines=1, placeholder="Enter the MSFT Azure OpenAI endpoint here...", label="Azure endpoint:", type="text")
107
  gr.Textbox(lines=1, placeholder="Enter your API-key here...", label="API-Key:", type="password"),
108
  gr.Slider(0.0,1.0, value=0.3, label="Temperature:")
109
  ],
110
  outputs=[gr.Textbox(label="Text from URL:"), gr.Markdown(label="Output from GPT:"), gr.Markdown(label="Total Tokens:")],
111
+ examples=[[ "https://www.eleconomista.es/andalucia/noticias/11534190/12/21/Nueva-condena-a-ex-presidente-de-Invercaria-por-dar-300000-euros-a-una-empresa-inviable.html","","",0.2],
112
+ ["https://www.eleconomista.es/andalucia/noticias/11533733/12/21/El-juez-procesa-a-35-investigados-en-la-pieza-de-las-sobrecomisiones-de-los-ERE-.html","","",0.7]
113
  ],
114
  title="ChatGPT - KYC from URL",
115
+ description="""This tool allows to generate points of a KYC report based on the text retrieved from the URL using the [gpt-3.5-turbo] engine of MSFT Azure OpenAI.
116
+ Provide the url for text retrieval, your endopoint, api-key and the temperature to process the text."""
117
  )
118
 
119
  # error capturing in integration as a component