File size: 2,373 Bytes
6f66e5a
 
e8c7621
6f66e5a
 
 
 
 
 
 
e8c7621
 
6f66e5a
e8c7621
6f66e5a
e8c7621
 
6f66e5a
e8c7621
6f66e5a
e8c7621
6619948
6f66e5a
6619948
6f66e5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b05c47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import gradio as gr
import os
import requests
from dotenv import load_dotenv

load_dotenv()

API_TOKEN = os.environ.get("API_TOKEN", None)
MODEL_URL = os.environ.get("MODEL_URL", None)

def evaluate(hotel_request: str):
    resp = requests.post(
        MODEL_URL,
        json={"inputs": hotel_request},
        headers={"Authorization": f"Bearer {API_TOKEN}"},
        cookies=None,
        timeout=10,
    )
    payload = resp.json()

    text = payload[0]["generated_text"]
    name, location, hotel, date = text.split("|")

    return name, hotel, location, date

gr.Interface(
        fn=evaluate,
        inputs=[
        #     gr.components.Textbox(
        #         lines=2,
        #         label="Instruction",
        #         placeholder="Tell me about alpacas.",
        #     ),
            gr.components.Textbox(lines=2, label="Input", placeholder="Request for the Hotel"),
        #     gr.components.Slider(
        #         minimum=0, maximum=1, value=0.1, label="Temperature"
        #     ),
        #     gr.components.Slider(
        #         minimum=0, maximum=1, value=0.75, label="Top p"
        #     ),
        #     gr.components.Slider(
        #         minimum=0, maximum=100, step=1, value=40, label="Top k"
        #     ),
        #     gr.components.Slider(
        #         minimum=1, maximum=4, step=1, value=4, label="Beams"
        #     ),
        #     gr.components.Slider(
        #         minimum=1, maximum=2000, step=1, value=128, label="Max tokens"
        #     ),
        #     gr.components.Checkbox(label="Stream output"),
        ],
        outputs=[
            gr.inputs.Textbox(
                lines=1,
                label="Guest Name",
            ),
            gr.inputs.Textbox(
                lines=1,
                label="Hotel",
            ),
            gr.inputs.Textbox(
                lines=1,
                label="Location",
            ),
            gr.inputs.Textbox(
                lines=1,
                label="Date",
            )
        ],
        allow_flagging="never",
        title="Falcon-LoRA",
        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
    ).queue().launch() #server_name="0.0.0.0", server_port=8080)