stream-gptbeta / app.py
Serg4451D's picture
Update app.py
f2f6b48 verified
raw
history blame
2.09 kB
import streamlit as st
from g4f.client import Client
# Инициализация клиента GPT
client = Client()
# Настройки страницы
st.set_page_config(page_title="Chat with GPT", page_icon="🤖", layout="wide")
# Заголовок и описание
st.title("Chat with GPT-3.5-turbo")
st.write("Welcome to the GPT-3.5-turbo chat interface. Ask me anything!")
# Создание боковой панели для ввода сообщения
with st.sidebar:
user_input = st.text_area("You:", height=100)
send_button = st.button("Send")
# Основной контейнер для чата
chat_container = st.container()
# Обработка отправки сообщения
if send_button and user_input:
# Отправка запроса к GPT
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": user_input}],
)
# Получение ответа
gpt_response = response.choices[0].message.content
# Отображение сообщений в чате
with chat_container:
st.write(f"**You:** {user_input}")
st.write(f"**GPT:** {gpt_response}")
# Пример стилизации с использованием CSS
st.markdown(
"""
<style>
.stTextInput > div > div > textarea {
font-size: 18px;
}
.stButton > button {
background-color: #4CAF50;
color: white;
font-size: 16px;
padding: 10px 20px;
border: none;
cursor: pointer;
}
.stButton > button:hover {
background-color: #45a049;
}
</style>
""",
unsafe_allow_html=True
)
# Пример добавления изображения
st.image("https://via.placeholder.com/150", caption="GPT-3.5-turbo", use_column_width=True)
# Пример добавления разделителя
st.markdown("---")
# Пример добавления ссылки
st.markdown("[Learn more about GPT-3.5-turbo](https://platform.openai.com/docs/models/gpt-3-5)")