andreinigo commited on
Commit
02e8449
·
1 Parent(s): 3883f12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -13,7 +13,7 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
13
  import openai
14
 
15
  def proper_query(query):
16
- prompt = f"El siguiente texto es una pregunta en español: {query}\n\n¿Cómo debería ser la pregunta para que sea correcta en español?\nPregunta corregida:"
17
  response = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=1000, temperature=0.2)
18
  return response.choices[0].text
19
 
@@ -60,7 +60,7 @@ def asesor_transito(query):
60
  "If that context is not helpful to answer the question, then omit it.\n"
61
  "Shorten the answer if possible.\n"
62
  "Reply in the same language as the question.\n"
63
- "If the context is not helpful to answer the question or if it is not a question, then you will refuse to answer.\n"
64
  "Answer:"
65
  )
66
  refine_prompt = PromptTemplate(
@@ -76,7 +76,7 @@ def asesor_transito(query):
76
  "\n---------------------\n"
77
  "Given the context information and not prior knowledge, "
78
  "answer the question: {question}\n"
79
- "If the context is not helpful to answer the question or if it is not a question, then you will refuse to answer.\n"
80
  )
81
  initial_qa_prompt = PromptTemplate(
82
  input_variables=["context_str", "question"], template=initial_qa_template
@@ -89,14 +89,14 @@ def asesor_transito(query):
89
  demo = gr.Interface(
90
  fn=asesor_transito,
91
  inputs=[
92
- gr.Textbox(label="Hola soy tu asesor personal de tránsito de Durango, ¿cuál es tu pregunta? \nHi, I am your Durango transit law personal assistant, ask me anything about Mexico City's transit law in any language.", lines=3,),
93
  ],
94
- outputs=[gr.Textbox(label="Respuesta: \nAnswer: ")],
95
  title="Asesor de Reglamento de Tránsito Durango",
 
96
  examples=[
97
  ["cuál es la multa por no llevar casco?"],
98
  ["qué pasa si no tengo licencia de conducir?"],
99
- ["What would happen if I drove under the influence of alcohol?"]
100
  ],
101
  )
102
 
 
13
  import openai
14
 
15
  def proper_query(query):
16
+ prompt = f"The following text is a question: {query}\nHow should that question be modified so it becomes correctly written in that same language?\nFixed question:"
17
  response = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=1000, temperature=0.2)
18
  return response.choices[0].text
19
 
 
60
  "If that context is not helpful to answer the question, then omit it.\n"
61
  "Shorten the answer if possible.\n"
62
  "Reply in the same language as the question.\n"
63
+ "If the given context is not helpful to answer the question, then you will refuse to answer due to policy guidelines.\n"
64
  "Answer:"
65
  )
66
  refine_prompt = PromptTemplate(
 
76
  "\n---------------------\n"
77
  "Given the context information and not prior knowledge, "
78
  "answer the question: {question}\n"
79
+ "If the context is not helpful to answer the question, then you will refuse to answer due to policy guidelines.\n"
80
  )
81
  initial_qa_prompt = PromptTemplate(
82
  input_variables=["context_str", "question"], template=initial_qa_template
 
89
  demo = gr.Interface(
90
  fn=asesor_transito,
91
  inputs=[
92
+ gr.Textbox(label="Pregunta / Question:", lines=3,),
93
  ],
94
+ outputs=[gr.Textbox(label="Respuesta: / Answer: ")],
95
  title="Asesor de Reglamento de Tránsito Durango",
96
+ description ="Soy Viv, tu asesora personalizada para responder cualquier pregunta sobre el reglamento de tránsito del estado de Durango. Puedes preguntarme en cualquier idioma.",
97
  examples=[
98
  ["cuál es la multa por no llevar casco?"],
99
  ["qué pasa si no tengo licencia de conducir?"],
 
100
  ],
101
  )
102