import gradio as gr
from huggingface_hub import InferenceClient

--- CONFIGURACIÓN DEL CEREBRO GRATIS (Mistral 7B) ---

No necesitas clave, Hugging Face lo pone gratis.

client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")

--- PERSONALIDAD V. KING ---

SYSTEM_PROMPT = """
Eres V. KING, una Inteligencia Artificial experta en negocios digitales, viralidad y estrategias de alto valor (High Ticket).
Tu tono es profesional, directo, sofisticado y autoritario.
Siempre respondes en Español.
Ayudas a crear guiones, ideas de contenido y estrategias de venta.
"""

def vking_responde(mensaje, historial):
# Preparamos la instrucción para que la IA entienda
prompt_completo = f"[INST] {SYSTEM_PROMPT} \n\n Usuario: {mensaje} [/INST]"

try:
    respuesta = client.text_generation(
        prompt_completo,
        max_new_tokens=512,  # Largo de la respuesta
        temperature=0.7      # Creatividad
    )
    return respuesta
except Exception as e:
    return f"Error en el sistema V. KING: {str(e)}"

--- INTERFAZ GRÁFICA (DISEÑO) ---

Esto crea el chat automáticamente sin HTML complicado

interfaz = gr.ChatInterface(
fn=vking_responde,
title="👑 IA CENTRO ESTUDIO V. KING",
description="Estratega de Contenido Viral & Negocios. Pregunta lo que quieras.",
theme="soft", # Tema suave y moderno
examples=[
"Dame una idea viral para TikTok sobre IA",
"Escribe un guión de ventas para un curso de $500",
"¿Cómo crecer en Instagram en 2026?"
],
submit_btn="Consultar a V. King",
retry_btn="🔄 Intentar de nuevo",
undo_btn="↩️ Deshacer",
clear_btn="🗑️ Limpiar",
)

--- LANZAMIENTO ---

if name == "main":
interfaz.launch()

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment