{"id":25059640,"url":"https://github.com/glav/autoplay","last_synced_at":"2025-03-31T10:35:13.427Z","repository":{"id":261175210,"uuid":"883473955","full_name":"glav/autoplay","owner":"glav","description":"An experiment to get familiar with Autogen - playpen only","archived":false,"fork":false,"pushed_at":"2025-02-05T00:10:10.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T12:18:18.943Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glav.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-05T02:54:35.000Z","updated_at":"2025-02-02T22:24:09.000Z","dependencies_parsed_at":"2025-01-22T07:30:47.833Z","dependency_job_id":"059088a0-2bd5-462c-8633-801399990904","html_url":"https://github.com/glav/autoplay","commit_stats":null,"previous_names":["glav/autoplay"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glav%2Fautoplay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glav%2Fautoplay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glav%2Fautoplay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glav%2Fautoplay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glav","download_url":"https://codeload.github.com/glav/autoplay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246454575,"owners_count":20780170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-06T15:35:51.569Z","updated_at":"2025-03-31T10:35:13.408Z","avatar_url":"https://github.com/glav.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n### Files\n\n- **basic/basic.py**: Contains an asynchronous function to get weather information and an agent setup to query weather using Azure OpenAI.\n- **simple_agent/*.py**: Code to execute a simple agent co-ordinating using a simple runtime.\n- **debug/example.py**: Directly from Autogen site to see a working example\n- **file_reader_agent/*.py**: A slightly more complex custom thing with a router agent that selects between local disk operations and a github repository. Execute the `app.py` file to kick it all off. Github requires the following environment vars set:\n  - `GITHUB_REPONAME=\"{repo_name}\"`  \u003c-- For example 'Glav.HelperScripts'\n  - `GITHUB_TOKEN=\"{your_github_PAT}\"`\n- **file_reader_agent_using_SelectorGroupChat/*.py**: Same functionality as `- **file_reader_agent/*.py**: ` above but implemented using high level API `SelectorGroupChat`\n- **agent_using_AIFoundry/*.py**: Implement agents hosted in Azure AI Foundry Agents service/SDK but co-ordinated by Autogen `SelectorGroupChat`\n- **list-openai-models.py**: Lists available OpenAI models using the OpenAI API.\n- **requirements.txt**: Lists the Python dependencies required for the project.\n\n#### Environment Variables\n- Look at the `.env-sample` file to see what environment variables are required.\n- Copy the `.env-sample` into a `.env` file and populate the variables with valid values.\n- The code samples will load the environment vars from this file and use those.\n\n## Setup\n\n1. **Clone the repository**:\n    ```sh\n    git clone \u003crepository-url\u003e\n    cd \u003crepository-directory\u003e\n    ```\n\n2. **Set up the development container**:\n    - Ensure you have Docker installed.\n    - Open the repository in Visual Studio Code.\n    - Use the `Remote - Containers` extension to open the folder in a container.\n\n3. **Install dependencies**:\n    ```sh\n    pip install -r requirements.txt\n    ```\n\n4. **Set up environment variables**:\n    - You need to have some environment variables set for this to work.\n    - If using Open AI then\n    ```sh\n    export OPENAI_API_KEY=\"\u003cyour-open-ai-key\u003e\"\n    ```\n    - If using Azure Open AI then\n    ```sh\n    export AZURE_OPENAI_API_KEY=\"\u003cyour-azure-open-ai-key\u003e\"\n    export AZURE_OPENAI_ENDPOINT=\"https://{azure-openai-name}.openai.azure.com\"\n    export OPENAI_API_VERSION=\"2024-02-15-preview\"\n    ```\n\n## Usage\n\n### Get Weather Information\n\nRun the `basic.py` script to invoke the agent to get weather information:\n\n```sh\npython basic/basic.py\n```\n\n### Simple Agent\nRun the `runtime.py` script to invoke the agent to get things to do in Sydney.\nUses runtime and agent concepts.\n\n```sh\npython simple_agent/runtime.py\n```\n\n### File Reader Agent\nRun the `app.py` script to invoke the agent to answer questions about files on disk or files in a Github repo.\nUses runtime, agent concepts, topics for agent messaging, proper logging.\n\n```sh\ncd file_reader_agent\npython app.py\n```\nThen ask a question like, \"*What is the first file on disk that begins with the letter 'b'?*\"\nNote: You can easily switch between using a single or distributed runtimes using the following code in `app.py` by commenting and uncommenting the relevant line.\n```python\n#runtime = SingleRuntimeFacade()\nruntime = DistributedRuntimeFacade()\n```\nNote: When running the application (via `python app.py`), you can then run the `observer_agent.py` in a separate process which simply demonstrates that you can run another agent in a different process and communicate easily.\nThe `observer_agent.py` will simply listen for messages (sent via topics) and print them out.\n\n#### Telemetry note for File Reader agent\nAppInsights telemetry is enabled (albeit a WIP) if the '```APPLICATION_INSIGHTS_CONNECTION_STRING```' env var is set to a valid connection string.\n\nSet the env var  ```OTEL_EXPORTER_OTLP_ENDPOINT=http://host.docker.internal:4318```  # If running Aspire docker container locally\n\nTo run the the docker aspire dashboard, execute\n```\ndocker run --rm -it -p 18888:18888 -p 4318:18889 -d --name aspire-dashboard     mcr.microsoft.com/dotnet/aspire-dashboard:9.0\n```\nRun this outside of devcontainer, dashboard then is accessible on http://localhost:18888\n\nThis will require a token, you can get this by examining the logs of the container and looking for the 't' parameter on the Url\n\neg. ```docker logs {container-id}```\nWill see something like 'Login to the dashboard at ```http://localhost:18888/login?t=9583bf2935ee3d3538d54e676984e512``` where *9583bf2935ee3d3538d54e676984e512** is the access token\n\n\n### File Reader Agent Using SelectorGroupChat\nRun the `app.py` script to invoke the agent to answer questions about files on disk or files in a Github repo.\nUses higher level API `SelectorGroupChat` to register agents. This implementation is meant to contrast the implementation and functionality from the low level APIP shown in the `file_reader_agent` example mentioned above.\n\n*Note: In `file_reader_agent_using_SelectorGroupChat/agent_init.py` is where the agents are initialised and where agent interaction termination is setup:\n```python\ntext_mention_termination = TextMentionTermination(\"TERMINATE\")\nmax_messages_termination = MaxMessageTermination(max_messages=25)\ntermination = text_mention_termination | max_messages_termination\n```\nThe SelectorGroupChat can often go on a long time as agents converse with each other, sometimes on irrelevant conversations so it is important to craft the system prompt and agent descriptions appropriately. You may need to explicitly get an agent to issue a terminate action in certain scenarios to prevent long running conversations.\n\n#### Findings when using high level API SelectorGroupChat vs low level API RoutedAgent\n- More code required for low level API than high level API but more granular control. SelectorGroupChat much simpler though to get going.\n- No support for different runtimes in SelectorGroupChat. Does not provide option to change so assume it is using `SingleThreadedAgentRuntime`\n- Using Low level API allows a more deterministic approach, even if more code so can minimise LLM calls.\n- SelectorGroupChat requires careful system prompts and termination conditions as agents can carry on a conversation, even if the goal has been reached. Can use a lot of time and tokens.\n\n### AI Foundry AI Agents Service SDK\nThis is trying to use Azure AI Foundry AI Agents SDK to host the agents themselves. The orchestration is still carried out by Autogen though as no such mechanism exists in AI Foundry.\n\nRun the `app.py` script to invoke the agent to answer questions. The simple agent answers in a pirates voice.\n\nYou will need to have the `AZURE_AI_FOUNDRY_CONNECTION_STRING` environment variable set to an Azure AI Fopundry project connection string. Also, the assumption here is that `gpt-4o-mini` is deployed.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglav%2Fautoplay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglav%2Fautoplay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglav%2Fautoplay/lists"}