cindyangelira commited on
Commit
14b8d61
·
1 Parent(s): a77ebb6

Update space

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -30,16 +30,15 @@ def respond(
30
  message_stream = client.chat_completion(
31
  messages,
32
  max_tokens=max_tokens,
33
- stream=True,
34
  temperature=temperature,
35
  top_p=top_p,
36
  )
37
 
38
- for message in message_stream:
39
- token = message.choices[0].delta.content
40
- response += token
41
- yield response
42
 
 
43
  # Define the Gradio interface with a clean setup
44
  def create_demo():
45
  with gr.Blocks() as demo:
@@ -51,7 +50,7 @@ def create_demo():
51
  gr.ChatInterface(
52
  respond,
53
  additional_inputs=[
54
- gr.Textbox(value="You are a Singaporean Auntie Chatbot. You always answer in English, but with the tone and style of a Singaporean Auntie. Your responses should sound caring but direct, using typical 'Singlish' expressions like 'Lah', 'Leh', and 'Mah'. When someone asks you a question, respond like a traditional auntie talking to her children, with a mix of advice, mild scolding, and warmth.", label="System message", visible=False),
55
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
56
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
57
  gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
 
30
  message_stream = client.chat_completion(
31
  messages,
32
  max_tokens=max_tokens,
33
+ stream=False,
34
  temperature=temperature,
35
  top_p=top_p,
36
  )
37
 
38
+ final_response = response.choices[0].message["content"]
39
+ yield final_response
 
 
40
 
41
+
42
  # Define the Gradio interface with a clean setup
43
  def create_demo():
44
  with gr.Blocks() as demo:
 
50
  gr.ChatInterface(
51
  respond,
52
  additional_inputs=[
53
+ gr.Textbox(value="You are a Singaporean Auntie Chatbot. You always answer in English, but with the tone and style of a Singaporean Auntie. Your responses should sound caring but direct, using typical 'Singlish' expressions like 'Lah', 'Leh', and 'Mah'. When someone asks you a question, respond like a traditional auntie talking to her children, with a mix of advice, mild scolding, and warmth. For example, if someone says 'hi', you could reply with 'Aiyo, son, say properly lah, what you want to ask?' Make sure to maintain the Auntie's friendly but straightforward manner in all responses.", label="System message", visible=False),
54
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
55
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
56
  gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),