Spaces:
Sleeping
Sleeping
Update Final Draft
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
+
|
| 5 |
+
def respond(
|
| 6 |
+
message,
|
| 7 |
+
max_tokens,
|
| 8 |
+
temperature,
|
| 9 |
+
top_p
|
| 10 |
+
):
|
| 11 |
+
|
| 12 |
+
client = InferenceClient(token=os.getenv('write_token'), model="meta-llama/Meta-Llama-3-70B", provider="featherless-ai")
|
| 13 |
+
|
| 14 |
+
output = client.text_generation(
|
| 15 |
+
message,
|
| 16 |
+
max_new_tokens=max_tokens,
|
| 17 |
+
stream=False,
|
| 18 |
+
temperature=temperature,
|
| 19 |
+
top_p=top_p,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
return output
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
demo = gr.Interface(
|
| 26 |
+
fn=respond,
|
| 27 |
+
inputs=[
|
| 28 |
+
gr.Textbox(
|
| 29 |
+
lines=10,
|
| 30 |
+
label="Input Message",
|
| 31 |
+
placeholder="Enter your message here...",
|
| 32 |
+
),
|
| 33 |
+
gr.Slider(minimum=1, maximum=512, value=256, step=1, label="Max new tokens"),
|
| 34 |
+
gr.Slider(minimum=0, maximum=2.0, value=1, step=0.01, label="Temperature"),
|
| 35 |
+
gr.Slider(
|
| 36 |
+
minimum=0.1,
|
| 37 |
+
maximum=1.0,
|
| 38 |
+
value=0.95,
|
| 39 |
+
step=0.05,
|
| 40 |
+
label="Top-p (nucleus sampling)",
|
| 41 |
+
),
|
| 42 |
+
],
|
| 43 |
+
outputs=gr.Textbox(lines=10, label="Response")
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
if __name__ == "__main__":
|
| 48 |
+
demo.launch()
|