{"id":29401054,"url":"https://github.com/yepcode/autogen-ext-yepcode","last_synced_at":"2025-08-22T12:13:39.994Z","repository":{"id":303455290,"uuid":"1015362430","full_name":"yepcode/autogen-ext-yepcode","owner":"yepcode","description":"An AutoGen extension that enables secure code execution using YepCode's serverless runtime environment. Execute any Python and JavaScript code in isolated sandboxes.","archived":false,"fork":false,"pushed_at":"2025-07-07T17:49:06.000Z","size":505,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T18:52:01.199Z","etag":null,"topics":["autogen","autogen-extension","autogen-sample"],"latest_commit_sha":null,"homepage":"https://yepcode.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yepcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-07T11:43:38.000Z","updated_at":"2025-07-07T18:24:05.000Z","dependencies_parsed_at":"2025-07-07T18:52:10.190Z","dependency_job_id":"939c658e-6c1f-4542-a356-ce45614fb0b8","html_url":"https://github.com/yepcode/autogen-ext-yepcode","commit_stats":null,"previous_names":["yepcode/autogen-ext-yepcode"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/yepcode/autogen-ext-yepcode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yepcode%2Fautogen-ext-yepcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yepcode%2Fautogen-ext-yepcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yepcode%2Fautogen-ext-yepcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yepcode%2Fautogen-ext-yepcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yepcode","download_url":"https://codeload.github.com/yepcode/autogen-ext-yepcode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yepcode%2Fautogen-ext-yepcode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271636032,"owners_count":24794144,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["autogen","autogen-extension","autogen-sample"],"created_at":"2025-07-10T15:42:18.397Z","updated_at":"2025-08-22T12:13:39.930Z","avatar_url":"https://github.com/yepcode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![YepCode Run SDK Preview](/readme-assets/cover.png)\n\n\u003cdiv align=\"center\"\u003e\n\n[![PyPI Version](https://img.shields.io/pypi/v/autogen-ext-yepcode)](https://pypi.org/project/autogen-ext-yepcode/)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/autogen-ext-yepcode)](https://pypi.org/project/autogen-ext-yepcode/)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/yepcode/autogen-ext-yepcode-py/ci.yml)](https://github.com/yepcode/autogen-ext-yepcode-py/actions)\n\n\u003c/div\u003e\n\n# AutoGen Extension for YepCode\n\nAn [AutoGen](https://github.com/microsoft/autogen) extension that enables secure code execution using [YepCode's](https://yepcode.io/) serverless runtime environment. Execute Python and JavaScript code in production-grade, isolated sandboxes with built-in security and scalability.\n\n\u003e **Note**: If you are looking for the extension for AG2, which was evolved from AutoGen, please check the [autogen-ext-yepcode](https://github.com/yepcode/ag2-ext-yepcode) repository.\n\n## Features\n\n- **Secure Execution**: Code runs in isolated, production-grade sandboxes\n- **Multi-language Support**: Python and JavaScript execution\n- **Automatic Package Installation**: YepCode automatically detects and installs dependencies in the sandbox\n- **Logging and Monitoring**: Access to YepCode's execution logs, results and errors\n- **AutoGen Integration**: Seamless integration with AutoGen agents and tools\n\n## Installation\n\nInstall the package using pip:\n\n```bash\npip install autogen_ext_yepcode\n```\n\n## Setup\n\n1. **Create a YepCode Account**: Sign up at [yepcode.io](https://yepcode.io/)\n2. **Get Your API Token**: Navigate to `Settings` \u003e `API credentials` in your YepCode workspace\n3. **Set Environment Variable**:\n\n   ```bash\n   export YEPCODE_API_TOKEN=\"your-api-token-here\"\n   ```\n\nAlternatively, you can pass the API token directly to the executor constructor.\n\n## Quick Start\n\n### Basic Integration with AutoGen\n\nThe YepCode executor is designed to work with AutoGen agents through the `PythonCodeExecutionTool`. Here's a complete example:\n\n```python\nimport asyncio\nimport os\nfrom autogen_agentchat.agents import AssistantAgent\nfrom autogen_ext.models.openai import OpenAIChatCompletionClient\nfrom autogen_ext.tools.code_execution import PythonCodeExecutionTool\nfrom autogen_ext_yepcode import YepCodeCodeExecutor\n\nasync def main():\n    # Create OpenAI model client\n    model_client = OpenAIChatCompletionClient(\n        model=\"gpt-4\",\n        api_key=os.getenv(\"OPENAI_API_KEY\"),\n    )\n\n    # Initialize YepCode executor\n    yepcode_executor = YepCodeCodeExecutor(\n        timeout=120,\n        remove_on_done=False,\n        sync_execution=True,\n    )\n\n    # Start the executor\n    await yepcode_executor.start()\n\n    # Create a PythonCodeExecutionTool with the YepCode executor\n    code_tool = PythonCodeExecutionTool(executor=yepcode_executor)\n\n    # Create an AssistantAgent with the code execution tool\n    assistant = AssistantAgent(\n        name=\"assistant\",\n        model_client=model_client,\n        tools=[code_tool],\n    )\n\n    # Run a task that requires code execution\n    task = \"Calculate the sum of squares for numbers 1 to 10. Show the calculation step by step using Python code.\"\n\n    result = await assistant.run(task=task)\n    print(f\"Result: {result}\")\n\n    # Clean up\n    await yepcode_executor.stop()\n    await model_client.close()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### With Anthropic Claude\n\nThe extension also works with other model providers like Anthropic:\n\n```python\nimport asyncio\nimport os\nfrom autogen_agentchat.agents import AssistantAgent\nfrom autogen_ext.models.anthropic import AnthropicChatCompletionClient\nfrom autogen_ext.tools.code_execution import PythonCodeExecutionTool\nfrom autogen_ext_yepcode import YepCodeCodeExecutor\n\nasync def main():\n    # Create Anthropic model client\n    model_client = AnthropicChatCompletionClient(\n        model=\"claude-3-haiku-20240307\",\n        api_key=os.getenv(\"ANTHROPIC_API_KEY\"),\n    )\n\n    # Initialize YepCode executor\n    yepcode_executor = YepCodeCodeExecutor(\n        timeout=120,\n        remove_on_done=False,\n        sync_execution=True,\n    )\n\n    # Start the executor\n    await yepcode_executor.start()\n\n    # Create a PythonCodeExecutionTool with the YepCode executor\n    code_tool = PythonCodeExecutionTool(executor=yepcode_executor)\n\n    # Create an AssistantAgent\n    assistant = AssistantAgent(\n        name=\"assistant\",\n        model_client=model_client,\n        tools=[code_tool],\n    )\n\n    # Run a task\n    task = \"Fetch cryptocurrency price data from a public API and analyze the top 5 cryptocurrencies by market cap. Use the requests library to get data and calculate some basic statistics.\"\n\n    result = await assistant.run(task=task)\n    print(f\"Result: {result}\")\n\n    # Clean up\n    await yepcode_executor.stop()\n    await model_client.close()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Custom Configuration\n\nYou can customize the YepCode executor behavior:\n\n```python\n# Custom executor configuration\nyepcode_executor = YepCodeCodeExecutor(\n    api_token=\"your-api-token\",  # Optional: pass token directly\n    timeout=300,  # 5 minutes timeout\n    remove_on_done=False,  # Keep execution records for debugging\n    sync_execution=True,  # Wait for completion\n)\n```\n\n## Usage Patterns\n\n### Standard AutoGen Pattern\n\nThe recommended approach is to use the `YepCodeCodeExecutor` with AutoGen's `PythonCodeExecutionTool`:\n\n```python\n# 1. Create the YepCode executor\nyepcode_executor = YepCodeCodeExecutor()\nawait yepcode_executor.start()\n\n# 2. Wrap it in a PythonCodeExecutionTool\ncode_tool = PythonCodeExecutionTool(executor=yepcode_executor)\n\n# 3. Add to your AssistantAgent\nassistant = AssistantAgent(\n    name=\"assistant\",\n    model_client=your_model_client,\n    tools=[code_tool],\n)\n\n# 4. Use normally with AutoGen\nresult = await assistant.run(\"Your task here\")\n```\n\n### Context Manager Pattern\n\nYou can also use the executor as a context manager:\n\n```python\nasync def main():\n    async with YepCodeCodeExecutor() as executor:\n        code_tool = PythonCodeExecutionTool(executor=executor)\n        # Use the tool with your agents\n        assistant = AssistantAgent(\n            name=\"assistant\",\n            model_client=model_client,\n            tools=[code_tool],\n        )\n        result = await assistant.run(\"Your task\")\n```\n\n## API Reference\n\n### YepCodeCodeExecutor\n\nThe main executor class for running code in YepCode's serverless environment.\n\n#### Constructor Parameters\n\n- `api_token` (Optional[str]): YepCode API token. If not provided, will use `YEPCODE_API_TOKEN` environment variable.\n- `timeout` (int): Execution timeout in seconds. Default: 60.\n- `remove_on_done` (bool): Whether to remove execution records after completion. Default: True.\n- `sync_execution` (bool): Whether to wait for execution completion. Default: True.\n\n#### Methods\n\n- `async start()`: Initialize the executor\n- `async stop()`: Clean up the executor\n- `async execute_code_blocks(code_blocks, cancellation_token)`: Execute code blocks\n- `async restart()`: Restart the executor\n\n### YepCodeCodeResult\n\nResult object returned from code execution.\n\n#### Properties\n\n- `exit_code` (int): Execution exit code (0 for success)\n- `output` (str): Execution output and logs\n- `execution_id` (Optional[str]): YepCode execution ID for tracking\n\n## Supported Languages\n\n| Language   | Language Code | Aliases |\n|------------|---------------|---------|\n| Python     | `python`      | `py`    |\n| JavaScript | `javascript`  | `js`    |\n\n## Examples\n\nCheck out the [samples](samples/) directory for comprehensive examples:\n\n- **[AutoGen Integration Sample](samples/autogen_yepcode_code_executor_sample.py)**: Complete example showing integration with AutoGen agents\n\n## Development\n\n### Setup Development Environment\n\n```bash\ngit clone https://github.com/yepcode/autogen_ext_yepcode.git\ncd autogen_ext_yepcode\npoetry install\n```\n\n### Run Tests\n\n```bash\npytest tests/ -v\n```\n\n## 📚 Documentation\n\n- **[YepCode Documentation](https://yepcode.io/docs)**: Complete YepCode platform documentation\n- **[AutoGen Documentation](https://microsoft.github.io/autogen/)**: AutoGen framework documentation\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyepcode%2Fautogen-ext-yepcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyepcode%2Fautogen-ext-yepcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyepcode%2Fautogen-ext-yepcode/lists"}