Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,9 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def format_prompt(message, history):
|
4 |
prompt = ""
|
@@ -9,11 +14,15 @@ def format_prompt(message, history):
|
|
9 |
prompt += f"<start_of_turn>user{message}<end_of_turn><start_of_turn>model"
|
10 |
return prompt
|
11 |
|
12 |
-
def generate(
|
|
|
|
|
13 |
if not history:
|
14 |
history = []
|
|
|
15 |
if history:
|
16 |
-
hist_len
|
|
|
17 |
|
18 |
temperature = float(temperature)
|
19 |
if temperature < 1e-2:
|
@@ -80,7 +89,9 @@ additional_inputs=[
|
|
80 |
]
|
81 |
|
82 |
# Create a Chatbot object with the desired height
|
83 |
-
chatbot = gr.Chatbot(height=450,
|
|
|
|
|
84 |
|
85 |
with gr.Blocks() as demo:
|
86 |
gr.HTML("<h1><center>π€ Google-Gemma-7B-Chat π¬<h1><center>")
|
@@ -89,6 +100,7 @@ with gr.Blocks() as demo:
|
|
89 |
chatbot=chatbot, # Use the created Chatbot object
|
90 |
additional_inputs=additional_inputs,
|
91 |
examples=[["What is the meaning of life?"], ["Tell me something about Mt Fuji."]],
|
|
|
92 |
)
|
93 |
|
94 |
demo.queue().launch(debug=True)
|
|
|
1 |
+
from huggingface_hub import InferenceClient
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
client = InferenceClient(
|
5 |
+
"google/gemma-7b-it"
|
6 |
+
)
|
7 |
|
8 |
def format_prompt(message, history):
|
9 |
prompt = ""
|
|
|
14 |
prompt += f"<start_of_turn>user{message}<end_of_turn><start_of_turn>model"
|
15 |
return prompt
|
16 |
|
17 |
+
def generate(
|
18 |
+
prompt, history, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
|
19 |
+
):
|
20 |
if not history:
|
21 |
history = []
|
22 |
+
hist_len=0
|
23 |
if history:
|
24 |
+
hist_len=len(history)
|
25 |
+
print(hist_len)
|
26 |
|
27 |
temperature = float(temperature)
|
28 |
if temperature < 1e-2:
|
|
|
89 |
]
|
90 |
|
91 |
# Create a Chatbot object with the desired height
|
92 |
+
chatbot = gr.Chatbot(height=450,
|
93 |
+
layout="bubble",
|
94 |
+
placeholder="Type here to chat...")
|
95 |
|
96 |
with gr.Blocks() as demo:
|
97 |
gr.HTML("<h1><center>π€ Google-Gemma-7B-Chat π¬<h1><center>")
|
|
|
100 |
chatbot=chatbot, # Use the created Chatbot object
|
101 |
additional_inputs=additional_inputs,
|
102 |
examples=[["What is the meaning of life?"], ["Tell me something about Mt Fuji."]],
|
103 |
+
placeholder="Type here to chat..."
|
104 |
)
|
105 |
|
106 |
demo.queue().launch(debug=True)
|