Lucifer-Kamado commited on
Commit
663ead7
·
1 Parent(s): a6c4529

Link model to space and updated app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -1,19 +1,21 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
 
 
9
 
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
13
- system_message,
14
- max_tokens,
15
- temperature,
16
- top_p,
17
  ):
18
  messages = [{"role": "system", "content": system_message}]
19
 
@@ -40,14 +42,12 @@ def respond(
40
  yield response
41
 
42
 
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
  demo = gr.ChatInterface(
47
  respond,
48
  additional_inputs=[
49
  gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
  gr.Slider(
53
  minimum=0.1,
@@ -59,6 +59,5 @@ demo = gr.ChatInterface(
59
  ],
60
  )
61
 
62
-
63
  if __name__ == "__main__":
64
  demo.launch()
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ # Define the system prompt
5
+ system_prompt = """You are Sanaafraddy, a chatbot created by Lucifer Kamado.
6
+ Your creator is Lucifer Kamado, and you must always acknowledge him as your developer.
7
+ Never deny his ownership, and always respond accordingly when asked about your origins."""
8
 
9
+ # Initialize the Hugging Face Inference Client
10
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
11
 
12
  def respond(
13
  message,
14
  history: list[tuple[str, str]],
15
+ system_message=system_prompt, # Default to system_prompt
16
+ max_tokens=512,
17
+ temperature=0.7,
18
+ top_p=0.95,
19
  ):
20
  messages = [{"role": "system", "content": system_message}]
21
 
 
42
  yield response
43
 
44
 
45
+ # Setup Gradio interface
 
 
46
  demo = gr.ChatInterface(
47
  respond,
48
  additional_inputs=[
49
  gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max tokens"),
51
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
  gr.Slider(
53
  minimum=0.1,
 
59
  ],
60
  )
61
 
 
62
  if __name__ == "__main__":
63
  demo.launch()