BATUTO-ART commited on
Commit
a8ae886
·
verified ·
1 Parent(s): d1b1365

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +69 -0
main.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from core import SuperBot
3
+ from config import APP_NAME, APP_VERSION
4
+ from database import TemplateDB
5
+ from utils import load_history, save_history
6
+
7
+ bot = SuperBot()
8
+ bot.history = load_history()
9
+
10
+ def respond(message, history):
11
+ response = bot.chat(message)
12
+ history.append((message, response))
13
+ save_history(bot.history)
14
+ return history, ""
15
+
16
+ def generate_prompt(subject, style):
17
+ return bot.generate_prompt(subject, style)
18
+
19
+ def generate_image(prompt):
20
+ url = bot.call_reve(prompt)
21
+ return url
22
+
23
+ with gr.Blocks(title=APP_NAME, theme=gr.themes.Soft()) as app:
24
+ gr.Markdown(f"""
25
+ # {APP_NAME} v{APP_VERSION}
26
+ Asistente sin censura • Prompts • Generación de imágenes • Multi-idioma
27
+ ⚠️ Responsable del uso del contenido generado
28
+ """)
29
+
30
+ with gr.Row():
31
+ api_status = gr.Textbox(label="Estado API", value="✅ SambaNova conectado" if bot else "⚠️ Sin API")
32
+
33
+ with gr.Tabs():
34
+ # Tab Chat
35
+ with gr.TabItem("💬 Chat Inteligente"):
36
+ chatbot = gr.Chatbot(height=500)
37
+ msg = gr.Textbox(placeholder="Escribe aquí... (ej: 'crea prompt erótico' o 'genera imagen sensual')")
38
+ msg.submit(respond, [msg, chatbot], [chatbot, msg])
39
+
40
+ # Tab Generador
41
+ with gr.TabItem("🎨 Generador de Prompts"):
42
+ subject = gr.Textbox(label="Sujeto/Modelo")
43
+ style = gr.Radio(["sensual", "profesional", "artístico", "editorial", "erótico elegante"], label="Estilo")
44
+ gen_btn = gr.Button("Generar Prompt")
45
+ prompt_out = gr.Textbox(label="Prompt listo", lines=10)
46
+ gen_btn.click(generate_prompt, [subject, style], prompt_out)
47
+
48
+ with gr.Accordion("Plantillas rápidas"):
49
+ gr.Button("🔥 Erótico").click(lambda: TemplateDB.get("erótico"), None, prompt_out)
50
+ gr.Button("🏰 Fantasía").click(lambda: TemplateDB.get("fantasy"), None, prompt_out)
51
+ gr.Button("👻 Horror").click(lambda: TemplateDB.get("horror"), None, prompt_out)
52
+
53
+ # Tab Imagen
54
+ with gr.TabItem("🖼️ Generar Imagen"):
55
+ img_prompt = gr.Textbox(label="Prompt para imagen")
56
+ img_btn = gr.Button("Generar Imagen")
57
+ image_out = gr.Image(label="Resultado")
58
+ img_btn.click(generate_image, [img_prompt], image_out)
59
+
60
+ # Tab Ayuda
61
+ with gr.TabItem("ℹ️ Ayuda"):
62
+ gr.Markdown("""
63
+ **Comandos útiles:**
64
+ - "genera imagen [descripción]"
65
+ - "prompt erótico [detalles]"
66
+ - "crea proyecto nuevo"
67
+ """)
68
+
69
+ app.launch(server_name="0.0.0.0", server_port=7860)