Spaces:
Sleeping
Sleeping
Michael Brunzel
commited on
Commit
·
6f66e5a
1
Parent(s):
e4b08e3
Add request to the model
Browse files- .gitignore +1 -0
- app.py +75 -0
- requirements.txt +4 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
*.env
|
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
from text_generation import Client
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
API_TOKEN = os.environ.get("API_TOKEN", None)
|
9 |
+
MODEL_URL = os.environ.get("MODEL_URL", None)
|
10 |
+
|
11 |
+
def evaluate(hotel_request: str, **kwargs):
|
12 |
+
hf_client = Client(
|
13 |
+
MODEL_URL,
|
14 |
+
headers={"Authorization": f"Bearer {API_TOKEN}"},
|
15 |
+
)
|
16 |
+
|
17 |
+
stream = hf_client.generate_stream(
|
18 |
+
hotel_request,
|
19 |
+
**kwargs,
|
20 |
+
)
|
21 |
+
|
22 |
+
for response in stream:
|
23 |
+
output += response.token.text
|
24 |
+
yield output
|
25 |
+
|
26 |
+
return output
|
27 |
+
|
28 |
+
gr.Interface(
|
29 |
+
fn=evaluate,
|
30 |
+
inputs=[
|
31 |
+
# gr.components.Textbox(
|
32 |
+
# lines=2,
|
33 |
+
# label="Instruction",
|
34 |
+
# placeholder="Tell me about alpacas.",
|
35 |
+
# ),
|
36 |
+
gr.components.Textbox(lines=2, label="Input", placeholder="Request for the Hotel"),
|
37 |
+
# gr.components.Slider(
|
38 |
+
# minimum=0, maximum=1, value=0.1, label="Temperature"
|
39 |
+
# ),
|
40 |
+
# gr.components.Slider(
|
41 |
+
# minimum=0, maximum=1, value=0.75, label="Top p"
|
42 |
+
# ),
|
43 |
+
# gr.components.Slider(
|
44 |
+
# minimum=0, maximum=100, step=1, value=40, label="Top k"
|
45 |
+
# ),
|
46 |
+
# gr.components.Slider(
|
47 |
+
# minimum=1, maximum=4, step=1, value=4, label="Beams"
|
48 |
+
# ),
|
49 |
+
# gr.components.Slider(
|
50 |
+
# minimum=1, maximum=2000, step=1, value=128, label="Max tokens"
|
51 |
+
# ),
|
52 |
+
# gr.components.Checkbox(label="Stream output"),
|
53 |
+
],
|
54 |
+
outputs=[
|
55 |
+
gr.inputs.Textbox(
|
56 |
+
lines=1,
|
57 |
+
label="Guest Name",
|
58 |
+
),
|
59 |
+
gr.inputs.Textbox(
|
60 |
+
lines=1,
|
61 |
+
label="Hotel",
|
62 |
+
),
|
63 |
+
gr.inputs.Textbox(
|
64 |
+
lines=1,
|
65 |
+
label="Location",
|
66 |
+
),
|
67 |
+
gr.inputs.Textbox(
|
68 |
+
lines=1,
|
69 |
+
label="Date",
|
70 |
+
)
|
71 |
+
],
|
72 |
+
allow_flagging="never",
|
73 |
+
title="Falcon-LoRA",
|
74 |
+
description="Falcon-LoRA is a 1B-parameter LLM finetuned to follow instructions. It is trained on the [Hotel Requests](https://huggingface.co/datasets/MichaelAI23/hotel_requests) dataset.", # noqa: E501
|
75 |
+
).queue().launch(server_name="0.0.0.0", server_port=8080)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
python-dotenv
|
2 |
+
gradio
|
3 |
+
bitsandbytes
|
4 |
+
text-generation
|