Spaces:
Runtime error

VTSSPACE / app.py
LMSindia's picture
Update app.py
4e86b17 verified
Raw History Blame Contribute Delete
1.78 kB
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())