Threatthriver commited on
Commit
2178804
1 Parent(s): ba6c3d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -51,31 +51,24 @@ def respond(
51
  temperature=temperature,
52
  top_p=top_p,
53
  ):
54
- token = message.choices[0].delta.content
55
  response += token
56
  yield response
57
 
58
  except Exception as e:
59
  yield f"An error occurred: {str(e)}"
60
 
61
-
62
  # Define the ChatInterface with additional input components for user customization
63
  demo = gr.ChatInterface(
64
  fn=respond,
65
  additional_inputs=[
66
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
67
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
68
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
69
- gr.Slider(
70
- minimum=0.1,
71
- maximum=1.0,
72
- value=0.95,
73
- step=0.05,
74
- label="Top-p (nucleus sampling)",
75
- ),
76
  ],
77
- title="Chatbot Interface",
78
- description="A customizable chatbot interface using Hugging Face's Inference API.",
79
  )
80
 
81
  # Launch the Gradio interface
 
51
  temperature=temperature,
52
  top_p=top_p,
53
  ):
54
+ token = message.choices[0].delta.get("content", "")
55
  response += token
56
  yield response
57
 
58
  except Exception as e:
59
  yield f"An error occurred: {str(e)}"
60
 
 
61
  # Define the ChatInterface with additional input components for user customization
62
  demo = gr.ChatInterface(
63
  fn=respond,
64
  additional_inputs=[
65
+ gr.Textbox(value="You are a friendly Chatbot.", label="System Message", lines=2),
66
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max New Tokens"),
67
+ gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"),
68
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (Nucleus Sampling)"),
 
 
 
 
 
 
69
  ],
70
+ title="AI Chatbot Interface",
71
+ description="Interact with an AI chatbot powered by Hugging Face's Zephyr-7B model. Customize the chatbot's behavior and response generation settings.",
72
  )
73
 
74
  # Launch the Gradio interface