Update gdmk_aux.py
Browse files- gdmk_aux.py +52 -1
gdmk_aux.py
CHANGED
@@ -1 +1,52 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Define the LLM function
|
2 |
+
def generacion_llm(texto_input):
|
3 |
+
# Define the system and user messages
|
4 |
+
formato_json = '''
|
5 |
+
{
|
6 |
+
"nombre_usuario": " ",
|
7 |
+
"ubicaci贸n_geogr谩fica": " ",
|
8 |
+
"descripci贸n_reto": " ",
|
9 |
+
"dudas_conceptuales": " ",
|
10 |
+
"certezas_conceptuales": " ",
|
11 |
+
"expectativas_del_taller": " "
|
12 |
+
}
|
13 |
+
'''
|
14 |
+
|
15 |
+
mensaje_sistema = (
|
16 |
+
"Eres un experto en identificar aspectos descriptivos de las razones "
|
17 |
+
"por las cuales un usuario necesita asesor铆a para implementar retos "
|
18 |
+
"que involucren inteligencia artificial de varios tipos."
|
19 |
+
)
|
20 |
+
|
21 |
+
mensaje_usuario = (
|
22 |
+
f"Analizar el texto: \nTexto a Analizar: {texto_input}, que es una redacci贸n \
|
23 |
+
libre de un usuario que busca asesor铆a para su uso 贸ptimo de la inteligencia \
|
24 |
+
artificial, que busca orientaci贸n a trav茅s de un taller de asesor铆a de un facilitador, \
|
25 |
+
para lo cual te pido identifiques los siguientes extractos del texto \
|
26 |
+
en el formato JSON: {formato_json}\n Si no hubiera claridad suficiente sobre alguno \
|
27 |
+
de los contenidos del formato JSON, escribir 'No hay suficiente informaci贸n'"
|
28 |
+
)
|
29 |
+
|
30 |
+
version_model = 'gpt-3.5-turbo-0125'
|
31 |
+
|
32 |
+
# Call OpenAI API
|
33 |
+
try:
|
34 |
+
response = client.chat.completions.create(
|
35 |
+
model=version_model,
|
36 |
+
messages=[
|
37 |
+
{"role": "system", "content": mensaje_sistema},
|
38 |
+
{"role": "user", "content": mensaje_usuario}
|
39 |
+
],
|
40 |
+
temperature=0.8,
|
41 |
+
max_tokens=300,
|
42 |
+
top_p=1,
|
43 |
+
|
44 |
+
)
|
45 |
+
|
46 |
+
# Extract the generated text from the response
|
47 |
+
texto_respuesta = response.choices[0].message.content
|
48 |
+
|
49 |
+
# Try parsing as JSON (if applicable)
|
50 |
+
return texto_respuesta # Return plain text for now (replace with JSON if needed)
|
51 |
+
except Exception as e:
|
52 |
+
return f"Error: {e}"
|