Update app.py
Browse files
app.py
CHANGED
@@ -2,21 +2,12 @@ import gradio as gr
|
|
2 |
|
3 |
MODELS = ["Mixtral-8x7B-Instruct-v0.1"]
|
4 |
|
5 |
-
def
|
6 |
-
"""Formats the chat history for processing."""
|
7 |
-
history = [{"role": "system", "content": system_prompt}]
|
8 |
-
history.extend(chat_history)
|
9 |
-
history.append({"role": "user", "content": message})
|
10 |
-
return history
|
11 |
-
|
12 |
-
def generate(message, chat_history, model, system_prompt, thinking_budget):
|
13 |
"""Simulates response generation."""
|
14 |
-
# Dummy logic for simulating a response
|
15 |
response = f"Simulated response for: {message}"
|
16 |
|
17 |
-
# Update chat history
|
18 |
-
chat_history.append(
|
19 |
-
chat_history.append({"role": "assistant", "content": response})
|
20 |
|
21 |
return chat_history, ""
|
22 |
|
@@ -24,7 +15,6 @@ DEFAULT_SYSTEM_PROMPT = """
|
|
24 |
You are a helpful assistant in normal conversation.
|
25 |
When given a problem to solve, you are an expert problem-solving assistant.
|
26 |
Your task is to provide a detailed, step-by-step solution to a given question.
|
27 |
-
...
|
28 |
"""
|
29 |
|
30 |
with gr.Blocks() as demo:
|
@@ -32,9 +22,8 @@ with gr.Blocks() as demo:
|
|
32 |
|
33 |
with gr.Row():
|
34 |
model = gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[0])
|
35 |
-
thinking_budget = gr.Slider(minimum=1, maximum=100, value=10, step=1, label="Thinking Budget")
|
36 |
|
37 |
-
system_prompt = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=
|
38 |
chatbot = gr.Chatbot(label="Chat")
|
39 |
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message...")
|
40 |
|
@@ -43,6 +32,6 @@ with gr.Blocks() as demo:
|
|
43 |
|
44 |
gr.Button("Clear Chat").click(clear_chat, inputs=None, outputs=[chatbot, msg])
|
45 |
|
46 |
-
msg.submit(generate, inputs=[msg, chatbot, model, system_prompt
|
47 |
|
48 |
demo.launch()
|
|
|
2 |
|
3 |
MODELS = ["Mixtral-8x7B-Instruct-v0.1"]
|
4 |
|
5 |
+
def generate(message, chat_history, model, system_prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
"""Simulates response generation."""
|
|
|
7 |
response = f"Simulated response for: {message}"
|
8 |
|
9 |
+
# Update chat history as a list of tuples
|
10 |
+
chat_history.append((message, response))
|
|
|
11 |
|
12 |
return chat_history, ""
|
13 |
|
|
|
15 |
You are a helpful assistant in normal conversation.
|
16 |
When given a problem to solve, you are an expert problem-solving assistant.
|
17 |
Your task is to provide a detailed, step-by-step solution to a given question.
|
|
|
18 |
"""
|
19 |
|
20 |
with gr.Blocks() as demo:
|
|
|
22 |
|
23 |
with gr.Row():
|
24 |
model = gr.Dropdown(choices=MODELS, label="Select Model", value=MODELS[0])
|
|
|
25 |
|
26 |
+
system_prompt = gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, lines=5, label="System Prompt")
|
27 |
chatbot = gr.Chatbot(label="Chat")
|
28 |
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message...")
|
29 |
|
|
|
32 |
|
33 |
gr.Button("Clear Chat").click(clear_chat, inputs=None, outputs=[chatbot, msg])
|
34 |
|
35 |
+
msg.submit(generate, inputs=[msg, chatbot, model, system_prompt], outputs=[chatbot, msg])
|
36 |
|
37 |
demo.launch()
|