diff --git a/docs/ja/examples.md b/docs/ja/examples.md index dbe84067a5..820719c934 100644 --- a/docs/ja/examples.md +++ b/docs/ja/examples.md @@ -4,104 +4,139 @@ search: --- # コード例 -[repo](https://github.com/openai/openai-agents-python/tree/main/examples) の examples セクションで、 SDK のさまざまなサンプル実装を確認できます。examples は、異なるパターンと機能を示す複数のカテゴリーに整理されています。 +[repo](https://github.com/openai/openai-agents-python/tree/main/examples) の examples セクションで、 SDK のさまざまなサンプル実装を確認できます。これらのコード例は、異なるパターンと機能を示す複数のカテゴリーに整理されています。 ## カテゴリー - **[agent_patterns](https://github.com/openai/openai-agents-python/tree/main/examples/agent_patterns):** - このカテゴリーのコード例では、一般的なエージェント設計パターンを示しています。例: + このカテゴリーのコード例では、次のような一般的なエージェント設計パターンを示します。 - 決定論的ワークフロー - Agents as tools - - エージェントの並列実行 + - ストリーミングイベントを伴う Agents as tools (`examples/agent_patterns/agents_as_tools_streaming.py`) + - 構造化入力パラメーターを伴う Agents as tools (`examples/agent_patterns/agents_as_tools_structured.py`) + - 並列エージェント実行 - 条件付きツール使用 - - 入力/出力ガードレール - - 審判としての LLM + - 異なる挙動でツール使用を強制する (`examples/agent_patterns/forcing_tool_use.py`) + - 入力 / 出力ガードレール + - 審査者としての LLM - ルーティング - ストリーミングガードレール + - ツール承認と状態シリアライズを伴う Human-in-the-loop (`examples/agent_patterns/human_in_the_loop.py`) + - ストリーミングを伴う Human-in-the-loop (`examples/agent_patterns/human_in_the_loop_stream.py`) - 承認フロー向けのカスタム拒否メッセージ (`examples/agent_patterns/human_in_the_loop_custom_rejection.py`) - **[basic](https://github.com/openai/openai-agents-python/tree/main/examples/basic):** - これらのコード例では、 SDK の基礎的な機能を紹介しています。例: + これらのコード例では、次のような SDK の基本機能を紹介します。 - - Hello world のコード例 (デフォルトモデル、 GPT-5 、 open-weight モデル) + - Hello world のコード例 (デフォルトモデル、 GPT-5、 open-weight モデル) - エージェントライフサイクル管理 + - Run hooks と agent hooks のライフサイクル例 (`examples/basic/lifecycle_example.py`) - 動的システムプロンプト + - 基本的なツール使用 (`examples/basic/tools.py`) + - ツール入力 / 出力ガードレール (`examples/basic/tool_guardrails.py`) + - 画像ツール出力 (`examples/basic/image_tool_output.py`) - ストリーミング出力 (テキスト、項目、関数呼び出し引数) - - ターン間で共有セッションヘルパーを使う Responses websocket トランスポート (`examples/basic/stream_ws.py`) + - 複数ターンで共有セッションヘルパーを使用する Responses websocket transport (`examples/basic/stream_ws.py`) - プロンプトテンプレート - - ファイル処理 (ローカル/リモート、画像/PDF) - - 使用状況トラッキング - - Runner 管理のリトライ設定 (`examples/basic/retry.py`) - - サードパーティアダプターを介した Runner 管理のリトライ (`examples/basic/retry_litellm.py`) + - ファイル処理 (ローカルとリモート、画像と PDF) + - 使用状況追跡 + - Runner 管理の再試行設定 (`examples/basic/retry.py`) + - サードパーティアダプター経由の Runner 管理再試行 (`examples/basic/retry_litellm.py`) - 非 strict な出力型 - - 前回レスポンス ID の使用 + - 以前の response ID の使用 - **[customer_service](https://github.com/openai/openai-agents-python/tree/main/examples/customer_service):** 航空会社向けのカスタマーサービスシステムのコード例です。 - **[financial_research_agent](https://github.com/openai/openai-agents-python/tree/main/examples/financial_research_agent):** - 金融データ分析のためのエージェントとツールを使った構造化リサーチワークフローを示す、金融リサーチエージェントです。 + 金融データ分析のためのエージェントとツールを用いた、構造化された調査ワークフローを示す金融リサーチエージェントです。 - **[handoffs](https://github.com/openai/openai-agents-python/tree/main/examples/handoffs):** - メッセージフィルタリングを伴うエージェントハンドオフの実践的なコード例をご覧ください。 + メッセージフィルタリングを含む、エージェントのハンドオフの実践的なコード例です。 + + - メッセージフィルター例 (`examples/handoffs/message_filter.py`) + - ストリーミングを伴うメッセージフィルター (`examples/handoffs/message_filter_streaming.py`) - **[hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp):** - hosted MCP (Model Context Protocol) コネクターと承認の使い方を示すコード例です。 + OpenAI Responses API で hosted MCP (Model Context Protocol) を使用する方法を示すコード例です。以下を含みます。 + + - 承認なしのシンプルな hosted MCP (`examples/hosted_mcp/simple.py`) + - Google Calendar などの MCP コネクター (`examples/hosted_mcp/connectors.py`) + - 割り込みベース承認を伴う Human-in-the-loop (`examples/hosted_mcp/human_in_the_loop.py`) + - MCP ツール呼び出しの on-approval コールバック (`examples/hosted_mcp/on_approval.py`) - **[mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp):** - MCP (Model Context Protocol) を使ってエージェントを構築する方法を学べます。内容: + 以下を含め、 MCP (Model Context Protocol) でエージェントを構築する方法を学べます。 - - ファイルシステムのコード例 + - Filesystem のコード例 - Git のコード例 - - MCP プロンプトサーバーのコード例 + - MCP prompt server のコード例 - SSE (Server-Sent Events) のコード例 - - ストリーミング可能な HTTP のコード例 + - SSE リモートサーバー接続 (`examples/mcp/sse_remote_example`) + - Streamable HTTP のコード例 + - Streamable HTTP リモート接続 (`examples/mcp/streamable_http_remote_example`) + - Streamable HTTP 向けカスタム HTTP client factory (`examples/mcp/streamablehttp_custom_client_example`) + - `MCPUtil.get_all_function_tools` による全 MCP ツールの事前取得 (`examples/mcp/get_all_mcp_tools_example`) + - FastAPI を使用した MCPServerManager (`examples/mcp/manager_example`) + - MCP ツールフィルタリング (`examples/mcp/tool_filter_example`) - **[memory](https://github.com/openai/openai-agents-python/tree/main/examples/memory):** - エージェント向けのさまざまなメモリ実装のコード例です。内容: + エージェント向けのさまざまなメモリ実装のコード例です。以下を含みます。 - SQLite セッションストレージ - 高度な SQLite セッションストレージ - Redis セッションストレージ - SQLAlchemy セッションストレージ - - Dapr ステートストアセッションストレージ + - Dapr state store セッションストレージ - 暗号化セッションストレージ - OpenAI Conversations セッションストレージ - Responses compaction セッションストレージ - - `ModelSettings(store=False)` を使ったステートレスな Responses compaction (`examples/memory/compaction_session_stateless_example.py`) + - `ModelSettings(store=False)` を使用したステートレスな Responses compaction (`examples/memory/compaction_session_stateless_example.py`) + - ファイルベースのセッションストレージ (`examples/memory/file_session.py`) + - Human-in-the-loop を伴うファイルベースセッション (`examples/memory/file_hitl_example.py`) + - Human-in-the-loop を伴う SQLite インメモリセッション (`examples/memory/memory_session_hitl_example.py`) + - Human-in-the-loop を伴う OpenAI Conversations セッション (`examples/memory/openai_session_hitl_example.py`) + - セッションをまたぐ HITL 承認 / 拒否シナリオ (`examples/memory/hitl_session_scenario.py`) - **[model_providers](https://github.com/openai/openai-agents-python/tree/main/examples/model_providers):** - カスタムプロバイダーやサードパーティアダプターを含め、 SDK で非 OpenAI モデルを使う方法を確認できます。 + カスタムプロバイダーやサードパーティアダプターを含め、 SDK で非 OpenAI モデルを使用する方法を確認できます。 - **[realtime](https://github.com/openai/openai-agents-python/tree/main/examples/realtime):** - SDK を使ってリアルタイム体験を構築する方法を示すコード例です。内容: + SDK を使用してリアルタイム体験を構築する方法を示すコード例です。以下を含みます。 - - 構造化テキストおよび画像メッセージを使った Web アプリケーションパターン + - 構造化されたテキストおよび画像メッセージによる Web アプリケーションパターン - コマンドライン音声ループと再生処理 - WebSocket 経由の Twilio Media Streams 統合 - Realtime Calls API attach フローを使用した Twilio SIP 統合 - **[reasoning_content](https://github.com/openai/openai-agents-python/tree/main/examples/reasoning_content):** - reasoning content と structured outputs の扱い方を示すコード例です。 + reasoning content の扱い方を示すコード例です。以下を含みます。 + + - Runner API、ストリーミング、非ストリーミングでの reasoning content (`examples/reasoning_content/runner_example.py`) + - OpenRouter 経由で OSS モデルを使用した reasoning content (`examples/reasoning_content/gpt_oss_stream.py`) + - 基本的な reasoning content のコード例 (`examples/reasoning_content/main.py`) - **[research_bot](https://github.com/openai/openai-agents-python/tree/main/examples/research_bot):** - 複雑なマルチエージェントのディープリサーチワークフローを示す、シンプルなディープリサーチクローンです。 + 複雑なマルチエージェント調査ワークフローを示す、シンプルなディープリサーチクローンです。 - **[tools](https://github.com/openai/openai-agents-python/tree/main/examples/tools):** - OpenAI がホストするツールと、次のような実験的な Codex ツール機能の実装方法を学べます。 + 以下のような OpenAI がホストするツールと実験的な Codex ツール機能の実装方法を学べます。 - Web 検索 とフィルター付き Web 検索 - ファイル検索 - - Code Interpreter - - インラインスキル付き hosted container shell (`examples/tools/container_shell_inline_skill.py`) - - スキル参照付き hosted container shell (`examples/tools/container_shell_skill_reference.py`) - - ローカルスキル付きローカル shell (`examples/tools/local_shell_skill.py`) - - 名前空間と遅延ツールを使ったツール検索 (`examples/tools/tool_search.py`) + - Code interpreter + - ファイル編集と承認を伴う apply patch ツール (`examples/tools/apply_patch.py`) + - 承認コールバックを伴う shell ツール実行 (`examples/tools/shell.py`) + - Human-in-the-loop 割り込みベース承認を伴う shell ツール (`examples/tools/shell_human_in_the_loop.py`) + - インラインスキルを伴う hosted container shell (`examples/tools/container_shell_inline_skill.py`) + - スキル参照を伴う hosted container shell (`examples/tools/container_shell_skill_reference.py`) + - ローカルスキルを伴う local shell (`examples/tools/local_shell_skill.py`) + - 名前空間と遅延ツールを伴うツール検索 (`examples/tools/tool_search.py`) - コンピュータ操作 - 画像生成 - 実験的な Codex ツールワークフロー (`examples/tools/codex.py`) - 実験的な Codex 同一スレッドワークフロー (`examples/tools/codex_same_thread.py`) - **[voice](https://github.com/openai/openai-agents-python/tree/main/examples/voice):** - ストリーミング音声のコード例を含む、 TTS / STT モデルを使用した音声エージェントのコード例をご覧ください。 \ No newline at end of file + ストリーミング音声のコード例を含む、 TTS および STT モデルを使用した音声エージェントのコード例を確認できます。 \ No newline at end of file diff --git a/docs/ko/examples.md b/docs/ko/examples.md index 9d3d59cee4..7718043d15 100644 --- a/docs/ko/examples.md +++ b/docs/ko/examples.md @@ -4,7 +4,7 @@ search: --- # 코드 예제 -[repo](https://github.com/openai/openai-agents-python/tree/main/examples)의 examples 섹션에서 SDK의 다양한 샘플 구현을 확인해 보세요. examples는 다양한 패턴과 기능을 보여주는 여러 카테고리로 구성되어 있습니다. +[repo](https://github.com/openai/openai-agents-python/tree/main/examples)의 examples 섹션에서 SDK의 다양한 샘플 구현을 확인해 보세요. examples는 서로 다른 패턴과 기능을 보여주는 여러 카테고리로 구성되어 있습니다. ## 카테고리 @@ -13,21 +13,30 @@ search: - 결정론적 워크플로 - Agents as tools + - 스트리밍 이벤트를 포함한 Agents as tools (`examples/agent_patterns/agents_as_tools_streaming.py`) + - 구조화된 입력 매개변수를 포함한 Agents as tools (`examples/agent_patterns/agents_as_tools_structured.py`) - 병렬 에이전트 실행 - 조건부 도구 사용 - - 입력/출력 가드레일 - - 심사자로서의 LLM + - 서로 다른 동작으로 도구 사용 강제 (`examples/agent_patterns/forcing_tool_use.py`) + - 입출력 가드레일 + - 심판 역할의 LLM - 라우팅 - 스트리밍 가드레일 - - 승인 흐름을 위한 사용자 지정 거절 메시지 (`examples/agent_patterns/human_in_the_loop_custom_rejection.py`) + - 도구 승인 및 상태 직렬화를 포함한 휴먼인더루프 (HITL) (`examples/agent_patterns/human_in_the_loop.py`) + - 스트리밍을 포함한 휴먼인더루프 (HITL) (`examples/agent_patterns/human_in_the_loop_stream.py`) + - 승인 플로를 위한 사용자 지정 거절 메시지 (`examples/agent_patterns/human_in_the_loop_custom_rejection.py`) - **[basic](https://github.com/openai/openai-agents-python/tree/main/examples/basic):** 이 예제들은 다음과 같은 SDK의 기본 기능을 보여줍니다 - - Hello World 예제 (기본 모델, GPT-5, 오픈 가중치 모델) + - Hello World 예제 (기본 모델, GPT-5, 오픈 웨이트 모델) - 에이전트 라이프사이클 관리 + - 실행 훅 및 에이전트 훅 라이프사이클 예제 (`examples/basic/lifecycle_example.py`) - 동적 시스템 프롬프트 - - 스트리밍 출력 (텍스트, 항목, 함수 호출 인수) + - 기본 도구 사용 (`examples/basic/tools.py`) + - 도구 입출력 가드레일 (`examples/basic/tool_guardrails.py`) + - 이미지 도구 출력 (`examples/basic/image_tool_output.py`) + - 스트리밍 출력 (텍스트, 항목, 함수 호출 인자) - 턴 간 공유 세션 헬퍼를 사용하는 Responses websocket 전송 (`examples/basic/stream_ws.py`) - 프롬프트 템플릿 - 파일 처리 (로컬 및 원격, 이미지 및 PDF) @@ -41,25 +50,39 @@ search: 항공사를 위한 고객 서비스 시스템 예제입니다 - **[financial_research_agent](https://github.com/openai/openai-agents-python/tree/main/examples/financial_research_agent):** - 금융 데이터 분석을 위해 에이전트와 도구를 활용한 구조화된 리서치 워크플로를 보여주는 금융 리서치 에이전트입니다 + 금융 데이터 분석을 위한 에이전트와 도구를 사용한 구조화된 리서치 워크플로를 보여주는 금융 리서치 에이전트입니다 - **[handoffs](https://github.com/openai/openai-agents-python/tree/main/examples/handoffs):** - 메시지 필터링을 사용하는 에이전트 핸드오프의 실용적인 예제를 확인하세요 + 메시지 필터링을 포함한 에이전트 핸드오프의 실용적인 예제: + + - 메시지 필터 예제 (`examples/handoffs/message_filter.py`) + - 스트리밍을 포함한 메시지 필터 (`examples/handoffs/message_filter_streaming.py`) - **[hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp):** - 호스티드 MCP (Model context protocol) 커넥터와 승인 사용 방법을 보여주는 예제입니다 + OpenAI Responses API와 함께 호스티드 MCP (Model context protocol)를 사용하는 방법을 보여주는 예제: + + - 승인 없는 간단한 호스티드 MCP (`examples/hosted_mcp/simple.py`) + - Google Calendar 같은 MCP 커넥터 (`examples/hosted_mcp/connectors.py`) + - 인터럽션(중단 처리) 기반 승인을 포함한 휴먼인더루프 (HITL) (`examples/hosted_mcp/human_in_the_loop.py`) + - MCP 도구 호출용 승인 시 콜백 (`examples/hosted_mcp/on_approval.py`) - **[mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp):** - 다음을 포함해 MCP (Model context protocol)로 에이전트를 구축하는 방법을 알아보세요 + MCP (Model context protocol)로 에이전트를 구축하는 방법을 알아보세요: - - 파일 시스템 예제 + - 파일시스템 예제 - Git 예제 - MCP 프롬프트 서버 예제 - SSE (Server-Sent Events) 예제 - - 스트리밍 가능한 HTTP 예제 + - SSE 원격 서버 연결 (`examples/mcp/sse_remote_example`) + - Streamable HTTP 예제 + - Streamable HTTP 원격 연결 (`examples/mcp/streamable_http_remote_example`) + - Streamable HTTP용 사용자 지정 HTTP 클라이언트 팩토리 (`examples/mcp/streamablehttp_custom_client_example`) + - `MCPUtil.get_all_function_tools`를 사용한 모든 MCP 도구 프리패칭 (`examples/mcp/get_all_mcp_tools_example`) + - FastAPI를 사용하는 MCPServerManager (`examples/mcp/manager_example`) + - MCP 도구 필터링 (`examples/mcp/tool_filter_example`) - **[memory](https://github.com/openai/openai-agents-python/tree/main/examples/memory):** - 다음을 포함한 에이전트를 위한 다양한 메모리 구현 예제입니다 + 에이전트를 위한 다양한 메모리 구현 예제: - SQLite 세션 저장소 - 고급 SQLite 세션 저장소 @@ -70,38 +93,50 @@ search: - OpenAI Conversations 세션 저장소 - Responses 컴팩션 세션 저장소 - `ModelSettings(store=False)`를 사용한 상태 비저장 Responses 컴팩션 (`examples/memory/compaction_session_stateless_example.py`) + - 파일 기반 세션 저장소 (`examples/memory/file_session.py`) + - 휴먼인더루프 (HITL)를 포함한 파일 기반 세션 (`examples/memory/file_hitl_example.py`) + - 휴먼인더루프 (HITL)를 포함한 SQLite 인메모리 세션 (`examples/memory/memory_session_hitl_example.py`) + - 휴먼인더루프 (HITL)를 포함한 OpenAI Conversations 세션 (`examples/memory/openai_session_hitl_example.py`) + - 세션 전반의 HITL 승인/거절 시나리오 (`examples/memory/hitl_session_scenario.py`) - **[model_providers](https://github.com/openai/openai-agents-python/tree/main/examples/model_providers):** - 사용자 지정 제공자와 서드파티 어댑터를 포함해 SDK에서 OpenAI가 아닌 모델을 사용하는 방법을 살펴보세요 + 사용자 지정 프로바이더와 서드파티 어댑터를 포함해 SDK에서 OpenAI 이외 모델을 사용하는 방법을 살펴보세요 - **[realtime](https://github.com/openai/openai-agents-python/tree/main/examples/realtime):** - 다음을 포함해 SDK를 사용해 실시간 경험을 구축하는 방법을 보여주는 예제입니다 + SDK를 사용해 실시간 경험을 구축하는 방법을 보여주는 예제: - 구조화된 텍스트 및 이미지 메시지를 사용하는 웹 애플리케이션 패턴 - - 명령줄 오디오 루프 및 재생 처리 + - 커맨드라인 오디오 루프 및 재생 처리 - WebSocket을 통한 Twilio Media Streams 통합 - - Realtime Calls API attach 흐름을 사용하는 Twilio SIP 통합 + - Realtime Calls API attach 플로를 사용하는 Twilio SIP 통합 - **[reasoning_content](https://github.com/openai/openai-agents-python/tree/main/examples/reasoning_content):** - reasoning content 및 structured outputs를 다루는 방법을 보여주는 예제입니다 + reasoning content를 다루는 방법을 보여주는 예제: + + - Runner API의 reasoning content, 스트리밍 및 비스트리밍 (`examples/reasoning_content/runner_example.py`) + - OpenRouter를 통한 OSS 모델의 reasoning content (`examples/reasoning_content/gpt_oss_stream.py`) + - 기본 reasoning content 예제 (`examples/reasoning_content/main.py`) - **[research_bot](https://github.com/openai/openai-agents-python/tree/main/examples/research_bot):** 복잡한 멀티 에이전트 리서치 워크플로를 보여주는 간단한 딥 리서치 클론입니다 - **[tools](https://github.com/openai/openai-agents-python/tree/main/examples/tools):** - 다음과 같은 OpenAI 호스트하는 도구 및 실험적 Codex 도구 기능을 구현하는 방법을 알아보세요 + 다음과 같은 OpenAI 호스트하는 도구 및 실험적 Codex 도구 기능을 구현하는 방법을 알아보세요: - - 웹 검색 및 필터가 있는 웹 검색 + - 웹 검색 및 필터를 포함한 웹 검색 - 파일 검색 - - 코드 인터프리터 - - 인라인 스킬을 사용하는 호스티드 컨테이너 셸 (`examples/tools/container_shell_inline_skill.py`) - - 스킬 참조를 사용하는 호스티드 컨테이너 셸 (`examples/tools/container_shell_skill_reference.py`) - - 로컬 스킬을 사용하는 로컬 셸 (`examples/tools/local_shell_skill.py`) - - 네임스페이스와 지연 도구를 사용하는 도구 검색 (`examples/tools/tool_search.py`) + - Code Interpreter + - 파일 편집 및 승인을 포함한 패치 적용 도구 (`examples/tools/apply_patch.py`) + - 승인 콜백을 포함한 셸 도구 실행 (`examples/tools/shell.py`) + - 휴먼인더루프 (HITL) 인터럽션(중단 처리) 기반 승인을 포함한 셸 도구 (`examples/tools/shell_human_in_the_loop.py`) + - 인라인 스킬을 포함한 호스티드 컨테이너 셸 (`examples/tools/container_shell_inline_skill.py`) + - 스킬 참조를 포함한 호스티드 컨테이너 셸 (`examples/tools/container_shell_skill_reference.py`) + - 로컬 스킬을 포함한 로컬 셸 (`examples/tools/local_shell_skill.py`) + - 네임스페이스 및 지연 도구를 사용하는 도구 검색 (`examples/tools/tool_search.py`) - 컴퓨터 사용 - 이미지 생성 - 실험적 Codex 도구 워크플로 (`examples/tools/codex.py`) - 실험적 Codex 동일 스레드 워크플로 (`examples/tools/codex_same_thread.py`) - **[voice](https://github.com/openai/openai-agents-python/tree/main/examples/voice):** - 스트리밍 음성 예제를 포함해 TTS 및 STT 모델을 사용하는 음성 에이전트 예제를 확인하세요 \ No newline at end of file + 스트리밍 음성 예제를 포함해 TTS 및 STT 모델을 사용하는 음성 에이전트 예제를 확인해 보세요 \ No newline at end of file diff --git a/docs/zh/examples.md b/docs/zh/examples.md index 4ca594faf4..d2aee9af6d 100644 --- a/docs/zh/examples.md +++ b/docs/zh/examples.md @@ -4,62 +4,85 @@ search: --- # 示例 -在[repo](https://github.com/openai/openai-agents-python/tree/main/examples)的示例部分查看 SDK 的各种 sample code。这些示例按多个目录组织,展示了不同的模式与能力。 +请在 [repo](https://github.com/openai/openai-agents-python/tree/main/examples) 的示例部分查看 SDK 的多种 sample code。示例按多个目录组织,展示了不同的模式和能力。 ## 目录 - **[agent_patterns](https://github.com/openai/openai-agents-python/tree/main/examples/agent_patterns):** - 该目录中的示例展示了常见的智能体设计模式,例如 + 此目录中的示例展示了常见的智能体设计模式,例如 - 确定性工作流 - Agents as tools + - 带流式事件的 Agents as tools(`examples/agent_patterns/agents_as_tools_streaming.py`) + - 带结构化输入参数的 Agents as tools(`examples/agent_patterns/agents_as_tools_structured.py`) - 并行智能体执行 - 条件化工具使用 + - 通过不同行为强制工具使用(`examples/agent_patterns/forcing_tool_use.py`) - 输入/输出安全防护措施 - - LLM 作为评判者 + - LLM 作为裁判 - 路由 - - 流式传输安全防护措施 - - 用于审批流程的自定义拒绝消息(`examples/agent_patterns/human_in_the_loop_custom_rejection.py`) + - 流式安全防护措施 + - 带工具审批与状态序列化的人在回路(`examples/agent_patterns/human_in_the_loop.py`) + - 带流式传输的人在回路(`examples/agent_patterns/human_in_the_loop_stream.py`) + - 审批流程的自定义拒绝消息(`examples/agent_patterns/human_in_the_loop_custom_rejection.py`) - **[basic](https://github.com/openai/openai-agents-python/tree/main/examples/basic):** 这些示例展示了 SDK 的基础能力,例如 - - Hello world 示例(默认模型、GPT-5、开放权重模型) + - Hello World 示例(默认模型、GPT-5、开放权重模型) - 智能体生命周期管理 + - Run hooks 和 agent hooks 生命周期示例(`examples/basic/lifecycle_example.py`) - 动态系统提示词 - - 流式传输输出(文本、条目、函数调用参数) - - 跨轮次使用共享会话助手的 Responses websocket 传输(`examples/basic/stream_ws.py`) + - 基础工具使用(`examples/basic/tools.py`) + - 工具输入/输出安全防护措施(`examples/basic/tool_guardrails.py`) + - 图像工具输出(`examples/basic/image_tool_output.py`) + - 流式输出(文本、条目、函数调用参数) + - 跨轮次共享会话助手的 Responses websocket 传输(`examples/basic/stream_ws.py`) - 提示词模板 - - 文件处理(本地与远程,图像与 PDF) - - 用量跟踪 + - 文件处理(本地与远程、图像与 PDF) + - 用量追踪 - 由 Runner 管理的重试设置(`examples/basic/retry.py`) - - 通过第三方适配器进行由 Runner 管理的重试(`examples/basic/retry_litellm.py`) + - 通过第三方适配器由 Runner 管理重试(`examples/basic/retry_litellm.py`) - 非严格输出类型 - - 先前响应 ID 的使用 + - previous response ID 用法 - **[customer_service](https://github.com/openai/openai-agents-python/tree/main/examples/customer_service):** - 面向航空公司的客户服务系统示例。 + 航空公司的客户服务系统示例。 - **[financial_research_agent](https://github.com/openai/openai-agents-python/tree/main/examples/financial_research_agent):** - 一个金融研究智能体,展示了使用智能体与工具进行金融数据分析的结构化研究工作流。 + 一个金融研究智能体,展示了使用智能体和工具进行金融数据分析的结构化研究工作流。 - **[handoffs](https://github.com/openai/openai-agents-python/tree/main/examples/handoffs):** - 查看带有消息过滤的智能体任务转移实践示例。 + 智能体任务转移的实用示例,包含消息过滤,包括: + + - 消息过滤示例(`examples/handoffs/message_filter.py`) + - 带流式传输的消息过滤(`examples/handoffs/message_filter_streaming.py`) - **[hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp):** - 演示如何使用托管 MCP(Model Context Protocol)连接器与审批的示例。 + 展示如何将托管 MCP(Model context protocol)与 OpenAI Responses API 一起使用的示例,包括: + + - 无需审批的简单托管 MCP(`examples/hosted_mcp/simple.py`) + - MCP 连接器,例如 Google Calendar(`examples/hosted_mcp/connectors.py`) + - 基于中断审批的人在回路(`examples/hosted_mcp/human_in_the_loop.py`) + - MCP 工具调用的审批回调(`examples/hosted_mcp/on_approval.py`) - **[mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp):** - 了解如何使用 MCP(Model Context Protocol)构建智能体,包括: + 了解如何使用 MCP(Model context protocol)构建智能体,包括: - 文件系统示例 - Git 示例 - - MCP 提示词服务示例 - - SSE(Server-Sent Events)示例 - - 可流式 HTTP 示例 + - MCP prompt 服务示例 + - SSE(服务器发送事件)示例 + - SSE 远程服务连接(`examples/mcp/sse_remote_example`) + - Streamable HTTP 示例 + - Streamable HTTP 远程连接(`examples/mcp/streamable_http_remote_example`) + - 用于 Streamable HTTP 的自定义 HTTP 客户端工厂(`examples/mcp/streamablehttp_custom_client_example`) + - 使用 `MCPUtil.get_all_function_tools` 预获取所有 MCP 工具(`examples/mcp/get_all_mcp_tools_example`) + - 搭配 FastAPI 的 MCPServerManager(`examples/mcp/manager_example`) + - MCP 工具过滤(`examples/mcp/tool_filter_example`) - **[memory](https://github.com/openai/openai-agents-python/tree/main/examples/memory):** - 不同智能体记忆实现的示例,包括: + 面向智能体的不同内存实现示例,包括: - SQLite 会话存储 - 高级 SQLite 会话存储 @@ -70,6 +93,11 @@ search: - OpenAI Conversations 会话存储 - Responses 压缩会话存储 - 使用 `ModelSettings(store=False)` 的无状态 Responses 压缩(`examples/memory/compaction_session_stateless_example.py`) + - 文件后端会话存储(`examples/memory/file_session.py`) + - 带人在回路的文件后端会话(`examples/memory/file_hitl_example.py`) + - 带人在回路的 SQLite 内存会话(`examples/memory/memory_session_hitl_example.py`) + - 带人在回路的 OpenAI Conversations 会话(`examples/memory/openai_session_hitl_example.py`) + - 跨会话的 HITL 审批/拒绝场景(`examples/memory/hitl_session_scenario.py`) - **[model_providers](https://github.com/openai/openai-agents-python/tree/main/examples/model_providers):** 探索如何在 SDK 中使用非 OpenAI 模型,包括自定义提供方和第三方适配器。 @@ -77,27 +105,34 @@ search: - **[realtime](https://github.com/openai/openai-agents-python/tree/main/examples/realtime):** 展示如何使用 SDK 构建实时体验的示例,包括: - - 使用结构化文本与图像消息的 Web 应用模式 + - 使用结构化文本和图像消息的 Web 应用模式 - 命令行音频循环与播放处理 - - 通过 WebSocket 集成 Twilio Media Streams - - 使用 Realtime Calls API 附加流程的 Twilio SIP 集成 + - 基于 WebSocket 的 Twilio Media Streams 集成 + - 使用 Realtime Calls API attach 流程的 Twilio SIP 集成 - **[reasoning_content](https://github.com/openai/openai-agents-python/tree/main/examples/reasoning_content):** - 演示如何处理推理内容和 structured outputs 的示例。 + 展示如何处理推理内容的示例,包括: + + - 使用 Runner API 的推理内容,含流式和非流式(`examples/reasoning_content/runner_example.py`) + - 通过 OpenRouter 使用 OSS 模型的推理内容(`examples/reasoning_content/gpt_oss_stream.py`) + - 基础推理内容示例(`examples/reasoning_content/main.py`) - **[research_bot](https://github.com/openai/openai-agents-python/tree/main/examples/research_bot):** - 简单的深度研究克隆,展示了复杂的多智能体研究工作流。 + 简单的深度研究克隆示例,展示复杂的多智能体研究工作流。 - **[tools](https://github.com/openai/openai-agents-python/tree/main/examples/tools):** 了解如何实现由OpenAI托管的工具和实验性 Codex 工具能力,例如: - - 网络检索与带过滤器的网络检索 + - 网络检索以及带过滤器的网络检索 - 文件检索 - - 代码解释器 + - Code Interpreter + - 带文件编辑与审批的 apply patch 工具(`examples/tools/apply_patch.py`) + - 带审批回调的 shell 工具执行(`examples/tools/shell.py`) + - 带基于中断审批的人在回路 shell 工具(`examples/tools/shell_human_in_the_loop.py`) - 带内联技能的托管容器 shell(`examples/tools/container_shell_inline_skill.py`) - 带技能引用的托管容器 shell(`examples/tools/container_shell_skill_reference.py`) - 带本地技能的本地 shell(`examples/tools/local_shell_skill.py`) - - 带命名空间与延迟工具的工具搜索(`examples/tools/tool_search.py`) + - 带命名空间和延迟工具的工具搜索(`examples/tools/tool_search.py`) - 计算机操作 - 图像生成 - 实验性 Codex 工具工作流(`examples/tools/codex.py`)