MAIChat
Browse filesopenai
streamlit
app.py
CHANGED
@@ -1,8 +1,28 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
2 |
|
3 |
# T铆tulo de la aplicaci贸n
|
4 |
-
st.title("
|
|
|
|
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import openai
|
3 |
+
|
4 |
+
# Configura tu clave de OpenAI
|
5 |
+
openai.api_key = "TU_API_KEY_AQU脥"
|
6 |
|
7 |
# T铆tulo de la aplicaci贸n
|
8 |
+
st.title("Chat IA sin restricciones 馃")
|
9 |
+
|
10 |
+
# Input del usuario
|
11 |
+
user_input = st.text_input("Hazme una pregunta:")
|
12 |
|
13 |
+
# Procesa la respuesta de la IA
|
14 |
+
if user_input:
|
15 |
+
try:
|
16 |
+
with st.spinner("Pensando... 馃"):
|
17 |
+
response = openai.ChatCompletion.create(
|
18 |
+
model="gpt-3.5-turbo",
|
19 |
+
messages=[
|
20 |
+
{"role": "system", "content": "Eres un asistente 煤til y sin sesgos."},
|
21 |
+
{"role": "user", "content": user_input},
|
22 |
+
],
|
23 |
+
)
|
24 |
+
answer = response["choices"][0]["message"]["content"]
|
25 |
+
st.success("隆Respuesta lista! 馃槉")
|
26 |
+
st.write(answer)
|
27 |
+
except Exception as e:
|
28 |
+
st.error(f"Hubo un error: {e}")
|