Blood076 commited on
Commit
260a182
verified
1 Parent(s): 438a7aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -1
app.py CHANGED
@@ -1,4 +1,67 @@
1
  import gradio as gr
 
2
 
 
 
 
 
 
 
 
 
3
 
4
- gr.load("models/unsloth/Llama-3.2-90B-Vision-Instruct-bnb-4bit").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
 
4
+ """
5
+ 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
6
+ """
7
+ #client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
+ #client = InferenceClient("meta-llama/Llama-3.2-1B-Instruct")
9
+ #client = InferenceClient("microsoft/Phi-3.5-mini-instruct")
10
+ #client = InferenceClient("unsloth/Llama-3.2-1B-Instruct")
11
+ client = InferenceClient("unsloth/Llama-3.2-90B-Vision-Instruct")
12
 
13
+
14
+ def respond(
15
+ message,
16
+ history: list[tuple[str, str]],
17
+ system_message,
18
+ max_tokens,
19
+ temperature,
20
+ top_p,
21
+ ):
22
+ messages = [{"role": "system", "content": system_message}]
23
+
24
+ for val in history:
25
+ if val[0]:
26
+ messages.append({"role": "user", "content": val[0]})
27
+ if val[1]:
28
+ messages.append({"role": "assistant", "content": val[1]})
29
+
30
+ messages.append({"role": "user", "content": message})
31
+
32
+ response = ""
33
+
34
+
35
+ mensagens = client.chat_completion(
36
+ messages,
37
+ max_tokens=max_tokens,
38
+ temperature=temperature,
39
+ top_p=top_p,
40
+ )
41
+ response = mensagens.choices[0].message.content
42
+
43
+ return response
44
+
45
+
46
+ """
47
+ For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
48
+ """
49
+ demo = gr.ChatInterface(
50
+ respond,
51
+ additional_inputs=[
52
+ gr.Textbox(value="Voc锚 se chama Esquizofrenia, voc锚 茅 ir么nico e t铆mido", label="System message"),
53
+ gr.Slider(minimum=1, maximum=2048, value=256, step=1, label="Max new tokens"),
54
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.6, step=0.1, label="Temperature"),
55
+ gr.Slider(
56
+ minimum=0.1,
57
+ maximum=1.0,
58
+ value=0.95,
59
+ step=0.05,
60
+ label="Top-p (nucleus sampling)",
61
+ ),
62
+ ],
63
+ )
64
+
65
+
66
+ if __name__ == "__main__":
67
+ demo.launch()