From f0b93aec91fa9c021b80bcdbd4022033933ab70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mayoral=20Vilches?= Date: Fri, 28 Mar 2025 08:35:25 +0100 Subject: [PATCH] Fix paths in docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: VĂ­ctor Mayoral Vilches --- docs/agents.md | 6 +++--- docs/config.md | 12 ++++++------ docs/context.md | 2 +- docs/guardrails.md | 4 ++-- docs/handoffs.md | 10 +++++----- docs/index.md | 2 +- docs/models.md | 2 +- docs/quickstart.md | 10 +++++----- docs/running_agents.md | 2 +- docs/streaming.md | 4 ++-- docs/tools.md | 8 ++++---- docs/tracing.md | 2 +- docs/voice/quickstart.md | 4 ++-- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docs/agents.md b/docs/agents.md index a384c029..5d726561 100644 --- a/docs/agents.md +++ b/docs/agents.md @@ -11,7 +11,7 @@ The most common properties of an agent you'll configure are: - `tools`: Tools that the agent can use to achieve its tasks. ```python -from cai.agents import Agent, ModelSettings, function_tool +from cai.sdk.agents import Agent, ModelSettings, function_tool @function_tool def get_weather(city: str) -> str: @@ -49,7 +49,7 @@ By default, agents produce plain text (i.e. `str`) outputs. If you want the agen ```python from pydantic import BaseModel -from cai.agents import Agent +from cai.sdk.agents import Agent class CalendarEvent(BaseModel): @@ -73,7 +73,7 @@ agent = Agent( Handoffs are sub-agents that the agent can delegate to. You provide a list of handoffs, and the agent can choose to delegate to them if relevant. This is a powerful pattern that allows orchestrating modular, specialized agents that excel at a single task. Read more in the [handoffs](handoffs.md) documentation. ```python -from cai.agents import Agent +from cai.sdk.agents import Agent booking_agent = Agent(...) refund_agent = Agent(...) diff --git a/docs/config.md b/docs/config.md index f7204aa3..291358ad 100644 --- a/docs/config.md +++ b/docs/config.md @@ -5,7 +5,7 @@ By default, the SDK looks for the `OPENAI_API_KEY` environment variable for LLM requests and tracing, as soon as it is imported. If you are unable to set that environment variable before your app starts, you can use the [`set_default_openai_key()`][cai.sdk.agents.set_default_openai_key] function to set the key. ```python -from cai.agents import set_default_openai_key +from cai.sdk.agents import set_default_openai_key set_default_openai_key("sk-...") ``` @@ -14,7 +14,7 @@ Alternatively, you can also configure an OpenAI client to be used. By default, t ```python from openai import AsyncOpenAI -from cai.agents import set_default_openai_client +from cai.sdk.agents import set_default_openai_client custom_client = AsyncOpenAI(base_url="...", api_key="...") set_default_openai_client(custom_client) @@ -23,7 +23,7 @@ set_default_openai_client(custom_client) Finally, you can also customize the OpenAI API that is used. By default, we use the OpenAI Responses API. You can override this to use the Chat Completions API by using the [`set_default_openai_api()`][cai.sdk.agents.set_default_openai_api] function. ```python -from cai.agents import set_default_openai_api +from cai.sdk.agents import set_default_openai_api set_default_openai_api("chat_completions") ``` @@ -33,7 +33,7 @@ set_default_openai_api("chat_completions") Tracing is enabled by default. It uses the OpenAI API keys from the section above by default (i.e. the environment variable or the default key you set). You can specifically set the API key used for tracing by using the [`set_tracing_export_api_key`][cai.sdk.agents.set_tracing_export_api_key] function. ```python -from cai.agents import set_tracing_export_api_key +from cai.sdk.agents import set_tracing_export_api_key set_tracing_export_api_key("sk-...") ``` @@ -41,7 +41,7 @@ set_tracing_export_api_key("sk-...") You can also disable tracing entirely by using the [`set_tracing_disabled()`][cai.sdk.agents.set_tracing_disabled] function. ```python -from cai.agents import set_tracing_disabled +from cai.sdk.agents import set_tracing_disabled set_tracing_disabled(True) ``` @@ -53,7 +53,7 @@ The SDK has two Python loggers without any handlers set. By default, this means To enable verbose logging, use the [`enable_verbose_stdout_logging()`][cai.sdk.agents.enable_verbose_stdout_logging] function. ```python -from cai.agents import enable_verbose_stdout_logging +from cai.sdk.agents import enable_verbose_stdout_logging enable_verbose_stdout_logging() ``` diff --git a/docs/context.md b/docs/context.md index 0cb56d35..f764e90c 100644 --- a/docs/context.md +++ b/docs/context.md @@ -29,7 +29,7 @@ You can use the context for things like: import asyncio from dataclasses import dataclass -from cai.agents import Agent, RunContextWrapper, Runner, function_tool +from cai.sdk.agents import Agent, RunContextWrapper, Runner, function_tool @dataclass class UserInfo: # (1)! diff --git a/docs/guardrails.md b/docs/guardrails.md index 8dbe63a3..9747d8e1 100644 --- a/docs/guardrails.md +++ b/docs/guardrails.md @@ -41,7 +41,7 @@ You need to provide a function that receives input, and returns a [`GuardrailFun ```python from pydantic import BaseModel -from cai.agents import ( +from cai.sdk.agents import ( Agent, GuardrailFunctionOutput, InputGuardrailTripwireTriggered, @@ -99,7 +99,7 @@ Output guardrails are similar. ```python from pydantic import BaseModel -from cai.agents import ( +from cai.sdk.agents import ( Agent, GuardrailFunctionOutput, OutputGuardrailTripwireTriggered, diff --git a/docs/handoffs.md b/docs/handoffs.md index 32dc7bd8..0b302201 100644 --- a/docs/handoffs.md +++ b/docs/handoffs.md @@ -15,7 +15,7 @@ You can create a handoff using the [`handoff()`][cai.sdk.agents.handoffs.handoff Here's how you can create a simple handoff: ```python -from cai.agents import Agent, handoff +from cai.sdk.agents import Agent, handoff billing_agent = Agent(name="Billing agent") refund_agent = Agent(name="Refund agent") @@ -38,7 +38,7 @@ The [`handoff()`][cai.sdk.agents.handoffs.handoff] function lets you customize t - `input_filter`: This lets you filter the input received by the next agent. See below for more. ```python -from cai.agents import Agent, handoff, RunContextWrapper +from cai.sdk.agents import Agent, handoff, RunContextWrapper def on_handoff(ctx: RunContextWrapper[None]): print("Handoff called") @@ -60,7 +60,7 @@ In certain situations, you want the LLM to provide some data when it calls a han ```python from pydantic import BaseModel -from cai.agents import Agent, handoff, RunContextWrapper +from cai.sdk.agents import Agent, handoff, RunContextWrapper class EscalationData(BaseModel): reason: str @@ -84,7 +84,7 @@ When a handoff occurs, it's as though the new agent takes over the conversation, There are some common patterns (for example removing all tool calls from the history), which are implemented for you in [`cai.sdk.agents.extensions.handoff_filters`][] ```python -from cai.agents import Agent, handoff +from cai.sdk.agents import Agent, handoff from agents.extensions import handoff_filters agent = Agent(name="FAQ agent") @@ -102,7 +102,7 @@ handoff_obj = handoff( To make sure that LLMs understand handoffs properly, we recommend including information about handoffs in your agents. We have a suggested prefix in [`cai.sdk.agents.extensions.handoff_prompt.RECOMMENDED_PROMPT_PREFIX`][], or you can call [`cai.sdk.agents.extensions.handoff_prompt.prompt_with_handoff_instructions`][] to automatically add recommended data to your prompts. ```python -from cai.agents import Agent +from cai.sdk.agents import Agent from agents.extensions.handoff_prompt import RECOMMENDED_PROMPT_PREFIX billing_agent = Agent( diff --git a/docs/index.md b/docs/index.md index 45b1f0b0..1848e512 100644 --- a/docs/index.md +++ b/docs/index.md @@ -33,7 +33,7 @@ pip install openai-agents ## Hello world example ```python -from cai.agents import Agent, Runner +from cai.sdk.agents import Agent, Runner agent = Agent(name="Assistant", instructions="You are a helpful assistant") diff --git a/docs/models.md b/docs/models.md index 79ee5fb6..dd3534f1 100644 --- a/docs/models.md +++ b/docs/models.md @@ -18,7 +18,7 @@ Within a single workflow, you may want to use different models for each agent. F While our SDK supports both the [`OpenAIResponsesModel`][cai.sdk.agents.models.openai_responses.OpenAIResponsesModel] and the [`OpenAIChatCompletionsModel`][cai.sdk.agents.models.openai_chatcompletions.OpenAIChatCompletionsModel] shapes, we recommend using a single model shape for each workflow because the two shapes support a different set of features and tools. If your workflow requires mixing and matching model shapes, make sure that all the features you're using are available on both. ```python -from cai.agents import Agent, Runner, AsyncOpenAI, OpenAIChatCompletionsModel +from cai.sdk.agents import Agent, Runner, AsyncOpenAI, OpenAIChatCompletionsModel import asyncio spanish_agent = Agent( diff --git a/docs/quickstart.md b/docs/quickstart.md index 9a7d78ac..71214f74 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -37,7 +37,7 @@ export OPENAI_API_KEY=sk-... Agents are defined with instructions, a name, and optional config (such as `model_config`) ```python -from cai.agents import Agent +from cai.sdk.agents import Agent agent = Agent( name="Math Tutor", @@ -50,7 +50,7 @@ agent = Agent( Additional agents can be defined in the same way. `handoff_descriptions` provide additional context for determining handoff routing ```python -from cai.agents import Agent +from cai.sdk.agents import Agent history_tutor_agent = Agent( name="History Tutor", @@ -82,7 +82,7 @@ triage_agent = Agent( Let's check that the workflow runs and the triage agent correctly routes between the two specialist agents. ```python -from cai.agents import Runner +from cai.sdk.agents import Runner async def main(): result = await Runner.run(triage_agent, "What is the capital of France?") @@ -94,7 +94,7 @@ async def main(): You can define custom guardrails to run on the input or output. ```python -from cai.agents import GuardrailFunctionOutput, Agent, Runner +from cai.sdk.agents import GuardrailFunctionOutput, Agent, Runner from pydantic import BaseModel class HomeworkOutput(BaseModel): @@ -121,7 +121,7 @@ async def homework_guardrail(ctx, agent, input_data): Let's put it all together and run the entire workflow, using handoffs and the input guardrail. ```python -from cai.agents import Agent, InputGuardrail,GuardrailFunctionOutput, Runner +from cai.sdk.agents import Agent, InputGuardrail,GuardrailFunctionOutput, Runner from pydantic import BaseModel import asyncio diff --git a/docs/running_agents.md b/docs/running_agents.md index 2f08e56f..18b15b97 100644 --- a/docs/running_agents.md +++ b/docs/running_agents.md @@ -7,7 +7,7 @@ You can run agents via the [`Runner`][cai.sdk.agents.run.Runner] class. You have 3. [`Runner.run_streamed()`][cai.sdk.agents.run.Runner.run_streamed], which runs async and returns a [`RunResultStreaming`][cai.sdk.agents.result.RunResultStreaming]. It calls the LLM in streaming mode, and streams those events to you as they are received. ```python -from cai.agents import Agent, Runner +from cai.sdk.agents import Agent, Runner async def main(): agent = Agent(name="Assistant", instructions="You are a helpful assistant") diff --git a/docs/streaming.md b/docs/streaming.md index 1ea3c622..25e228ac 100644 --- a/docs/streaming.md +++ b/docs/streaming.md @@ -13,7 +13,7 @@ For example, this will output the text generated by the LLM token-by-token. ```python import asyncio from openai.types.responses import ResponseTextDeltaEvent -from cai.agents import Agent, Runner +from cai.sdk.agents import Agent, Runner async def main(): agent = Agent( @@ -40,7 +40,7 @@ For example, this will ignore raw events and stream updates to the user. ```python import asyncio import random -from cai.agents import Agent, ItemHelpers, Runner, function_tool +from cai.sdk.agents import Agent, ItemHelpers, Runner, function_tool @function_tool def how_many_jokes() -> int: diff --git a/docs/tools.md b/docs/tools.md index 0785d1d3..b6e79891 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -15,7 +15,7 @@ OpenAI offers a few built-in tools when using the [`OpenAIResponsesModel`][cai.s - The [`ComputerTool`][cai.sdk.agents.tool.ComputerTool] allows automating computer use tasks. ```python -from cai.agents import Agent, FileSearchTool, Runner, WebSearchTool +from cai.sdk.agents import Agent, FileSearchTool, Runner, WebSearchTool agent = Agent( name="Assistant", @@ -49,7 +49,7 @@ import json from typing_extensions import TypedDict, Any -from cai.agents import Agent, FunctionTool, RunContextWrapper, function_tool +from cai.sdk.agents import Agent, FunctionTool, RunContextWrapper, function_tool class Location(TypedDict): @@ -183,7 +183,7 @@ from typing import Any from pydantic import BaseModel -from cai.agents import RunContextWrapper, FunctionTool +from cai.sdk.agents import RunContextWrapper, FunctionTool @@ -223,7 +223,7 @@ The code for the schema extraction lives in [`cai.sdk.agents.function_schema`][] In some workflows, you may want a central agent to orchestrate a network of specialized agents, instead of handing off control. You can do this by modeling agents as tools. ```python -from cai.agents import Agent, Runner +from cai.sdk.agents import Agent, Runner import asyncio spanish_agent = Agent( diff --git a/docs/tracing.md b/docs/tracing.md index e2e77242..1c8c58b6 100644 --- a/docs/tracing.md +++ b/docs/tracing.md @@ -48,7 +48,7 @@ In addition, you can set up [custom trace processors](#custom-tracing-processors Sometimes, you might want multiple calls to `run()` to be part of a single trace. You can do this by wrapping the entire code in a `trace()`. ```python -from cai.agents import Agent, Runner, trace +from cai.sdk.agents import Agent, Runner, trace async def main(): agent = Agent(name="Joke generator", instructions="Tell funny jokes.") diff --git a/docs/voice/quickstart.md b/docs/voice/quickstart.md index c11af530..e1d1a885 100644 --- a/docs/voice/quickstart.md +++ b/docs/voice/quickstart.md @@ -50,7 +50,7 @@ First, let's set up some Agents. This should feel familiar to you if you've buil import asyncio import random -from cai.agents import ( +from cai.sdk.agents import ( Agent, function_tool, ) @@ -129,7 +129,7 @@ import random import numpy as np import sounddevice as sd -from cai.agents import ( +from cai.sdk.agents import ( Agent, function_tool, set_tracing_disabled,