Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Carga un modelo ligero que no sea muy robusto
|
5 |
+
model = pipeline("text-generation", model="EleutherAI/gpt-neo-125M")
|
6 |
+
|
7 |
+
# Define una funci贸n para procesar las solicitudes
|
8 |
+
def process_prompt(prompt):
|
9 |
+
response = model(prompt, max_length=50, num_return_sequences=1, do_sample=True)
|
10 |
+
return response[0]["generated_text"]
|
11 |
+
|
12 |
+
# Configura la interfaz de API con Gradio
|
13 |
+
interface = gr.Interface(
|
14 |
+
fn=process_prompt,
|
15 |
+
inputs="text",
|
16 |
+
outputs="text",
|
17 |
+
title="Hugging Face Space API",
|
18 |
+
description="Modelo ligero basado en GPT-Neo para probar vulnerabilidades con RedTeamer."
|
19 |
+
)
|
20 |
+
|
21 |
+
# Ejecuta la app
|
22 |
+
if __name__ == "__main__":
|
23 |
+
interface.launch(share=True)
|