garrethlee commited on
Commit
3248cbc
·
verified ·
1 Parent(s): 8190924
Files changed (1) hide show
  1. app.py +20 -17
app.py CHANGED
@@ -38,8 +38,10 @@ def respond(
38
 
39
  outputs = pipeline(
40
  messages,
41
- max_new_tokens=256,
42
- eos_token_id=terminators,
 
 
43
  )
44
 
45
  yield outputs[0]["generated_text"][-1]["content"]
@@ -47,21 +49,22 @@ def respond(
47
  """
48
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
49
  """
50
- demo = gr.ChatInterface(
51
- respond,
52
- additional_inputs=[
53
- gr.Textbox(value="Kamu adalah seorang asisten yang baik", label="System message"),
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(
57
- minimum=0.1,
58
- maximum=1.0,
59
- value=0.95,
60
- step=0.05,
61
- label="Top-p (nucleus sampling)",
62
- ),
63
- ],
64
- )
 
65
 
66
 
67
  if __name__ == "__main__":
 
38
 
39
  outputs = pipeline(
40
  messages,
41
+ max_new_tokens=max_tokens,
42
+ temperature=temprature,
43
+ top_p=top_p,
44
+ eos_token_id=terminators
45
  )
46
 
47
  yield outputs[0]["generated_text"][-1]["content"]
 
49
  """
50
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
51
  """
52
+ with gr.Blocks() as demo:
53
+ gr.Markdown("# 🇮🇩 Sahabat AI (Gemma)")
54
+ gr.ChatInterface(
55
+ respond,
56
+ additional_inputs=[
57
+ gr.Slider(minimum=1, maximum=2048, value=256, step=1, label="Max new tokens"),
58
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
59
+ gr.Slider(
60
+ minimum=0.1,
61
+ maximum=1.0,
62
+ value=0.95,
63
+ step=0.05,
64
+ label="Top-p (nucleus sampling)",
65
+ ),
66
+ ],
67
+ )
68
 
69
 
70
  if __name__ == "__main__":