Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,33 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import InferenceClient
|
3 |
|
4 |
+
client = InferenceClient("moonshotai/Kimi-Dev-72B")
|
5 |
+
|
6 |
+
def chat(message, system_prompt="", max_tokens=1024, temperature=0.9, top_p=0.95, top_k=40, repetition_penalty=1.0):
|
7 |
+
prompt = f"{system_prompt}\n{message}" if system_prompt else message
|
8 |
+
result = client.text_generation(
|
9 |
+
prompt=prompt,
|
10 |
+
max_new_tokens=max_tokens,
|
11 |
+
temperature=temperature,
|
12 |
+
top_p=top_p,
|
13 |
+
repetition_penalty=repetition_penalty,
|
14 |
+
do_sample=True,
|
15 |
+
return_full_text=False
|
16 |
+
)
|
17 |
+
return result
|
18 |
+
|
19 |
+
demo = gr.Interface(
|
20 |
+
fn=chat,
|
21 |
+
inputs=[
|
22 |
+
gr.Textbox(label="Prompt"),
|
23 |
+
gr.Textbox(label="System Prompt", value=""),
|
24 |
+
gr.Slider(1, 2048, value=1024, label="Max Tokens"),
|
25 |
+
gr.Slider(0.1, 1.0, value=0.9, label="Temperature"),
|
26 |
+
gr.Slider(0.1, 1.0, value=0.95, label="Top-p"),
|
27 |
+
gr.Slider(1, 100, value=40, label="Top-k"),
|
28 |
+
gr.Slider(1.0, 2.0, value=1.0, label="Repetition Penalty")
|
29 |
+
],
|
30 |
+
outputs=gr.Textbox(label="Response"),
|
31 |
+
)
|
32 |
+
|
33 |
+
demo.launch()
|