Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
# Pega o token do Hugging Face dos Secrets
|
| 6 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
@@ -16,14 +16,10 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 16 |
# Prompt principal incluindo system_message
|
| 17 |
full_prompt = f"{system_message}\nUsuário: {message}"
|
| 18 |
|
| 19 |
-
# --- Passo 1: Llama 3.1 ---
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
temperature=temperature,
|
| 24 |
-
top_p=top_p
|
| 25 |
-
)
|
| 26 |
-
response_main = result_main.generated_text
|
| 27 |
|
| 28 |
# --- Passo 2: FLAN-T5 ---
|
| 29 |
result_aux1 = client_aux1.text_generation(
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from huggingface_hub import InferenceClient, Conversation
|
| 4 |
|
| 5 |
# Pega o token do Hugging Face dos Secrets
|
| 6 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
|
|
| 16 |
# Prompt principal incluindo system_message
|
| 17 |
full_prompt = f"{system_message}\nUsuário: {message}"
|
| 18 |
|
| 19 |
+
# --- Passo 1: Llama 3.1 (conversational) ---
|
| 20 |
+
conversation = Conversation(full_prompt)
|
| 21 |
+
result_main = client_main.conversational(conversation)
|
| 22 |
+
response_main = result_main.generated_responses[-1] # pega a última resposta
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# --- Passo 2: FLAN-T5 ---
|
| 25 |
result_aux1 = client_aux1.text_generation(
|