diff --git a/README.md b/README.md index a7ffc47..173abee 100644 --- a/README.md +++ b/README.md @@ -111,13 +111,8 @@ client = OpenAI( ) ``` -## Running the Examples - -1. Update `examples/agenthub/common.py` and/or `examples/partner/openai/common.py` with your `COMPARTMENT_ID`, `PROJECT_OCID`, and set the correct `REGION`. -2. Set the `OCI_GENAI_API_KEY` environment variable when an example uses API key authentication. -3. Install optional dev dependencies: `pip install -e '.[dev]'`. - -Run an example either by calling its `main()` method or from the command line. +## Examples +Demo code and instructions on how to run them, for both agenthub and partner usecases can be found in ```examples``` folder. ## Contributing diff --git a/examples/agenthub/README.md b/examples/agenthub/README.md new file mode 100644 index 0000000..50707cb --- /dev/null +++ b/examples/agenthub/README.md @@ -0,0 +1,75 @@ +# AgentHub Examples + +This folder contains examples for OCI Generative AI AgentHub APIs using the OpenAI Python SDK. + +## Prerequisites + +1. Install dependencies: + + ```bash + pip install -e '.[dev]' + ``` + +2. Configure shared values in `examples/agenthub/common.py`: + - `PROFILE_NAME` + - `COMPARTMENT_ID` + - `PROJECT_OCID` + - `REGION` + +3. (Optional) You can override project at runtime: + + ```bash + export OCI_GENAI_PROJECT_ID= + ``` + +4. If running API-key based examples, set: + + ```bash + export OPENAI_API_KEY= + ``` + +## How to run + +From repository root, run any example module with `python -m`. + +Quickstarts: + +```bash +python -m examples.agenthub.quickstart_responses_create_oci_iam +python -m examples.agenthub.quickstart_responses_create_api_key +``` + +Responses API examples: + +```bash +python -m examples.agenthub.responses.create_response +python -m examples.agenthub.responses.streaming_text_delta +python -m examples.agenthub.responses.structured_output +python -m examples.agenthub.responses.use_gpt_model +python -m examples.agenthub.responses.use_google_gemini_model +``` + +Tools examples: + +```bash +python -m examples.agenthub.tools.function_calling +python -m examples.agenthub.tools.web_search +python -m examples.agenthub.tools.code_interpreter +``` + +Other categories follow the same pattern: + +```bash +python -m examples.agenthub.agents.basic_agents_example +python -m examples.agenthub.multiturn.responses_chaining +python -m examples.agenthub.memory.long_term_memory +python -m examples.agenthub.mcp.create_responses_mcp +python -m examples.agenthub.vector_stores.vector_stores_crud +python -m examples.agenthub.files.files_crud +python -m examples.agenthub.function.create_responses_fc +``` + +## Notes + +- Most examples use IAM signing through `oci-genai-auth`. +- AgentHub examples use OpenAI-compatible `/openai/v1` endpoints and require a project OCID. diff --git a/examples/agenthub/agents/basic_agents_example.py b/examples/agenthub/agents/basic_agents_example.py index ed4db5f..f12ebcb 100644 --- a/examples/agenthub/agents/basic_agents_example.py +++ b/examples/agenthub/agents/basic_agents_example.py @@ -17,4 +17,4 @@ async def main(): print(result.final_output) if __name__ == "__main__": - asyncio.run(main()) + asyncio.run(main()) \ No newline at end of file diff --git a/examples/partner/README.md b/examples/partner/README.md new file mode 100644 index 0000000..ccadd0a --- /dev/null +++ b/examples/partner/README.md @@ -0,0 +1,29 @@ +# Partner Examples + +This folder contains partner API examples using the OpenAI Python SDK. + +## Prerequisites + +1. Install dependencies: + + ```bash + pip install -e '.[dev]' + ``` + +2. Configure shared values in `examples/partner/common.py`: + - `PROFILE_NAME` + - `COMPARTMENT_ID` + - `REGION` + +## How to run + +From repository root: + +```bash +python -m examples.partner.openai.quickstart_openai_chat_completions +``` + +## Notes + +- Partner endpoints use pass-through mode and require the `opc-compartment-id` header. +- These examples use IAM signing through `oci-genai-auth`. diff --git a/examples/partner/common.py b/examples/partner/common.py index 874b325..05cec13 100644 --- a/examples/partner/common.py +++ b/examples/partner/common.py @@ -1,7 +1,7 @@ # Copyright (c) 2026 Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ -"""Partner (pass-through) example clients and configuration.""" +"""Partner example clients and configuration.""" from __future__ import annotations @@ -14,7 +14,7 @@ COMPARTMENT_ID = "<>" REGION = "us-chicago-1" -PARTNER_OPENAI_BASE_URL = f"https://inference.generativeai.{REGION}.oci.oraclecloud.com/v1" +PARTNER_OPENAI_BASE_URL = f"https://inference.generativeai.{REGION}.oci.oraclecloud.com/20231130/actions/v1" def build_openai_client() -> OpenAI: diff --git a/examples/partner/openai/basic_chat_completion.py b/examples/partner/openai/basic_chat_completion.py index 210b2d6..4437c5e 100644 --- a/examples/partner/openai/basic_chat_completion.py +++ b/examples/partner/openai/basic_chat_completion.py @@ -1,7 +1,7 @@ # Copyright (c) 2026 Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ -"""Demonstrates a basic chat completion request for the Partner (pass-through) endpoint.""" +"""Demonstrates a basic chat completion request for the Partner endpoint.""" from rich import print diff --git a/examples/partner/openai/tool_call_chat_completion.py b/examples/partner/openai/tool_call_chat_completion.py index 8fe6ce9..81b0205 100644 --- a/examples/partner/openai/tool_call_chat_completion.py +++ b/examples/partner/openai/tool_call_chat_completion.py @@ -1,7 +1,7 @@ # Copyright (c) 2026 Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ -"""Demonstrates tool calling with chat completions for the Partner (pass-through) endpoint.""" +"""Demonstrates tool calling with chat completions for the Partner endpoint.""" import json from typing import Dict