From 97515ec15068d7a95d2b73a7776d555ed9cb8071 Mon Sep 17 00:00:00 2001 From: Twisha Bansal Date: Fri, 8 Nov 2024 14:52:06 +0530 Subject: [PATCH 1/5] docs: LLamaIndex SDK docs --- DEVELOPER.md | 34 +++++++++++++++ README.md | 23 +++++++++- sdks/llamaindex/README.md | 76 ++++++++++++++++++++++++++++++++++ sdks/llamaindex/pyproject.toml | 2 +- 4 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 sdks/llamaindex/README.md diff --git a/DEVELOPER.md b/DEVELOPER.md index 038d0e623..6f03d60b3 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -105,6 +105,40 @@ docker run -d toolbox:dev ``` +## Developing Toolbox SDKs + +Setting up a Development Environment: + +1. Clone the repository: + + ```bash + git clone https://github.com/googleapis/genai-toolbox.git + ``` + +1. Navigate to the SDK directory: + + ```bash + cd genai-toolbox/sdks/langchain + ``` + + or + + ```bash + cd genai-toolbox/sdks/llamaindex + ``` + +1. Install the SDK and test dependencies: + + ```bash + pip install -e .[test] + ``` + +1. Run tests and/or contribute to the SDK's development. + + ```bash + pytest + ``` + ## CI/CD Details Cloud Build is used to run tests against Google Cloud resources in test project. diff --git a/README.md b/README.md index 7c5ff3953..dec9c66fe 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,30 @@ Once you've installed the Toolbox LangChain SDK, you can load tools: ```python from toolbox_langchain_sdk import ToolboxClient +from aiohttp import ClientSession # update the url to point to your server -client = ToolboxClient("http://127.0.0.1/") +session = ClientSession() +client = ToolboxClient("http://127.0.0.1:5000", session) + +# these tools can be passed to your application! +tools = await client.load_toolset() +``` + + + +
+ +LlamaIndex +Once you've installed the Toolbox LlamaIndex SDK, you can load tools: + +```python +from toolbox_llamaindex_sdk import ToolboxClient +from aiohttp import ClientSession + +# update the url to point to your server +session = ClientSession() +client = ToolboxClient("http://127.0.0.1:5000", session) # these tools can be passed to your application! tools = await client.load_toolset() diff --git a/sdks/llamaindex/README.md b/sdks/llamaindex/README.md new file mode 100644 index 000000000..48ce5fec4 --- /dev/null +++ b/sdks/llamaindex/README.md @@ -0,0 +1,76 @@ +# GenAI Toolbox SDK + +This SDK allows you to seamlessly integrate the functionalities of [Toolbox](https://github.com/googleapis/genai-toolbox) into your LLM applications, enabling advanced orchestration and interaction with GenAI models. + + +## Table of Contents + + +- [Installation](#installation) +- [Usage](#usage) +- [Load a toolset](#load-a-toolset) +- [Use with LlamaIndex](#use-with-llamaindex) +- [Manual usage](#manual-usage) + + + +## Installation + +You can install the Toolbox SDK for LlamaIndex using `pip`. + +```bash +pip install toolbox-llamaindex-sdk +``` + +> [!IMPORTANT] +> This SDK is not yet available on PyPI. For now, install it from source by following these [instructions](/DEVELOPER.md#developing-toolbox-SDKs). + +## Usage + +Import and initialize the toolbox client. + +```python +from toolbox_llamaindex_sdk import ToolboxClient +from aiohttp import ClientSession + +session = ClientSession() +# Replace with your Toolbox service's URL +toolbox = ToolboxClient("http://127.0.0.1:5000", session) +``` + +## Load a toolset + +You can load a toolsets, that are collections of related tools. + +```python +# Load all tools +tools = await toolbox.load_toolset() + +# Load a specific toolset +tools = await toolbox.load_toolset("my-toolset") +``` + +## Use with LlamaIndex + +LlamaIndex agents can dynamically choose and execute tools based on the user input. The user can include the tools loaded from the Toolbox SDK in the agent's toolkit. + +```python +from llama_index.llms.vertex import Vertex +from llama_index.core.agent import ReActAgent + +model = Vertex(model="gemini-1.5-pro") + +# Initialize agent with tools +agent = ReActAgent.from_tools(tools, llm=model, verbose=True) + +# Query the agent +response = agent.query("Get some response from the agent.") +``` + +## Manual usage + +You can also execute a tool manually using the `acall` method. + +```python +result = await tools[0].acall({"param1": "value1", "param2": "value2"}) +``` \ No newline at end of file diff --git a/sdks/llamaindex/pyproject.toml b/sdks/llamaindex/pyproject.toml index e570489ee..e11cdfd54 100644 --- a/sdks/llamaindex/pyproject.toml +++ b/sdks/llamaindex/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "toolbox_llamaindex_sdk" +name = "toolbox-llamaindex-sdk" version="0.0.1" description = "Python SDK for interacting with the Toolbox service with Llamaindex" license = {file = "LICENSE"} From a14a962f3fdcbc81acf58b54624d6a4a7721d68c Mon Sep 17 00:00:00 2001 From: Twisha Bansal <58483338+twishabansal@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:39:07 +0530 Subject: [PATCH 2/5] Update DEVELOPER.md Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> --- DEVELOPER.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/DEVELOPER.md b/DEVELOPER.md index 6f03d60b3..88bef8d29 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -115,18 +115,12 @@ Setting up a Development Environment: git clone https://github.com/googleapis/genai-toolbox.git ``` -1. Navigate to the SDK directory: +1. Navigate to the SDK directory, e.g.: ```bash cd genai-toolbox/sdks/langchain ``` - or - - ```bash - cd genai-toolbox/sdks/llamaindex - ``` - 1. Install the SDK and test dependencies: ```bash From bcfd00304f4e3b292152702f3690c754bc0d6351 Mon Sep 17 00:00:00 2001 From: Twisha Bansal Date: Mon, 11 Nov 2024 11:44:36 +0530 Subject: [PATCH 3/5] Moved SDK developer guide to a separate markdown --- DEVELOPER.md | 26 +------------------------- sdks/DEVELOPER.md | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 sdks/DEVELOPER.md diff --git a/DEVELOPER.md b/DEVELOPER.md index 88bef8d29..244aadecd 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -107,31 +107,7 @@ ## Developing Toolbox SDKs -Setting up a Development Environment: - -1. Clone the repository: - - ```bash - git clone https://github.com/googleapis/genai-toolbox.git - ``` - -1. Navigate to the SDK directory, e.g.: - - ```bash - cd genai-toolbox/sdks/langchain - ``` - -1. Install the SDK and test dependencies: - - ```bash - pip install -e .[test] - ``` - -1. Run tests and/or contribute to the SDK's development. - - ```bash - pytest - ``` +Please refer to the [SDK developer guide](sdks/DEVELOPER.md) ## CI/CD Details diff --git a/sdks/DEVELOPER.md b/sdks/DEVELOPER.md new file mode 100644 index 000000000..647492388 --- /dev/null +++ b/sdks/DEVELOPER.md @@ -0,0 +1,27 @@ +# DEVELOPER.md + +## Setting up a Development Environment + +1. Clone the repository: + + ```bash + git clone https://github.com/googleapis/genai-toolbox.git + ``` + +1. Navigate to the SDK directory, e.g.: + + ```bash + cd genai-toolbox/sdks/langchain + ``` + +1. Install the SDK and test dependencies: + + ```bash + pip install -e .[test] + ``` + +1. Run tests and/or contribute to the SDK's development. + + ```bash + pytest + ``` From 8afa5bd272d7c2fcdebb14ff45401cffee85c168 Mon Sep 17 00:00:00 2001 From: Twisha Bansal Date: Mon, 11 Nov 2024 22:29:36 +0530 Subject: [PATCH 4/5] Removed session from toolbox client --- README.md | 8 ++------ sdks/llamaindex/README.md | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index dec9c66fe..1b4912d96 100644 --- a/README.md +++ b/README.md @@ -99,11 +99,9 @@ Once you've installed the Toolbox LangChain SDK, you can load tools: ```python from toolbox_langchain_sdk import ToolboxClient -from aiohttp import ClientSession # update the url to point to your server -session = ClientSession() -client = ToolboxClient("http://127.0.0.1:5000", session) +client = ToolboxClient("http://127.0.0.1:5000") # these tools can be passed to your application! tools = await client.load_toolset() @@ -118,11 +116,9 @@ Once you've installed the Toolbox LlamaIndex SDK, you can load tools: ```python from toolbox_llamaindex_sdk import ToolboxClient -from aiohttp import ClientSession # update the url to point to your server -session = ClientSession() -client = ToolboxClient("http://127.0.0.1:5000", session) +client = ToolboxClient("http://127.0.0.1:5000") # these tools can be passed to your application! tools = await client.load_toolset() diff --git a/sdks/llamaindex/README.md b/sdks/llamaindex/README.md index 48ce5fec4..6057384aa 100644 --- a/sdks/llamaindex/README.md +++ b/sdks/llamaindex/README.md @@ -31,11 +31,9 @@ Import and initialize the toolbox client. ```python from toolbox_llamaindex_sdk import ToolboxClient -from aiohttp import ClientSession -session = ClientSession() # Replace with your Toolbox service's URL -toolbox = ToolboxClient("http://127.0.0.1:5000", session) +toolbox = ToolboxClient("http://127.0.0.1:5000") ``` ## Load a toolset From 629b0a0899292190be4dc4801b0412afeebe851c Mon Sep 17 00:00:00 2001 From: Twisha Bansal Date: Mon, 11 Nov 2024 22:47:02 +0530 Subject: [PATCH 5/5] rewrap markdown --- sdks/llamaindex/README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sdks/llamaindex/README.md b/sdks/llamaindex/README.md index 6057384aa..3fed846ed 100644 --- a/sdks/llamaindex/README.md +++ b/sdks/llamaindex/README.md @@ -1,9 +1,14 @@ # GenAI Toolbox SDK -This SDK allows you to seamlessly integrate the functionalities of [Toolbox](https://github.com/googleapis/genai-toolbox) into your LLM applications, enabling advanced orchestration and interaction with GenAI models. +This SDK allows you to seamlessly integrate the functionalities of +[Toolbox](https://github.com/googleapis/genai-toolbox) into your LLM +applications, enabling advanced orchestration and interaction with GenAI +models. + ## Table of Contents + - [Installation](#installation) @@ -23,7 +28,8 @@ pip install toolbox-llamaindex-sdk ``` > [!IMPORTANT] -> This SDK is not yet available on PyPI. For now, install it from source by following these [instructions](/DEVELOPER.md#developing-toolbox-SDKs). +> This SDK is not yet available on PyPI. For now, install it from source by +following these [instructions](/DEVELOPER.md#developing-toolbox-SDKs). ## Usage @@ -50,7 +56,9 @@ tools = await toolbox.load_toolset("my-toolset") ## Use with LlamaIndex -LlamaIndex agents can dynamically choose and execute tools based on the user input. The user can include the tools loaded from the Toolbox SDK in the agent's toolkit. +LlamaIndex agents can dynamically choose and execute tools based on the user +input. The user can include the tools loaded from the Toolbox SDK in the +agent's toolkit. ```python from llama_index.llms.vertex import Vertex @@ -71,4 +79,4 @@ You can also execute a tool manually using the `acall` method. ```python result = await tools[0].acall({"param1": "value1", "param2": "value2"}) -``` \ No newline at end of file +```