Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
def call_api(prompt, history, system_prompt, temperature, max_new_tokens, top_p, repetition_penalty):
|
5 |
+
url = "https://seawolf2357-nvidia-llama-fastapi.hf.space/generate/"
|
6 |
+
data = {
|
7 |
+
"prompt": prompt,
|
8 |
+
"history": history,
|
9 |
+
"system_prompt": system_prompt,
|
10 |
+
"temperature": temperature,
|
11 |
+
"max_new_tokens": max_new_tokens,
|
12 |
+
"top_p": top_p,
|
13 |
+
"repetition_penalty": repetition_penalty
|
14 |
+
}
|
15 |
+
response = requests.post(url, json=data)
|
16 |
+
return response.json()['response']
|
17 |
+
|
18 |
+
def main_interface():
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
with gr.Row():
|
21 |
+
prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
22 |
+
history = gr.Textbox(label="History", placeholder="Enter history here...")
|
23 |
+
system_prompt = gr.Textbox(label="System Prompt", placeholder="Enter system prompt here...")
|
24 |
+
temperature = gr.Number(label="Temperature", value=0.0)
|
25 |
+
max_new_tokens = gr.Number(label="Max New Tokens", value=1048)
|
26 |
+
top_p = gr.Number(label="Top P", value=0.15)
|
27 |
+
repetition_penalty = gr.Number(label="Repetition Penalty", value=1.0)
|
28 |
+
submit_button = gr.Button("Generate")
|
29 |
+
|
30 |
+
submit_button.click(
|
31 |
+
fn=call_api,
|
32 |
+
inputs=[prompt, history, system_prompt, temperature, max_new_tokens, top_p, repetition_penalty],
|
33 |
+
outputs=[gr.Textbox(label="Response")]
|
34 |
+
)
|
35 |
+
|
36 |
+
return demo
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
demo = main_interface()
|
40 |
+
demo.launch()
|