Spaces:
Runtime error

File size: 1,779 Bytes
b9c1407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e86b17
 
b9c1407
 
 
 
 
 
 
 
 
 
 
 
 
4e86b17
 
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
import gradio as gr
from huggingface_hub import InferenceClient

# 1. Initialize the free Hugging Face AI client
# We are using Mistral, a fast and highly capable free model
client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")

def aws_architect_agent(user_idea):
    # 2. Create the "Prompt" (This is where your PO product thinking shines!)
    prompt = f"""
    You are an expert AWS Solutions Architect. 
    A Product Manager has given you an app idea. 
    Recommend the top 3 core AWS services to build it, and explain why in 1-2 sentences each.
    
    App Idea: {user_idea}
    
    Format your response clearly with bullet points. Do not include any introductory text.
    """
    
    # 3. Send the prompt to the AI and get the answer
    response = client.chat.completions.create(
        messages=[{"role": "user", "content": prompt}],
        max_tokens=250,
    )
    return response.choices[0].message.content

# 4. Build the User Interface (NO theme here - moved to launch)
with gr.Blocks() as demo:
    gr.Markdown("# 🏗️ AWS Solutions Architect Agent")
    gr.Markdown("Type your app idea below, and the AI Agent will recommend the AWS architecture.")
    
    with gr.Row():
        with gr.Column():
            input_text = gr.Textbox(label="Your App Idea", placeholder="e.g., A video streaming app for 10,000 users...")
            submit_btn = gr.Button("Generate Architecture", variant="primary")
        with gr.Column():
            output_text = gr.Textbox(label="Recommended AWS Architecture", lines=10)
            
    # Connect the button to the AI function
    submit_btn.click(fn=aws_architect_agent, inputs=input_text, outputs=output_text)

# 5. Launch the app (THEME MOVED HERE for Gradio 6.0)
demo.launch(theme=gr.themes.Soft())