Update app.py
Browse files
app.py
CHANGED
@@ -4,11 +4,7 @@ from huggingface_hub import InferenceClient
|
|
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 |
-
|
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/Hermes-3-Llama-3.1-70B-8bit")
|
12 |
|
13 |
|
14 |
def respond(
|
@@ -29,18 +25,18 @@ def respond(
|
|
29 |
|
30 |
messages.append({"role": "user", "content": message})
|
31 |
|
32 |
-
|
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 |
-
|
|
|
|
|
|
|
44 |
|
45 |
|
46 |
"""
|
@@ -64,4 +60,4 @@ demo = gr.ChatInterface(
|
|
64 |
|
65 |
|
66 |
if __name__ == "__main__":
|
67 |
-
demo.launch()
|
|
|
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("mlx-community/Hermes-3-Llama-3.1-70B-8bit") # Garantir que o modelo seja compatível com `text-generation`
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
def respond(
|
|
|
25 |
|
26 |
messages.append({"role": "user", "content": message})
|
27 |
|
28 |
+
# Alterar a requisição para utilizar um modelo de `text-generation`
|
29 |
+
response = client.text_generation(
|
30 |
+
inputs=messages[-1]['content'],
|
|
|
|
|
31 |
max_tokens=max_tokens,
|
32 |
temperature=temperature,
|
33 |
+
top_p=top_p
|
34 |
)
|
|
|
35 |
|
36 |
+
# Assumindo que o modelo de texto retorna a resposta como uma string diretamente
|
37 |
+
response_text = response['generated_text'] # Adapte de acordo com a estrutura da resposta
|
38 |
+
|
39 |
+
return response_text
|
40 |
|
41 |
|
42 |
"""
|
|
|
60 |
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
+
demo.launch()
|