diff --git a/docs/en/getting-started/configure.md b/docs/en/getting-started/configure.md index 603cd6b335..dba592f1d1 100644 --- a/docs/en/getting-started/configure.md +++ b/docs/en/getting-started/configure.md @@ -75,8 +75,8 @@ You can load toolsets by name: ```python # This will load all tools -all_tools = await client.aload_toolset() +all_tools = client.load_toolset() # This will only load the tools listed in 'my_second_toolset' -my_second_toolset = await client.aload_toolset("my_second_toolset") +my_second_toolset = client.load_toolset("my_second_toolset") ``` \ No newline at end of file diff --git a/docs/en/getting-started/introduction/_index.md b/docs/en/getting-started/introduction/_index.md index 81d23baf7a..4739b0e758 100644 --- a/docs/en/getting-started/introduction/_index.md +++ b/docs/en/getting-started/introduction/_index.md @@ -100,7 +100,7 @@ out the resources in the [How-to section](../../how-to/_index.md) Once your server is up and running, you can load the tools into your application. See below the list of Client SDKs for using various frameworks: -{{< tabpane text=true >}} +{{< tabpane text=true persist=header >}} {{% tab header="LangChain" lang="en" %}} Once you've installed the [Toolbox LangChain @@ -114,11 +114,31 @@ from toolbox_langchain import ToolboxClient client = ToolboxClient("http://127.0.0.1:5000") # these tools can be passed to your application! -tools = await client.aload_toolset() +tools = client.load_toolset() {{< /highlight >}} For more detailed instructions on using the Toolbox LangChain SDK, see the [project's README](https://github.com/googleapis/genai-toolbox-langchain-python/blob/main/README.md). +{{% /tab %}} +{{% tab header="Llamaindex" lang="en" %}} + +Once you've installed the [Toolbox Llamaindex +SDK](https://github.com/googleapis/genai-toolbox-llamaindex-python), you can load +tools: + +{{< highlight python >}} +from toolbox_llamaindex import ToolboxClient + +# update the url to point to your server +client = ToolboxClient("http://127.0.0.1:5000") + +# these tools can be passed to your application! +tools = client.load_toolset() +{{< /highlight >}} + +For more detailed instructions on using the Toolbox Llamaindex SDK, see the +[project's README](https://github.com/googleapis/genai-toolbox-llamaindex-python/blob/main/README.md). + {{% /tab %}} {{< /tabpane >}} diff --git a/docs/en/how-to/deploy_docker.md b/docs/en/how-to/deploy_docker.md index c12d79a7f8..f829e34d7a 100644 --- a/docs/en/how-to/deploy_docker.md +++ b/docs/en/how-to/deploy_docker.md @@ -84,7 +84,7 @@ You can use this setup quickly set up Toolbox + Postgres to follow along in our -## Connecting with Toolbox Client SDL +## Connecting with Toolbox Client SDK Next, we will use Toolbox with the Client SDKs: @@ -96,11 +96,19 @@ Next, we will use Toolbox with the Client SDKs: 1. Import and initialize the client with the URL: - ```bash - from toolbox_langchain_sdk import ToolboxClient + {{< tabpane persist=header >}} +{{< tab header="LangChain" lang="Python" >}} +from toolbox_langchain import ToolboxClient - # Replace with the cloud run service URL generated above - toolbox = ToolboxClient("$YOUR_URL") - ``` +# Replace with the cloud run service URL generated above +toolbox = ToolboxClient("http://$YOUR_URL") +{{< /tab >}} +{{< tab header="Llamaindex" lang="Python" >}} +from toolbox_llamaindex import ToolboxClient + +# Replace with the cloud run service URL generated above +toolbox = ToolboxClient("http://$YOUR_URL") +{{< /tab >}} +{{< /tabpane >}} diff --git a/docs/en/how-to/deploy_toolbox.md b/docs/en/how-to/deploy_toolbox.md index afc7aa002a..14e4ab9b46 100644 --- a/docs/en/how-to/deploy_toolbox.md +++ b/docs/en/how-to/deploy_toolbox.md @@ -168,9 +168,18 @@ Next, we will use Toolbox with client SDK: 1. Import and initialize the toolbox client with the URL retrieved above: - ```bash - from toolbox_langchain_sdk import ToolboxClient + {{< tabpane persist=header >}} +{{< tab header="LangChain" lang="Python" >}} +from toolbox_langchain import ToolboxClient + +# Replace with the cloud run service URL generated above +toolbox = ToolboxClient("http://$YOUR_URL") +{{< /tab >}} +{{< tab header="Llamaindex" lang="Python" >}} +from toolbox_llamaindex import ToolboxClient + +# Replace with the cloud run service URL generated above +toolbox = ToolboxClient("http://$YOUR_URL") +{{< /tab >}} +{{< /tabpane >}} - # Replace with the cloud run service URL generated above - toolbox = ToolboxClient("http://$YOUR_URL") - ``` diff --git a/docs/en/resources/authServices/_index.md b/docs/en/resources/authServices/_index.md index c333055d00..2dfbbf6097 100644 --- a/docs/en/resources/authServices/_index.md +++ b/docs/en/resources/authServices/_index.md @@ -58,7 +58,7 @@ when the tool is invoked. This allows you to cache and refresh the ID token as needed. ### Specifying tokens during load -{{< tabpane >}} +{{< tabpane persist=header >}} {{< tab header="LangChain" lang="Python" >}} async def get_auth_token(): # ... Logic to retrieve ID token (e.g., from local storage, OAuth flow) @@ -66,19 +66,41 @@ async def get_auth_token(): return "YOUR_ID_TOKEN" # Placeholder # for a single tool use: -authorized_tool = await toolbox.aload_tool("my-tool-name", auth_tokens={"my_auth": get_auth_token}) +authorized_tool = toolbox.load_tool("my-tool-name", auth_tokens={"my_auth": get_auth_token}) # for a toolset use: -authorized_tools = await toolbox.aload_toolset("my-toolset-name", auth_tokens={"my_auth": get_auth_token}) +authorized_tools = toolbox.load_toolset("my-toolset-name", auth_tokens={"my_auth": get_auth_token}) +{{< /tab >}} +{{< tab header="Llamaindex" lang="Python" >}} +async def get_auth_token(): + # ... Logic to retrieve ID token (e.g., from local storage, OAuth flow) + # This example just returns a placeholder. Replace with your actual token retrieval. + return "YOUR_ID_TOKEN" # Placeholder + +# for a single tool use: +authorized_tool = toolbox.load_tool("my-tool-name", auth_tokens={"my_auth": get_auth_token}) + +# for a toolset use: +authorized_tools = toolbox.load_toolset("my-toolset-name", auth_tokens={"my_auth": get_auth_token}) {{< /tab >}} {{< /tabpane >}} ### Specifying tokens for existing tools -{{< tabpane >}} +{{< tabpane persist=header >}} {{< tab header="LangChain" lang="Python" >}} -tools = await toolbox.aload_toolset() +tools = toolbox.load_toolset() +# for a single token +auth_tools = [tool.add_auth_token("my_auth", get_auth_token) for tool in tools] +# OR, if multiple tokens are needed +authorized_tool = tools[0].add_auth_tokens({ + "my_auth1": get_auth1_token, + "my_auth2": get_auth2_token, +}) +{{< /tab >}} +{{< tab header="Llamaindex" lang="Python" >}} +tools = toolbox.load_toolset() # for a single token auth_tools = [tool.add_auth_token("my_auth", get_auth_token) for tool in tools] # OR, if multiple tokens are needed