diff --git a/DEVELOPER.md b/DEVELOPER.md index 038d0e623..244aadecd 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -105,6 +105,10 @@ docker run -d toolbox:dev ``` +## Developing Toolbox SDKs + +Please refer to the [SDK developer guide](sdks/DEVELOPER.md) + ## 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..1b4912d96 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,24 @@ Once you've installed the Toolbox LangChain SDK, you can load tools: from toolbox_langchain_sdk import ToolboxClient # update the url to point to your server -client = ToolboxClient("http://127.0.0.1/") +client = ToolboxClient("http://127.0.0.1:5000") + +# 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 + +# 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 = await client.load_toolset() 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 + ``` diff --git a/sdks/llamaindex/README.md b/sdks/llamaindex/README.md new file mode 100644 index 000000000..3fed846ed --- /dev/null +++ b/sdks/llamaindex/README.md @@ -0,0 +1,82 @@ +# 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 + +# Replace with your Toolbox service's URL +toolbox = ToolboxClient("http://127.0.0.1:5000") +``` + +## 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"}) +``` 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"}