Skip to content
Draft
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
4 changes: 4 additions & 0 deletions python-story-agents/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Azure AI Foundry connection info
AZURE_AI_PROJECT_ENDPOINT=https://<your-project>.services.ai.azure.com/api/projects/<your-project>
AZURE_AI_API_KEY=<your-api-key>
AZURE_AI_MODEL_DEPLOYMENT_NAME=<your-model-deployment-name>
35 changes: 35 additions & 0 deletions python-story-agents/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# python-story-agents

A simple multi-agent app using the [Microsoft Agent Framework SDK](https://github.com/microsoft/agent-framework).

- **Writer Agent**: Writes a short story based on user input.
- **Reviewer Agent**: Reviews the story and outputs a score from 0 to 100.

Both agents use an Azure AI Foundry model.

## Setup

1. Install dependencies:
```bash
pip install -r requirements.txt
```

2. Copy `.env.example` to `.env` and fill in your Azure AI Foundry connection info:
```bash
cp .env.example .env
```

3. Edit `.env` with your actual values:
- `AZURE_AI_PROJECT_ENDPOINT` – Your Azure AI project endpoint
- `AZURE_AI_API_KEY` – Your Azure AI API key
- `AZURE_AI_MODEL_DEPLOYMENT_NAME` – Your model deployment name

## Run

```bash
python main.py
```

Enter a topic or prompt when asked, and the app will:
1. Have the **Writer Agent** write a short story
2. Have the **Reviewer Agent** score it (0–100) with brief feedback
53 changes: 53 additions & 0 deletions python-story-agents/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import asyncio
import os

from agent_framework import Agent
from agent_framework.azure import AzureAIChatClient


AZURE_AI_PROJECT_ENDPOINT = os.getenv("AZURE_AI_PROJECT_ENDPOINT", "<your-azure-ai-project-endpoint>")
AZURE_AI_API_KEY = os.getenv("AZURE_AI_API_KEY", "<your-azure-ai-api-key>")
AZURE_AI_MODEL_DEPLOYMENT_NAME = os.getenv("AZURE_AI_MODEL_DEPLOYMENT_NAME", "<your-model-deployment-name>")


async def main():
user_input = input("Enter a topic or prompt for the short story: ").strip()
if not user_input:
user_input = "a brave knight and a mysterious dragon"

client = AzureAIChatClient(
endpoint=AZURE_AI_PROJECT_ENDPOINT,
api_key=AZURE_AI_API_KEY,
deployment_name=AZURE_AI_MODEL_DEPLOYMENT_NAME,
)

writer = Agent(
client=client,
name="Writer",
instructions=(
"You are a creative short story writer. "
"Write an engaging short story (around 150-200 words) based on the user's input."
),
)

reviewer = Agent(
client=client,
name="Reviewer",
instructions=(
"You are a literary critic. Review the provided short story and output a score from 0 to 100 "
"based on creativity, coherence, and engagement. "
"Respond with: Score: <number>\nFeedback: <brief feedback>"
),
)

print("\n--- Writer Agent ---")
story = await writer.run(user_input)
print(story)

print("\n--- Reviewer Agent ---")
review = await reviewer.run(f"Please review this story:\n\n{story}")
print(review)


if __name__ == "__main__":
asyncio.run(main())
1 change: 1 addition & 0 deletions python-story-agents/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
agent-framework-azure-ai --pre