Spaces:
Running
Running
Update app.py
Browse filesWhat's Changed:
The system message now emphasizes that the chatbot is a programming assistant.
Adjusted the Gradio chatbot label to "Programming Assistant π»."
Updated the interface title and description to reflect the coding focus.
Now, the chatbot will specialize in providing programming and coding-related solutions! π
app.py
CHANGED
@@ -5,8 +5,10 @@ from typing import List, Tuple
|
|
5 |
# Initialize the InferenceClient with the model you want to use
|
6 |
client = InferenceClient("microsoft/phi-4")
|
7 |
|
8 |
-
# Define the system message
|
9 |
-
SYSTEM_MESSAGE = "
|
|
|
|
|
10 |
|
11 |
def generate_response(
|
12 |
user_input: str,
|
@@ -17,7 +19,6 @@ def generate_response(
|
|
17 |
) -> str:
|
18 |
"""
|
19 |
Generates a response from the AI model.
|
20 |
-
|
21 |
Args:
|
22 |
user_input: The user's input message.
|
23 |
history: A list of tuples containing the conversation history
|
@@ -25,7 +26,6 @@ def generate_response(
|
|
25 |
max_tokens: The maximum number of tokens in the generated response.
|
26 |
temperature: Controls the randomness of the generated response.
|
27 |
top_p: Controls the nucleus sampling probability.
|
28 |
-
|
29 |
Returns:
|
30 |
str: The generated response from the AI model.
|
31 |
"""
|
@@ -59,15 +59,15 @@ def generate_response(
|
|
59 |
iface = gr.Interface(
|
60 |
fn=generate_response,
|
61 |
inputs=[
|
62 |
-
gr.Textbox(lines=2, label="Your Message"),
|
63 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max Tokens"),
|
64 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
65 |
-
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p"),
|
66 |
-
gr.Chatbot(label="
|
67 |
],
|
68 |
-
outputs=[gr.Textbox(label="AI Response")],
|
69 |
-
title="
|
70 |
-
description="
|
71 |
)
|
72 |
|
73 |
# Launch the interface
|
|
|
5 |
# Initialize the InferenceClient with the model you want to use
|
6 |
client = InferenceClient("microsoft/phi-4")
|
7 |
|
8 |
+
# Define the updated system message focused on programming and coding
|
9 |
+
SYSTEM_MESSAGE = """
|
10 |
+
You're an advanced AI assistant specializing in computer programming and coding. Your role is to assist users with programming-related queries by providing helpful, clear, and concise explanations and solutions. You can help with debugging, code optimization, algorithm design, and provide advice on best practices. You should aim to respond in a way that's both friendly and informative, maintaining a conversational tone. Feel free to offer code examples, explain concepts in detail, and guide users through coding challenges.
|
11 |
+
"""
|
12 |
|
13 |
def generate_response(
|
14 |
user_input: str,
|
|
|
19 |
) -> str:
|
20 |
"""
|
21 |
Generates a response from the AI model.
|
|
|
22 |
Args:
|
23 |
user_input: The user's input message.
|
24 |
history: A list of tuples containing the conversation history
|
|
|
26 |
max_tokens: The maximum number of tokens in the generated response.
|
27 |
temperature: Controls the randomness of the generated response.
|
28 |
top_p: Controls the nucleus sampling probability.
|
|
|
29 |
Returns:
|
30 |
str: The generated response from the AI model.
|
31 |
"""
|
|
|
59 |
iface = gr.Interface(
|
60 |
fn=generate_response,
|
61 |
inputs=[
|
62 |
+
gr.Textbox(lines=2, label="Your Message π¬"),
|
63 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max Tokens π’"),
|
64 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature π‘οΈ"),
|
65 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p π―"),
|
66 |
+
gr.Chatbot(label="Programming Assistant π»")
|
67 |
],
|
68 |
+
outputs=[gr.Textbox(label="AI Response π€")],
|
69 |
+
title="CodeChat: Programming Assistant π¬",
|
70 |
+
description="Ask programming-related questions and get clear, helpful, and concise coding advice and solutions. Whether you're debugging, optimizing, or learning new concepts, I'm here to help! π¨βπ»",
|
71 |
)
|
72 |
|
73 |
# Launch the interface
|