Skip to content

Commit

Permalink
chore: improve quickstart (#262)
Browse files Browse the repository at this point in the history
Improves the quick start to mention more Chat Models, and uses info boxes now that they are added.
  • Loading branch information
kurtisvg authored Feb 4, 2025
1 parent 1104ec9 commit a402c9e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 35 deletions.
72 changes: 46 additions & 26 deletions docs/en/getting-started/local_quickstart.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: "Local Quickstart"
title: "Quickstart"
type: docs
weight: 2
description: >
How to get started running Toolbox locally with Python and PostgreSQL.
How to get started running Toolbox locally with Python, PostgreSQL, and
LangGraph.
---

## Before you begin
Expand All @@ -13,13 +13,18 @@ This guide assumes you have already done the following:

1. Installed [Python 3.9+][install-python]
1. Installed [PostgreSQL 16+ and the `psql` client][install-postgres]
1. Completed [setup for `langchain-vertexai` package][install-vertexai] (or are
comfortable switching the example to a different LLM model)
1. Completed setup for usage with a [LangChain chat model][lc-chat], such as:
- [`langchain-vertexai` package][install-vertexai]
- [`langchain-google-genai` package][install-genai]
- [`langchain-anthropic` package][install-anthropic]


[install-python]: https://wiki.python.org/moin/BeginnersGuide/Download
[install-postgres]: https://www.postgresql.org/download/
[lc-chat]: https://python.langchain.com/docs/integrations/chat/
[install-vertexai]: https://python.langchain.com/docs/integrations/llms/google_vertex_ai_palm/#setup
[install-genai]: https://python.langchain.com/docs/integrations/chat/google_generative_ai/#setup
[install-anthropic]: https://python.langchain.com/docs/integrations/chat/anthropic/#setup

## Step 1: Set up your database

Expand All @@ -29,13 +34,18 @@ access by our agent, and create a database user for Toolbox to connect with.
1. Connect to postgres using the `psql` command:

```bash
psql -U postgres
psql -h 127.0.0.1 -U postgres
```

Here, `postgres` denotes the default postgres superuser.

1. Create a new database and a new user:

{{< notice tip >}}
For a real application, it's best to follow the principle of least permission
and only grant the privileges your application needs.
{{< /notice >}}
```sql
CREATE USER toolbox_user WITH PASSWORD 'my-password';
Expand All @@ -45,8 +55,7 @@ access by our agent, and create a database user for Toolbox to connect with.
ALTER DATABASE toolbox_db OWNER TO toolbox_user;
```
> **_NOTE:_** For a real application, it's best to follow the principle of
> least permission and only grant the privileges your application needs.
1. End the database session:
Expand Down Expand Up @@ -105,16 +114,16 @@ In this section, we will download Toolbox, configure our tools in a
1. Download the latest version of Toolbox as a binary:
> **_NOTE:_** Use the [correct binary][install-toolbox] corresponding to
> your OS and CPU architecture.
{{< notice tip >}}
Select the
[correct binary](https://github.com/googleapis/genai-toolbox/releases)
corresponding to your OS and CPU architecture.
{{< /notice >}}
```bash
export OS="linux/amd64" # one of linux/amd64, darwin/arm64, darwin/amd64, or windows/amd64
curl -O https://storage.googleapis.com/genai-toolbox/v0.0.5/$OS/toolbox
```
[install-toolbox]: https://github.com/googleapis/genai-toolbox/releases
1. Make the binary executable:
```bash
Expand Down Expand Up @@ -207,14 +216,16 @@ In this section, we will download Toolbox, configure our tools in a
In this section, we will write and run a LangGraph agent that will load the Tools
from Toolbox.

1. In a new terminal,install the `toolbox_langchain_sdk` package.
1. In a new terminal, install the `toolbox-langchain-sdk` package.

{{< notice warning >}}
The `toolbox-langchain-sdk` package is not yet published
to PyPi. Install it directly from the git repo instead:

> **_NOTE:_** toolbox_langchain_sdk package is not yet published to PyPi.
> Install it directly from the git repo instead:
>
> ```bash
> pip install -e "git+https://github.com/googleapis/genai-toolbox#egg=toolbox-langchain-sdk&subdirectory=sdks/langchain"
> ```
```bash
pip install -e "git+https://github.com/googleapis/genai-toolbox#egg=toolbox-langchain-sdk&subdirectory=sdks/langchain"
```
{{< /notice >}}

```bash
pip install toolbox-langchain-sdk
Expand All @@ -223,17 +234,24 @@ from Toolbox.
1. Install other required dependencies:

```bash
# TODO(developer): replace with correct package if needed
pip install langgraph langchain-google-vertexai
# pip install langchain_google_genai
# pip install langchain_anthropic
```

1. Create a new file named `langgraph_hotel_agent.py` and copy the following code to
create a [LangGraph agent][langgraph-agent], based on their [Hotels example][langchain-hotels]:
1. Create a new file named `langgraph_hotel_agent.py` and copy the following
code to create a [LangGraph agent][langgraph-agent], based on their [Hotels
example][langchain-hotels]:

```python
import asyncio
from langgraph.prebuilt import create_react_agent
# TODO(developer): replace this with another import if needed
from langchain_google_vertexai import ChatVertexAI
# from langchain_google_genai import ChatGoogleGenerativeAI
# from langchain_anthropic import ChatAnthropic
from langgraph.checkpoint.memory import MemorySaver
from toolbox_langchain_sdk import ToolboxClient
Expand All @@ -243,8 +261,8 @@ from Toolbox.
cancellations. When the user searches for a hotel, mention it's name, id,
location and price tier. Always mention hotel ids while performing any
searches. This is very important for any operations. For any bookings or
cancellations, please provide the appropriate confirmation. Be sure to update
checkin or checkout dates if mentioned by the user.
cancellations, please provide the appropriate confirmation. Be sure to
update checkin or checkout dates if mentioned by the user.
Don't ask for confirmations from the user.
"""
Expand All @@ -256,8 +274,10 @@ from Toolbox.
]
async def main():
# TODO(reader): replace this with another model if needed
model = ChatVertexAI(model_name="gemini-pro")
# TODO(developer): replace this with another model if needed
model = ChatVertexAI(model_name="gemini-1.5-pro")
# model = ChatGoogleGenerativeAI(model="gemini-1.5-pro")
# model = ChatAnthropic(model="claude-3-5-sonnet-20240620")
# Load the tools from the Toolbox server
client = ToolboxClient("http://127.0.0.1:5000")
Expand Down
9 changes: 6 additions & 3 deletions docs/en/resources/sources/cloud-sql-mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ permissions):

- `roles/cloudsql.client`

> **_NOTE:_**
> If you are connecting from Compute Engine, make sure your VM also has the
> [proper scope][gce-access-scopes] to connect using the Cloud SQL Admin API.
{{< notice tip >}}
If you are connecting from Compute Engine, make sure your VM
also has the [proper
scope](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam)
to connect using the Cloud SQL Admin API.
{{< /notice >}}

[csql-go-conn]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector
[adc]: https://cloud.google.com/docs/authentication#adc
Expand Down
9 changes: 6 additions & 3 deletions docs/en/resources/sources/cloud-sql-mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ permissions):

- `roles/cloudsql.client`

> **_NOTE:_**
> If you are connecting from Compute Engine, make sure your VM also has the
> [proper scope][gce-access-scopes] to connect using the Cloud SQL Admin API.
{{< notice tip >}}
If you are connecting from Compute Engine, make sure your VM
also has the [proper
scope](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam)
to connect using the Cloud SQL Admin API.
{{< /notice >}}

[csql-go-conn]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector
[adc]: https://cloud.google.com/docs/authentication#adc
Expand Down
9 changes: 6 additions & 3 deletions docs/en/resources/sources/cloud-sql-pg.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ permissions):

- `roles/cloudsql.client`

> **_NOTE:_**
> If you are connecting from Compute Engine, make sure your VM also has the
> [proper scope][gce-access-scopes] to connect using the Cloud SQL Admin API.
{{< notice tip >}}
If you are connecting from Compute Engine, make sure your VM
also has the [proper
scope](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam)
to connect using the Cloud SQL Admin API.
{{< /notice >}}

[csql-go-conn]: https://github.com/GoogleCloudPlatform/cloud-sql-go-connector
[adc]: https://cloud.google.com/docs/authentication#adc
Expand Down

0 comments on commit a402c9e

Please sign in to comment.