diff --git a/python-story-agents/.env.example b/python-story-agents/.env.example new file mode 100644 index 0000000..ca6dbc7 --- /dev/null +++ b/python-story-agents/.env.example @@ -0,0 +1,4 @@ +# Azure AI Foundry connection info +AZURE_AI_PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ +AZURE_AI_API_KEY= +AZURE_AI_MODEL_DEPLOYMENT_NAME= diff --git a/python-story-agents/README.md b/python-story-agents/README.md new file mode 100644 index 0000000..7be9bbf --- /dev/null +++ b/python-story-agents/README.md @@ -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 diff --git a/python-story-agents/main.py b/python-story-agents/main.py new file mode 100644 index 0000000..b283ff0 --- /dev/null +++ b/python-story-agents/main.py @@ -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", "") +AZURE_AI_API_KEY = os.getenv("AZURE_AI_API_KEY", "") +AZURE_AI_MODEL_DEPLOYMENT_NAME = os.getenv("AZURE_AI_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: \nFeedback: " + ), + ) + + 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()) diff --git a/python-story-agents/requirements.txt b/python-story-agents/requirements.txt new file mode 100644 index 0000000..61decf6 --- /dev/null +++ b/python-story-agents/requirements.txt @@ -0,0 +1 @@ +agent-framework-azure-ai --pre