cha0smagick
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from freeGPT import Client
|
3 |
+
|
4 |
+
# Configuraci贸n de la aplicaci贸n
|
5 |
+
st.set_page_config(page_title="Chat interactivo con selecci贸n de modelo", layout="centered")
|
6 |
+
st.title("Chat interactivo con selecci贸n de modelo")
|
7 |
+
|
8 |
+
# Lista de modelos disponibles
|
9 |
+
MODELS = {
|
10 |
+
"GPT-3 (chat9.yqcloud.top)": "gpt3",
|
11 |
+
"GPT-4 (you.com)": "gpt4",
|
12 |
+
"GPT-3.5 (vitalentum.net)": "gpt3_5",
|
13 |
+
}
|
14 |
+
|
15 |
+
# Selecci贸n del modelo
|
16 |
+
selected_model_name = st.selectbox("Selecciona el modelo con el que deseas chatear:", list(MODELS.keys()))
|
17 |
+
selected_model = MODELS[selected_model_name]
|
18 |
+
|
19 |
+
# 脕rea para el chat
|
20 |
+
if "chat_history" not in st.session_state:
|
21 |
+
st.session_state.chat_history = []
|
22 |
+
|
23 |
+
# Entrada del usuario
|
24 |
+
user_input = st.text_input("Tu mensaje:", "")
|
25 |
+
|
26 |
+
if st.button("Enviar") and user_input:
|
27 |
+
# A帽adir entrada del usuario al historial
|
28 |
+
st.session_state.chat_history.append(("馃懄", user_input))
|
29 |
+
|
30 |
+
try:
|
31 |
+
# Crear respuesta utilizando el modelo seleccionado
|
32 |
+
response = Client.create_completion(selected_model, user_input)
|
33 |
+
st.session_state.chat_history.append(("馃", response))
|
34 |
+
except Exception as e:
|
35 |
+
st.session_state.chat_history.append(("馃", str(e)))
|
36 |
+
|
37 |
+
# Mostrar el historial del chat
|
38 |
+
for sender, message in st.session_state.chat_history:
|
39 |
+
if sender == "馃懄":
|
40 |
+
st.markdown(f"**{sender}**: {message}")
|
41 |
+
else:
|
42 |
+
st.markdown(f"**{sender}**: {message}")
|