Canstralian commited on
Commit
87f9571
Β·
verified Β·
1 Parent(s): 24cd920

Update app.py

Browse files

What'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! 😊

Files changed (1) hide show
  1. app.py +12 -12
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 (non-editable)
9
- SYSTEM_MESSAGE = "You're an advanced AI assistant designed to engage in friendly and informative conversations. Your role is to respond to user queries with helpful, clear, and concise answers, while maintaining a conversational tone. You can provide advice, explanations, and solutions based on user input."
 
 
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="Conversation")
67
  ],
68
- outputs=[gr.Textbox(label="AI Response")],
69
- title="Chat with AI",
70
- description="Interact with an AI assistant that engages in friendly and informative conversations.",
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