Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
@@ -1,17 +1,13 @@
|
|
1 |
-
from transformers import
|
2 |
-
import torch
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
self.tokenizer = AutoTokenizer.from_pretrained(model_id, token=access_token)
|
7 |
-
self.model = AutoModelForCausalLM.from_pretrained(
|
8 |
-
model_id,
|
9 |
-
token=access_token,
|
10 |
-
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
11 |
-
device_map="auto"
|
12 |
-
)
|
13 |
-
self.pipeline = pipeline("text-generation", model=self.model, tokenizer=self.tokenizer)
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
|
|
2 |
|
3 |
+
# Usaremos un modelo ligero para mejor compatibilidad
|
4 |
+
modelo = "google/gemma-2b-it"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
generador = pipeline("text-generation", model=modelo)
|
7 |
+
|
8 |
+
def ejecutar_agente(texto):
|
9 |
+
"""
|
10 |
+
Procesa una pregunta usando el modelo LLM.
|
11 |
+
"""
|
12 |
+
resultado = generador(texto, max_new_tokens=300, do_sample=True, temperature=0.7)
|
13 |
+
return resultado[0]["generated_text"]
|