Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions python/samples/agent_collaboration_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
\# Agent Collaboration Example



This sample demonstrates how multiple AI agents can collaborate using

Microsoft Semantic Kernel.



\## Agents

\- Planner: breaks a task into steps

\- Executor: executes the plan and produces output



\## How it Works

1\. User provides a task

2\. Planner agent creates a plan

3\. Executor agent produces the final response



\## Requirements

\- Python 3.9+

\- OpenAI API key set as an environment variable



\## Run

```bash

python main.py



31 changes: 31 additions & 0 deletions python/samples/agent_collaboration_example/mainCode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.agents import Agent

kernel = Kernel()

kernel.add_service(
OpenAIChatCompletion(
service_id="chat",
api_key=os.getenv("OPENAI_API_KEY"),
model="gpt-3.5-turbo"
)
)

planner = Agent(
name="Planner",
instructions="Break the task into steps."
)

executor = Agent(
name="Executor",
instructions="Execute the plan and produce a final answer."
)

task = "Explain how AI agents collaborate."

plan = planner.invoke(kernel, task)
result = executor.invoke(kernel, plan)

print(result)