diff --git a/.github/Agent solathan file b/.github/Agent solathan file new file mode 100644 index 00000000..b73e65ea --- /dev/null +++ b/.github/Agent solathan file @@ -0,0 +1,126 @@ +from agents import Agent, Runner +import asyncio + +spanish_agent = Agent( + name="Spanish agent", + instructions="You only speak Spanish.", +) + +english_agent = Agent( + name="English agent", + instructions="You only speak English", +) + +triage_agent = Agent( + name="Triage agent", + instructions="Handoff to the appropriate agent based on the language of the request.", + handoffs=[spanish_agent, english_agent], +) + + +async def main(): + result = await Runner.run(triage_agent, input="Hola, ¿cómo estás?") + print(result.final_output) + # ¡Hola! Estoy bien, gracias por preguntar. ¿Y tú, cómo estás? + + +if __name__ == "__main__": + asyncio.run(main())import asyncio + +from agents import Agent, Runner, function_tool + + +@function_tool +def get_weather(city: str) -> str: + return f"The weather in {city} is sunny." + + +agent = Agent( + name="Hello world", + instructions="You are a helpful agent.", + tools=[get_weather], +) + + +async def main(): + result = await Runner.run(agent, input="What's the weather in Tokyo?") + print(result.final_output) + # The weather in Tokyo is sunny. + +import asyncio + +from agents import Agent, Runner, function_tool + + +@function_tool +def get_weather(city: str) -> str: + return f"The weather in {city} is sunny." + + +agent = Agent( + name="Hello world", + instructions="You are a helpful agent.", + tools=[get_weather], +) + + +async def main(): + result = await Runner.run(agent, input="What's the weather in Tokyo?") + print(result.final_output) + # The weather in Tokyo is sunny. +s +if __name__ == "__main__": + asyncio.run(main(asyncio.run)make sync from agents import Agent, Runner +import asyncio + +spanish_agent = Agent( + name="Spanish agent", + instructions="You only speak Spanish.", +) + +english_agent = Agent( + name="English agent", + instructions="You only speak English", +) + +triage_agent = Agent( + name="Triage agent", + instructions="Handoff to the appropriate agent based on the language of the request.", + handoffs=[spanish_agent, english_agent], +) + + +async def main(): + result = await Runner.run(triage_agent, input="Hola, ¿cómo estás?") + print(result.final_output) + # ¡Hola! Estoy bien, gracias por preguntar. ¿Y tú, cómo estás? + + +if __name__ == "__main__": + asyncio.run(main())import asyncio + +from agents import Agent, Runner, function_tool + + +@function_tool +def get_weather(city: str) -> str: + return f"The weather in {city} is sunny." + + +agent = Agent( + name="Hello world", + instructions="You are a helpful agent.", + tools=[get_weather], +) + + +async def main(): + result = await Runner.run(agent, input="What's the weather in Tokyo?") + print(result.final_output) + # The weather in Tokyo is sunny. + + +if __name__ == "__main__": + asyncio.run(main())make tests # run tests +make mypy # run typechecker +make lint # run lintermake syncuv --versionRunner.run diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 00000000..e56abb63 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/README.md b/README.md index bbd4a5a0..aedf56c2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# OpenAI Agents SDK +# OpenAI Agents SDK The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. @@ -178,3 +178,61 @@ We'd like to acknowledge the excellent work of the open-source community, especi - [uv](https://github.com/astral-sh/uv) and [ruff](https://github.com/astral-sh/ruff) We're committed to continuing to build the Agents SDK as an open source framework so others in the community can expand on our approach. +make tests # run tests +make mypy # run typechecker +make lint # run linterfrom agents import Agent, Runner +import asyncio + +spanish_agent = Agent( + name="Spanish agent", + instructions="You only speak Spanish.", +) + +english_agent = Agent( + name="English agent", + instructions="You only speak English", +) + +triage_agent = Agent( + name="Triage agent", + instructions="Handoff to the appropriate agent based on the language of the request.", + handoffs=[spanish_agent, english_agent], +) + + +async def main(): + result = await Runner.run(triage_agent, input="Hola, ¿cómo estás?") + print(result.final_output) + # ¡Hola! Estoy bien, gracias por preguntar. ¿Y tú, cómo estás? + + +if __name__ == "__main__": + asyncio.run(main())import asyncio + +from agents import Agent, Runner, function_tool + + +@function_tool +def get_weather(city: str) -> str: + return f"The weather in {city} is sunny." + + +agent = Agent( + name="Hello world", + instructions="You are a helpful agent.", + tools=[get_weather], +) + + +async def main(): + result = await Runner.run(agent, input="What's the weather in Tokyo?") + print(result.final_output) + # The weather in Tokyo is sunny. + + +if __name__ == "__main__": + asyncio.run(main())Runner.runmake tests # run tests +make mypy # run typechecker +make lint # run lintermake syncmake tests # run tests +make mypy # run typechecker +make lint # run linter