File size: 1,234 Bytes
b04a659 3538aac d0fb2d4 60e3903 d0fb2d4 60e3903 bf0e3ce 60e3903 d0fb2d4 60e3903 d0fb2d4 74dc24d d0fb2d4 74dc24d d0fb2d4 74dc24d d0fb2d4 74dc24d d9cbde6 |
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 |
import gradio as gr
# Загрузка Gradio интерфейса из Hugging Face Spaces
interface = gr.load("models/Mixtral-8x7B-Instruct-v0.1")
# Определение системного промпта по умолчанию
DEFAULT_SYSTEM_PROMPT = """
You are a helpful assistant in normal conversation.
When given a problem to solve, you are an expert problem-solving assistant.
Your task is to provide a detailed, step-by-step solution to a given question.
"""
# Создание интерфейса чата с подгруженной моделью
with gr.Blocks() as demo:
gr.Markdown("# Custom Chat Interface with AI")
system_prompt = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=5, label="System Prompt")
chatbot = gr.Chatbot(label="Chat")
# Функция для чата с использованием модели
def chat(message, system_prompt):
response = interface([message, system_prompt])
return response
# Отправка сообщений через текстовое поле
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message...")
msg.submit(chat, inputs=[msg, system_prompt], outputs=chatbot)
demo.launch()
|