File size: 2,256 Bytes
6a5bb7c
8876b50
6a5bb7c
8876b50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a5bb7c
8876b50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a5bb7c
8876b50
 
6a5bb7c
8876b50
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import gradio as gr
import requests

# Function to send a request to Inflection AI API
def idea_mirror(input_idea, context=""):
    try:
        # API endpoint for Inflection AI (replace with the actual endpoint)
        api_url = "https://layercake.pubwestus3.inf7ks8.com/external/api/inference"
        
        # Construct the payload
        payload = {
            "context": [
                {"text": input_idea, "type": "Human"},
                {"text": context, "type": "Human"} if context else {}
            ],
            "config": "inflection_3_pi"
        }
        
        # Headers with API Key
        headers = {
            "Authorization": "Bearer VRks3d8elJWfQ34pVqdkjydFL6S93taWsPCxFIgUWFc",
            "Content-Type": "application/json"
        }
        
        # Send the request
        response = requests.post(api_url, json=payload, headers=headers)
        
        # Handle the response
        if response.status_code == 200:
            response_data = response.json()
            result = response_data.get("result", "No se pudo obtener un resultado.")
            return f"Idea Refinada: {result}"
        else:
            return f"Error: {response.status_code}, {response.text}"
    except Exception as e:
        return f"Error procesando la idea: {e}"

# Gradio Interface
with gr.Blocks() as interfaz:
    gr.Markdown(
        """
        ## **Idea Mirror**
        ### Refinamos tus ideas con claridad y empatía.
        """
    )
    
    with gr.Row():
        idea_input = gr.Textbox(
            label="Ingresa tu idea", 
            placeholder="Escribe aquí tu idea principal...",
            lines=3
        )
        context_input = gr.Textbox(
            label="Contexto (opcional)", 
            placeholder="Añade más detalles sobre tu idea o audiencia...",
            lines=2
        )
    
    output_box = gr.Textbox(
        label="Resultado", 
        placeholder="Aquí aparecerá tu idea refinada...",
        lines=6, 
        interactive=False
    )
    
    refine_button = gr.Button("Refinar Idea")

    # Link the refinement function to the button
    refine_button.click(idea_mirror, inputs=[idea_input, context_input], outputs=output_box)

# Launch the Gradio app
interfaz.launch()