Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,13 @@ import gradio as gr
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
4 |
"""
|
5 |
-
For more information on
|
6 |
"""
|
7 |
-
client = InferenceClient("
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
def respond(
|
@@ -25,18 +29,18 @@ def respond(
|
|
25 |
|
26 |
messages.append({"role": "user", "content": message})
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
31 |
max_tokens=max_tokens,
|
32 |
temperature=temperature,
|
33 |
-
top_p=top_p
|
34 |
)
|
|
|
35 |
|
36 |
-
|
37 |
-
response_text = response['generated_text'] # Adapte de acordo com a estrutura da resposta
|
38 |
-
|
39 |
-
return response_text
|
40 |
|
41 |
|
42 |
"""
|
@@ -60,4 +64,4 @@ demo = gr.ChatInterface(
|
|
60 |
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
-
demo.launch()
|
|
|
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("mlx-community/gemma-2-27b-4bit")
|
12 |
|
13 |
|
14 |
def respond(
|
|
|
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 |
"""
|
|
|
64 |
|
65 |
|
66 |
if __name__ == "__main__":
|
67 |
+
demo.launch()
|