Fix paths in docs

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
This commit is contained in:
Víctor Mayoral Vilches 2025-03-28 08:35:25 +01:00
parent d2d2ce535d
commit f0b93aec91
13 changed files with 34 additions and 34 deletions

View File

@ -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(...)

View File

@ -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()
```

View File

@ -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)!

View File

@ -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,

View File

@ -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(

View File

@ -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")

View File

@ -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(

View File

@ -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

View File

@ -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")

View File

@ -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:

View File

@ -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(

View File

@ -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.")

View File

@ -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,