Rooni's picture
Update app.py
0de3f0b verified
raw
history blame
1.39 kB
import gradio as gr
# Предположим, что модель загружена и доступна
model = gr.load("models/Qwen/Qwen2.5-Coder-32B-Instruct")
def code_assistant(system_message, chat_history, user_input):
if not chat_history:
chat_history.append({"role": "system", "content": system_message})
# Рассмотрим, что модель принимает строку и возвращает строку
response = "Ответ от модели" # Замените на реальный вызов модели, например: model(user_input)
chat_history.append({"role": "user", "content": user_input})
chat_history.append({"role": "assistant", "content": response})
return chat_history
with gr.Blocks() as demo:
gr.Markdown("## Чат-бот для помощи в кодировании")
system_message = gr.Textbox(placeholder="Введите системное сообщение...", label="Системное сообщение")
chatbot = gr.Chatbot(label="Чат с ботом", type='messages')
user_input = gr.Textbox(placeholder="Введите ваш вопрос или код здесь...", label="Ваш ввод")
submit_btn = gr.Button("Отправить")
submit_btn.click(code_assistant, inputs=[system_message, chatbot, user_input], outputs=chatbot)
demo.launch()