File size: 1,393 Bytes
eae9c06
 
fe8d2aa
0de3f0b
9968db4
 
 
f4c1707
9968db4
fe8d2aa
 
7398c3f
f4c1707
 
 
9968db4
 
 
 
 
 
7398c3f
9968db4
 
 
 
 
 
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
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()