File size: 1,767 Bytes
ba24c51
8be7405
9bd14e9
ba24c51
9bd14e9
90c5875
1f8cd0c
ba24c51
 
 
 
 
539766c
3e7dabe
539766c
ba24c51
 
 
 
 
c18cd72
eb34c7e
 
 
 
ba24c51
 
539766c
 
 
 
 
ba24c51
 
d979f7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a40bbc
d979f7b
 
 
 
 
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
import google.generativeai as genai
import gradio as gr
import os
# 🔑 Configure your Gemini API key
api_key = os.getenv("YOUR_GEMINI_API_KEY")
genai.configure(api_key=api_key)
print("Using API key:", api_key)

# Choose Gemini model
model = genai.GenerativeModel("gemini-1.5-flash")

def build_agent(description):
    status_msg = "Generating agent plan... ⏳"
    output_md = ""
    yield gr.update(value=status_msg), gr.update(value=output_md)
    prompt = f"""
    You are Google Opal Agent Builder.
    The user wants to create an AI Agent.
    Agent description: "{description}"

    ✨ Please return in readable text format with headings:
    1. Agent Purpose
    2. Inputs (what the agent expects from the user)
    3. Step-by-step Workflow
    4. Example Interaction (dialogue between user and agent)
    """
    response = model.generate_content(prompt)
    status_msg = "✅ Done!"
    output_md = response.text.strip()
    
    # إرجاع النتيجة النهائية
    yield gr.update(value=status_msg), gr.update(value=output_md)

# Gradio UI
with gr.Blocks() as demo:
    gr.Markdown("## Google Opal Agent Builder (Gemini-powered)")

    with gr.Row():
        with gr.Column():
            gr.Markdown("### Describe Your Agent")
            description_input = gr.Textbox(
                lines=3, 
                placeholder="Enter your agent description here"
            )
            build_btn = gr.Button("Build Agent")

        with gr.Column():
            status_box = gr.Textbox(label="Status", interactive=False)
            output_box = gr.Markdown(label="Agent Plan")

        build_btn.click(
            build_agent, 
            inputs=description_input, 
            outputs=[status_box, output_box]
        )

demo.launch()