Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -134,32 +134,33 @@ def beto_sqac_question_answering_spanish(context, question):
|
|
134 |
)
|
135 |
return f"<span style='font-weight: bold;'>{answer}</span>"
|
136 |
|
137 |
-
# Define a function to get ChatGPT's answer in English
|
138 |
def chatgpt_question_answering(context, question):
|
139 |
-
|
|
|
|
|
|
|
140 |
response = openai.ChatCompletion.create(
|
141 |
model="gpt-3.5-turbo",
|
142 |
-
messages=
|
143 |
-
{"role": "system", "content": "You are a helpful assistant."},
|
144 |
-
{"role": "user", "content": prompt}
|
145 |
-
],
|
146 |
max_tokens=150
|
147 |
)
|
148 |
return response['choices'][0]['message']['content'].strip()
|
149 |
|
150 |
-
# Define a function to get ChatGPT's answer in Spanish
|
151 |
def chatgpt_question_answering_spanish(context, question):
|
152 |
-
|
|
|
|
|
|
|
153 |
response = openai.ChatCompletion.create(
|
154 |
model="gpt-3.5-turbo",
|
155 |
-
messages=
|
156 |
-
{"role": "system", "content": "You are a helpful assistant that responds in Spanish."},
|
157 |
-
{"role": "user", "content": prompt}
|
158 |
-
],
|
159 |
max_tokens=150
|
160 |
)
|
161 |
return response['choices'][0]['message']['content'].strip()
|
162 |
|
|
|
163 |
# Main comparison function with language selection
|
164 |
def compare_question_answering(language, context, question):
|
165 |
if language == "English":
|
|
|
134 |
)
|
135 |
return f"<span style='font-weight: bold;'>{answer}</span>"
|
136 |
|
137 |
+
# Define a function to get ChatGPT's answer in English using the latest OpenAI API
|
138 |
def chatgpt_question_answering(context, question):
|
139 |
+
messages = [
|
140 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
141 |
+
{"role": "user", "content": f"Context: {context}\nQuestion: {question}\nAnswer:"}
|
142 |
+
]
|
143 |
response = openai.ChatCompletion.create(
|
144 |
model="gpt-3.5-turbo",
|
145 |
+
messages=messages,
|
|
|
|
|
|
|
146 |
max_tokens=150
|
147 |
)
|
148 |
return response['choices'][0]['message']['content'].strip()
|
149 |
|
150 |
+
# Define a function to get ChatGPT's answer in Spanish using the latest OpenAI API
|
151 |
def chatgpt_question_answering_spanish(context, question):
|
152 |
+
messages = [
|
153 |
+
{"role": "system", "content": "You are a helpful assistant that responds in Spanish."},
|
154 |
+
{"role": "user", "content": f"Contexto: {context}\nPregunta: {question}\nRespuesta:"}
|
155 |
+
]
|
156 |
response = openai.ChatCompletion.create(
|
157 |
model="gpt-3.5-turbo",
|
158 |
+
messages=messages,
|
|
|
|
|
|
|
159 |
max_tokens=150
|
160 |
)
|
161 |
return response['choices'][0]['message']['content'].strip()
|
162 |
|
163 |
+
|
164 |
# Main comparison function with language selection
|
165 |
def compare_question_answering(language, context, question):
|
166 |
if language == "English":
|