Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,19 @@
|
|
1 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
2 |
-
import torch
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
-
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
def generate_text(prompt):
|
16 |
-
output = pipe(prompt, max_new_tokens=200, do_sample=True, temperature=0.7)
|
17 |
-
return output[0]["generated_text"]
|
18 |
-
|
19 |
-
demo = gr.Interface(
|
20 |
-
fn=generate_text,
|
21 |
-
inputs=gr.Textbox(lines=4, placeholder="Escribe algo..."),
|
22 |
-
outputs="text",
|
23 |
-
title="Generador de texto - Zephyr 1.3B (CPU compatible)"
|
24 |
-
)
|
25 |
-
|
26 |
-
demo.launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
|
4 |
+
API_URL = "https://api-inference.huggingface.co/models/TheBloke/MythoMax-L2-13B-GGUF"
|
5 |
+
headers = {"Authorization": "Bearer TU_TOKEN_DE_HUGGINGFACE"}
|
6 |
|
7 |
+
def responder(prompt):
|
8 |
+
payload = {
|
9 |
+
"inputs": prompt,
|
10 |
+
"parameters": {"max_new_tokens": 200}
|
11 |
+
}
|
12 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
13 |
+
try:
|
14 |
+
return response.json()[0]["generated_text"]
|
15 |
+
except:
|
16 |
+
return "Error en la respuesta del modelo."
|
17 |
|
18 |
+
iface = gr.Interface(fn=responder, inputs="text", outputs="text", title="MythoMax Chatbot")
|
19 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|