bharatcoder commited on
Commit
17f1324
·
verified ·
1 Parent(s): bddd93d

Make system prompt optional, increase max_tokens limit

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -26,8 +26,9 @@ def get_inference_client(selected_model):
26
  def get_response(user_input, history, selected_model, system_prompt, temperature, max_tokens, top_p):
27
  client = get_inference_client(selected_model)
28
 
29
- # Add system message
30
- messages = [{"role": "system", "content": system_prompt}]
 
31
 
32
  # Include previous conversation history
33
  for h in history:
@@ -65,9 +66,9 @@ with gr.Blocks() as demo:
65
  selected_model = gr.Dropdown(choices=list(models.keys()), label="Select Model", value="Llama-3.3-70B-Instruct")
66
 
67
  # Chat settings
68
- system_prompt = gr.Textbox(value="You are a friendly and open-minded chatbot.", label="System Prompt", lines=5)
69
  temperature = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.7, label="Temperature")
70
- max_tokens = gr.Slider(minimum=10, maximum=1000, step=10, value=250, label="Max Tokens")
71
  top_p = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.9, label="Top-p")
72
 
73
  # Chatbot interaction
 
26
  def get_response(user_input, history, selected_model, system_prompt, temperature, max_tokens, top_p):
27
  client = get_inference_client(selected_model)
28
 
29
+ # Add system message, if not empty
30
+ if (len(system_prompt)) > 0:
31
+ messages = [{"role": "system", "content": system_prompt}]
32
 
33
  # Include previous conversation history
34
  for h in history:
 
66
  selected_model = gr.Dropdown(choices=list(models.keys()), label="Select Model", value="Llama-3.3-70B-Instruct")
67
 
68
  # Chat settings
69
+ system_prompt = gr.Textbox(value="You are a friendly and open-minded chatbot.", label="System Prompt (Optional)", lines=5)
70
  temperature = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.7, label="Temperature")
71
+ max_tokens = gr.Slider(minimum=10, maximum=8192, step=10, value=250, label="Max Tokens")
72
  top_p = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.9, label="Top-p")
73
 
74
  # Chatbot interaction