Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
interface = gr.load("models/
|
5 |
|
6 |
-
# Определение системного промпта по умолчанию
|
7 |
DEFAULT_SYSTEM_PROMPT = """
|
8 |
You are a helpful assistant in normal conversation.
|
9 |
When given a problem to solve, you are an expert problem-solving assistant.
|
10 |
Your task is to provide a detailed, step-by-step solution to a given question.
|
11 |
"""
|
12 |
|
13 |
-
# Создание интерфейса чата
|
14 |
with gr.Blocks() as demo:
|
15 |
gr.Markdown("# Custom Chat Interface with AI")
|
16 |
-
|
17 |
system_prompt = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=5, label="System Prompt")
|
18 |
chatbot = gr.Chatbot(label="Chat")
|
19 |
|
20 |
-
# Функция для
|
21 |
-
def chat(message
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
# Отправка сообщений через текстовое поле
|
26 |
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message...")
|
27 |
-
msg.submit(chat, inputs=
|
28 |
|
29 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Предполагается, что модель уже загружена и доступна через Gradio interface
|
4 |
+
interface = gr.load("models/Mixtral-8x7B-Instruct-v0.1")
|
5 |
|
|
|
6 |
DEFAULT_SYSTEM_PROMPT = """
|
7 |
You are a helpful assistant in normal conversation.
|
8 |
When given a problem to solve, you are an expert problem-solving assistant.
|
9 |
Your task is to provide a detailed, step-by-step solution to a given question.
|
10 |
"""
|
11 |
|
12 |
+
# Создание интерфейса чата
|
13 |
with gr.Blocks() as demo:
|
14 |
gr.Markdown("# Custom Chat Interface with AI")
|
15 |
+
|
16 |
system_prompt = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=5, label="System Prompt")
|
17 |
chatbot = gr.Chatbot(label="Chat")
|
18 |
|
19 |
+
# Функция для обработки сообщений пользователя и получения ответов от модели
|
20 |
+
def chat(message):
|
21 |
+
# Формирование входных данных для модели
|
22 |
+
chat_history = [(message, "user")] # Пользовательское сообщение
|
23 |
+
# Вызов модели для генерации ответа
|
24 |
+
response = interface([system_prompt.value, message]) # Пример вызова модели, зависит от реализации
|
25 |
+
chat_history.append((response, "assistant")) # Ответ ассистента
|
26 |
+
return chat_history
|
27 |
|
|
|
28 |
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message...")
|
29 |
+
msg.submit(chat, inputs=msg, outputs=chatbot)
|
30 |
|
31 |
+
demo.launch()
|