timbosssds commited on
Commit
81606be
·
verified ·
1 Parent(s): 032019d

Rename app.py to main.py

Browse files
Files changed (2) hide show
  1. app.py +0 -85
  2. main.py +15 -0
app.py DELETED
@@ -1,85 +0,0 @@
1
- # import gradio as gr
2
- # from huggingface_hub import InferenceClient
3
-
4
- # def form_fn(name, email):
5
- # return f"Name: {name}, Email: {email}"
6
-
7
- # demo = gr.Interface(
8
- # fn=form_fn,
9
- # inputs=[
10
- # gr.inputs.Textbox(label="Name"),
11
- # gr.inputs.Textbox(label="Email")
12
- # ],
13
- # outputs="text"
14
- #)
15
- # demo.launch()
16
-
17
- # ------------
18
-
19
-
20
-
21
- # ------------------ Below works ------------------
22
-
23
- import gradio as gr
24
- from huggingface_hub import InferenceClient
25
-
26
- # """
27
- # For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
28
- # """
29
- # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
30
-
31
-
32
- # def respond(
33
- # message,
34
- # history: list[tuple[str, str]],
35
- # system_message,
36
- # max_tokens,
37
- # temperature,
38
- # top_p,
39
- # ):
40
- # messages = [{"role": "system", "content": system_message}]
41
-
42
- # for val in history:
43
- # if val[0]:
44
- # messages.append({"role": "user", "content": val[0]})
45
- # if val[1]:
46
- # messages.append({"role": "assistant", "content": val[1]})
47
-
48
- # messages.append({"role": "user", "content": message})
49
-
50
- # response = ""
51
-
52
- # for message in client.chat_completion(
53
- # messages,
54
- # max_tokens=max_tokens,
55
- # stream=True,
56
- # temperature=temperature,
57
- # top_p=top_p,
58
- # ):
59
- # token = message.choices[0].delta.content
60
-
61
- # response += token
62
- # yield response
63
-
64
- # """
65
- # For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
66
- # """
67
- demo = gr.ChatInterface(
68
- respond,
69
- additional_inputs=[
70
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
71
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
72
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
73
- gr.Slider(
74
- minimum=0.1,
75
- maximum=1.0,
76
- value=0.95,
77
- step=0.05,
78
- label="Top-p (nucleus sampling)",
79
- ),
80
- ],
81
- )
82
-
83
-
84
- if __name__ == "__main__":
85
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Body
2
+ from llm.model import predict
3
+
4
+ app = FastAPI()
5
+
6
+ @app.post("/predict")
7
+ async def make_prediction(data: dict = Body(...)):
8
+ # Get user input from the request body
9
+ user_input = data["input"]
10
+
11
+ # Call the LLM model for prediction
12
+ output = predict(user_input)
13
+
14
+ # Return the prediction as JSON
15
+ return {"output": output}