Spaces:
Sleeping
Sleeping
File size: 2,087 Bytes
b973e27 f2f6b48 2f71b8a f2f6b48 b973e27 f2f6b48 b973e27 f2f6b48 2f71b8a f2f6b48 2965cda f2f6b48 2965cda f2f6b48 2965cda f2f6b48 2965cda f2f6b48 2965cda f2f6b48 d882819 f2f6b48 2f71b8a f2f6b48 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
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)") |