Dagriffpatchfan commited on
Commit
8aaf228
·
verified ·
1 Parent(s): fdd96bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -30,20 +30,25 @@ def chat_with_gemma(user_input, temperature, top_p, frequency_penalty, presence_
30
 
31
  return response["choices"][0]["message"]["content"].strip()
32
 
33
- # Set up the Gradio interface
34
- demo = gr.Interface(
35
- fn=chat_with_gemma,
36
- inputs=[
37
- gr.Textbox(label="Enter your message to Gemma"),
38
- gr.Slider(0.0, 1.5, value=0.7, step=0.05, label="Temperature"),
39
- gr.Slider(0.0, 1.0, value=0.9, step=0.05, label="Top-p (Nucleus Sampling)"),
40
- gr.Slider(0.0, 2.0, value=0.4, step=0.1, label="Frequency Penalty"),
41
- gr.Slider(0.0, 2.0, value=0.2, step=0.1, label="Presence Penalty")
42
- ],
43
- outputs=gr.Textbox(label="Gemma's Response", lines=8),
44
- title="Talk to Gemma",
45
- description="Generate short responses using Google's Gemma model with adjustable settings. If you want to use this space via api, duplicate it, then look at the end of the app.py file to find a commented out line that you can renable to turn on api useage and protect it with a username and password so trolls don't ruin your api :)"
46
- )
 
 
 
 
 
47
 
48
  # Launch the ap
49
  demo.launch(share=True, enable_api=False)
 
30
 
31
  return response["choices"][0]["message"]["content"].strip()
32
 
33
+ with gr.Blocks() as demo:
34
+ user_input = gr.Textbox(label="Enter your message to Gemma")
35
+ temperature = gr.Slider(0.0, 1.5, value=0.7, step=0.05, label="Temperature")
36
+ top_p = gr.Slider(0.0, 1.0, value=0.9, step=0.05, label="Top-p (Nucleus Sampling)")
37
+ freq_penalty = gr.Slider(0.0, 2.0, value=0.4, step=0.1, label="Frequency Penalty")
38
+ pres_penalty = gr.Slider(0.0, 2.0, value=0.2, step=0.1, label="Presence Penalty")
39
+ output = gr.Textbox(label="Gemma's Response", lines=8)
40
+
41
+ submit_button = gr.Button("Submit")
42
+
43
+ submit_button.click(
44
+ chat_with_gemma,
45
+ inputs=[user_input, temperature, top_p, freq_penalty, pres_penalty],
46
+ outputs=output,
47
+ api_name=False # <---- This disables API for this endpoint
48
+ )
49
+
50
+ demo.launch(share=True)
51
+
52
 
53
  # Launch the ap
54
  demo.launch(share=True, enable_api=False)