Commit Graph

197 Commits

Author SHA1 Message Date
Yuan
a0ac5334d1 chore: return error for untested fields in tools.yaml (#239)
This only checks within `SourceConfig`, `ToolConfig`, and
`AuthSourceConfig`.

Error when an unknown field is provided:
`2025-01-27T22:43:46.988401-08:00 ERROR "unable to parse tool file at
\"tools.yaml\": unable to parse as \"cloud-sql-postgres\": [2:1] unknown
field \"extra\"\n 1 | database: test_database\n> 2 | extra: here\n ^\n 3
| instance: toolbox-cloudsql\n 4 | kind: cloud-sql-postgres\n 5 |
password: postgres\n 6 | "`

Error when a required field is not provided:
`2025-01-27T17:49:47.584846-08:00 ERROR "unable to parse tool file at
\"tools.yaml\": validation failed: Key: 'Config.Region' Error:Field
validation for 'Region' failed on the 'required' tag"`

---------

Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
2025-02-03 15:30:27 -08:00
dependabot[bot]
d2efd8c11d chore(deps): bump golang.org/x/net from 0.32.0 to 0.33.0 (#230)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.32.0 to
0.33.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="dfc720dfe0"><code>dfc720d</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="8e66b04771"><code>8e66b04</code></a>
html: use strings.EqualFold instead of lowering ourselves</li>
<li><a
href="b935f7b5d7"><code>b935f7b</code></a>
html: avoid endless loop on error token</li>
<li><a
href="9af49ef148"><code>9af49ef</code></a>
route: remove unused sizeof* consts</li>
<li><a
href="6705db9a4d"><code>6705db9</code></a>
quic: clean up crypto streams when dropping packet protection keys</li>
<li><a
href="4ef7588d2b"><code>4ef7588</code></a>
quic: handle ACK frame in packet which drops number space</li>
<li><a
href="552d8ac903"><code>552d8ac</code></a>
Revert &quot;route: change from syscall to x/sys/unix&quot;</li>
<li><a
href="13a7c0108b"><code>13a7c01</code></a>
Revert &quot;route: remove unused sizeof* consts on freebsd&quot;</li>
<li>See full diff in <a
href="https://github.com/golang/net/compare/v0.32.0...v0.33.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/net&package-manager=go_modules&previous-version=0.32.0&new-version=0.33.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/googleapis/genai-toolbox/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Yuan <45984206+Yuan325@users.noreply.github.com>
2025-02-03 14:43:37 -08:00
Yuan
b578e6ce89 docs(mssql): add docs for source (#256)
Add docs for `mssql` source, and update for `mssql-sql` tool.
2025-02-03 18:34:01 +00:00
Yuan
2a7a1eb49c ci(mssql): add integration test (#257)
Add integration test for `mssql`.
2025-02-03 18:27:22 +00:00
Shivaji Kharse
617cc872d1 feat: add dgraph tool and source (#233)
* add dgraph tool and source
2025-02-01 15:32:06 -07:00
Yuan
8fca0a95ee feat(sqlserver): add mssql source (#255)
Add `mssql` source for non-cloud sql server.
2025-01-31 19:13:54 +00:00
Yuan
5f9fc762e5 docs(mysql): add docs for source (#251)
Add docs for `mysql` source.
2025-01-31 19:07:41 +00:00
Yuan
1764a4918c ci(mysql): add integration test (#252)
Add integration test for `mysql`.
2025-01-31 18:54:00 +00:00
Yuan
378692ab50 feat(mysql): add source (#250)
Add `mysql` source.
2025-01-31 10:48:05 -08:00
Twisha Bansal
b0c94946d6 chore(docs): Fix typo and language (#254) 2025-01-30 20:18:29 +05:30
Yuan
8452f8eb44 feat: add user agent to cloud databases (#244)
Add user agent to cloud databases that provides us anonymized data
request count, number of users, number of projects, and other
environment settings.

User agent is using the format: `genai-toolbox/$version+metadata`
2025-01-29 17:19:52 -08:00
Yuan
8152a98b7a ci(cloudsqlmysql): add integration tests (#243)
Add integration test for CloudSQL for MySQL.

Added other integration tests' tag into `.golangci.yaml`, and fixing
lint errors.

Moved getCloudSQLDialOpts to `common_test.go` since it is used across
all three cloud sql integration tests.
2025-01-29 17:03:40 -08:00
Yuan
1357be2569 fix(mssql): fix mssql tool kind to mssql-sql (#249)
Fixing `mssql` tool to `mssql-sql`.
2025-01-29 23:46:01 +00:00
Yuan
669d6b7239 fix(mysql): fix mysql tool kind to mysql-sql (#248)
Update `mysql` tool to `mysql-sql`.
2025-01-29 23:09:13 +00:00
Yuan
b0ecc16a43 docs(cloudsql-pg): fix typos (#247)
Fix typos in cloud sql pg docs.
2025-01-29 15:04:54 -08:00
Yuan
a7b4f20c3c docs(cloudsql-mssql): fixing some typo and add doc to github pages (#246)
Fixing typo to be consistent with other cloudsql docs, and add source
docs to github pages.
2025-01-29 22:45:55 +00:00
Yuan
a900e562d6 docs(cloudsql-mysql): add docs for source and tools (#240)
Add docs for `cloud-sql-mysql` source and `mysql-sql` tool.
2025-01-29 14:41:40 -08:00
Kurtis Van Gent
497fb06fae feat: add local quickstart (#232)
This is a continuation of #218, which add a local quickstart for running
Toolbox with Python and LangGraph.

---------

Co-authored-by: Twisha Bansal <twishabansal@google.com>
Co-authored-by: Anubhav Dhawan <anubhav756@gmail.com>
2025-01-24 12:18:19 -07:00
Wenxin Du
4639cc6560 fix: Auth token verification failure should not throw error immedicately (#234)
Currently, we are throwing 401 error immediately after auth token
verification failure. This is not expected in the following situations:
1. Non-auth tool invocation with auth token that is invalid.
2. Auth tool invocation with all the required auth token, but the header
contains extra non-required token that is invalid
These requests should pass the authorization check but fail under the
current implementation.

Change made in this PR:
1. Do not throw error immediately after auth token verification failure.
Instead only log it and continue to the next header iteration.
2. In the parseParams() method, if an auth parameter is missing, we
should error with the message telling the user that either the auth
header is missing or is invalid.
2025-01-24 08:49:51 -07:00
Wenxin Du
9bad952060 feat: Add Cloud SQL for SQL Server Source and Tool (#223)
1. `sql/database` provides a `Scan()`interface to scan query results
into typed variables. Therefore we have to create a slice of typed
variables (types retrieved from rows.ColumnTypes()) to pass them into
`Scan()`. Using []byte works but makes the printing result different
from other tools (e.g [1] instead of %!s(int32=1)]
2. MS SQL supports both named (e.g @name) and positional args (e.g @p2),
so we have to check if the name is contained in the original statement
before passing them into `db.Query()` as either named arg or as values.
2025-01-23 21:21:12 +08:00
Kurtis Van Gent
1de3853006 chore: move sources documentation to docsite (#225)
Migrates the docs/sources documentation to the new docsite.

---------

Co-authored-by: Anubhav Dhawan <anubhav756@gmail.com>
2025-01-22 16:57:06 +00:00
Anubhav Dhawan
e2faaf2069 fix: Add coverage file to .gitignore (#228) 2025-01-22 08:45:27 +00:00
Anubhav Dhawan
779bf6b9a2 fix(langchain-sdk): Inherit from BaseTool and implement placeholder _run method.
This is some ground-work before we add sync tool calls support to ToolboxTool.
2025-01-22 14:04:43 +05:30
Yuan
f1f61d7087 feat: add cloudsql mysql source and tool (#221)
Add CloudSQL for MySQL source and tool.

CloudSQLMySQL source is initialize with the following config:
```
sources:
    my-cloudsqlmysql-source:
        kind: cloud-sql-mysql
        project: my-project-name
        region: my-region
        instance: my-instance-name
        user: my_user
        password: my_pass
        database: my_db
        # ipType: public # The default dialect is public.
```

MySQL tool is initialize with the following config.
```
tools:
    test_tool:
        kind: mysql
        source: my-cloudsqlmysql-source
        description: >
            Testing tool.
        statement: "SELECT 1;"
```
2025-01-21 13:53:37 +00:00
Anubhav Dhawan
0937200644 doc(langchain-sdk): Update LangChain SDK README according to the updated APIs for ToolboxTool. (#193) 2025-01-20 07:31:47 +00:00
Anubhav Dhawan
e0ee1286f9 feat(langchain-sdk): Add features for binding parameters to ToolboxTool class. (#192)
The newly implemented `ToolboxTool` class manages tool state and
supports this new feature of binding parameters along wiith the existing
OAuth.

> [!NOTE]
> These changes are done in the LlamaIndex SDK as well in #203, along
with documentation updates in #193.
2025-01-20 12:57:50 +05:30
Anubhav Dhawan
a136308f55 feat(langchain-sdk)!: Migrate existing state and APIs to a tools level class. (#171)
# `ToolboxTool` Class

The newly implemented `ToolboxTool` class manages tool state and
supports features like bound params and OAuth.

We have also added the logic as well as state related to bound params to
`ToolboxTool` in #192.

`ToolboxTool` follows a functional approach, meaning it ensures that the
internal tool state remains unchanged and a new copy of the tool is
updated with the new values of auth tokens (or bound params from #192).

## `ToolboxTool` Class Diagram

To better explain, here's a visual diagram of the ToolboxTool class.

The boxes have member function names, and the "red" box means a function
is mutating the internal state, while "green" means it does not change
the internal state (like a C++ `const` function or JS immutable
function). The red box also shows the member variable they mutated.

![Image of a diagram showing the `ToolboxTool` class with member
functions and their colors indicating whether they mutate the internal
state](https://github.com/user-attachments/assets/a59eadf2-4aa5-49f0-9b8d-65864e26df07)

## Constructor

From the diagram above, it is evident that all the state changes, or
rather setting of the state, is done in the class constructor.

For further reference, here's a visual explanation of the functionality
of the constructor showing which params we add as auth tokens, which
params we add to the underlying schema, and for what the error/warnings
are thrown.

![Image of a diagram showing the functionality of the `ToolboxTool`
constructor](https://github.com/user-attachments/assets/b4e6c0a1-f0da-4cf5-a56c-976c4c4b006e)

> [!NOTE]
> Documentation updates are done by #193 and the corresponding changes
to the LlamaIndex SDK are done by #203.
2025-01-20 12:38:36 +05:30
Twisha Bansal
b6e753add9 test(llamaindex-sdk): Add more test cases to e2e tests (#219)
Test for tool calls with

1. Missing params
2. Wrong param type
2025-01-17 06:11:08 +00:00
Yuan
45fc046437 chore: migrate yaml library to goccy/go-yaml (#211)
Migrate yaml library from
[gopkg.in/yaml.v3](https://pkg.go.dev/gopkg.in/yaml.v3) to
[goccy/go-yaml](https://github.com/goccy/go-yaml).

We are trying to add validation feature to the unmarshaling of yaml.
However, `yaml.v3` currently does not support that and the library had
not been actively maintained for awhile. This migration will allow us to
use validation processing such as
[go-playground/validator](https://github.com/go-playground/validator)

---------

Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
2025-01-16 09:15:18 -08:00
Yuan
0c3d12ae04 fix: fix typo in postgres test (#216) 2025-01-15 17:53:04 +00:00
Twisha Bansal
58aee52f40 ci: toolbox release latest version (#213) 2025-01-15 08:26:20 +00:00
Twisha Bansal
60c72bc750 ci: toolbox release latest version (#214) 2025-01-15 12:33:04 +05:30
Yuan
9fabfc3b8b docs: add example $VERSION for container image installation (#212)
container image uses `0.0.1` whereas the binary or source uses `v0.0.1`.
Example is added so that this is clear to the user.
2025-01-14 20:02:24 -08:00
release-please[bot]
afb24d322f chore(main): release 0.0.5 (#164)
🤖 I have created a release *beep* *boop*
---


##
[0.0.5](https://github.com/googleapis/genai-toolbox/compare/v0.0.4...v0.0.5)
(2025-01-14)


### ⚠ BREAKING CHANGES

* replace Source field `ip_type` with `ipType` for consistency
([#197](https://github.com/googleapis/genai-toolbox/issues/197))
* **toolbox-sdk:** deprecate 'add_auth_headers' in favor of
'add_auth_tokens'
([#170](https://github.com/googleapis/genai-toolbox/issues/170))

### Features

* Add support for OpenTelemetry
([#205](https://github.com/googleapis/genai-toolbox/issues/205))
([1fcc20a](1fcc20a846))
* Added Neo4j Source and Tool
([#189](https://github.com/googleapis/genai-toolbox/issues/189))
([8a1224b](8a1224b9e0))
* **llamaindex-sdk:** Implement OAuth support for LlamaIndex.
([#159](https://github.com/googleapis/genai-toolbox/issues/159))
([003ce51](003ce510a1))
* Replace Source field `ip_type` with `ipType` for consistency
([#197](https://github.com/googleapis/genai-toolbox/issues/197))
([e069520](e069520bb7))
* Update log with given context
([#147](https://github.com/googleapis/genai-toolbox/issues/147))
([809e547](809e547a48))


### Bug Fixes

* Correct parsing of floats/ints from json
([#180](https://github.com/googleapis/genai-toolbox/issues/180))
([387a5b5](387a5b56b5))
* **doc:** Update example `clientId` field
([#198](https://github.com/googleapis/genai-toolbox/issues/198))
([0c86e89](0c86e89506))
* Fix config name in auth doc samples
([#186](https://github.com/googleapis/genai-toolbox/issues/186))
([bb03457](bb0345767e))
* Handle shutdown gracefully
([#178](https://github.com/googleapis/genai-toolbox/issues/178))
([66ab70f](66ab70f702))
* Improve return error for parameters
([#206](https://github.com/googleapis/genai-toolbox/issues/206))
([346c57d](346c57da23))
* **toolbox-sdk:** Deprecate 'add_auth_headers' in favor of
'add_auth_tokens'
([#170](https://github.com/googleapis/genai-toolbox/issues/170))
([b56fa68](b56fa685e3))


### Miscellaneous Chores

* Release 0.0.5
([#210](https://github.com/googleapis/genai-toolbox/issues/210))
([bd407c0](bd407c0ab7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
v0.0.5
2025-01-15 01:52:22 +08:00
Wenxin Du
bd407c0ab7 chore: release 0.0.5 (#210)
Release-As: 0.0.5
2025-01-15 01:43:35 +08:00
Yuan
346c57da23 fix: improve return error for parameters (#206) 2025-01-14 16:35:33 +00:00
Michael Hunger
8a1224b9e0 feat: Added Neo4j Source and Tool (#189)
- configure neo4j source with url, username, password, database
- configure neo4j tools with cypher statement and paramters
- tests based on the postgres tests
- neo4j.yaml for integration tests
---------

Co-authored-by: duwenxin <duwenxin@google.com>
2025-01-14 09:17:18 -07:00
Twisha Bansal
cce93629a9 tests(sdk): e2e tests for llamaindex sdk (#207) 2025-01-14 07:20:17 +00:00
Wenxin Du
22bf137b8d ci(auth): Add OAuth integration test to Cloud SQL (#172)
1. Add generic integration test helpers for authenticated parameters and
auth-required tool invocations.
2. Call generic test helpers as Cloud SQL integration tests.
2025-01-14 14:02:50 +08:00
Wenxin Du
6ffcca0573 ci: Increase AlloyDB integration test coverage (#187)
add tests for tool invocation with params, connection over public IP,
and connection over private IP.
2025-01-14 12:07:34 +08:00
Wenxin Du
0c86e89506 fix(doc): Update example clientId field (#198) 2025-01-14 11:00:41 +08:00
Wenxin Du
e069520bb7 feat!: replace Source field ip_type with ipType for consistency (#197)
Replace `ip_type` with `ipType` to match the camel-case of the other
fields.
Update docs since we support both private and public IP connections.
2025-01-14 10:56:06 +08:00
Yuan
1fcc20a846 feat: add support for OpenTelemetry (#205)
Co-authored-by: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com>
Co-authored-by: Wenxin Du <117315983+duwenxin99@users.noreply.github.com>
2025-01-13 15:38:38 -08:00
Kurtis Van Gent
141cae7702 docs: add site for hosting docs on github pages (#204)
Adds a static site generation using Hugo, and deployed to GitHub pages
(googleapis.github.io/genai-toolbox).
2025-01-13 15:37:31 -07:00
Twisha Bansal
61627803db test: do not skip fixed tests (#201) 2025-01-13 16:54:04 +05:30
Yuan
d8ffbc68ee ci(spanner): add integration tests (#188) 2025-01-12 21:56:14 -08:00
Yuan
d65cefc600 chore: Add debug logs (#195)
Add debug logs to Toolbox. 

For example when a http fail, it will just show Error at the http level,
but not log with actual error message. err message are returned to the
api as following `{"status":"Internal Server Error","error":"error while
invoking tool: unable to execute client: spanner: code =
\"InvalidArgument\", desc = \"invalid session pool\""}`.

After adding this, if user/dev run toolbox with `--log-level=debug`, it
will output the following (debug log in addition to the error for http
request):

```
2025-01-08T14:16:25.040824-08:00 DEBUG "error while invoking tool: unable to execute client: spanner: code = \"InvalidArgument\", desc = \"invalid session pool\""

2025-01-08T14:16:25.040968-08:00 ERROR Response: 500 Server Error service: "httplog" httpRequest: {url: "http://127.0.0.1:5000/api/tool/test_tool_two/invoke" method: "POST" path: "/api/tool/test_tool_two/invoke" remoteIP: "127.0.0.1:51708" proto: "HTTP/1.1" requestID: "yuanteoh-macbookpro.roam.internal/N7LNMcLIUH-000001" scheme: "http" header: {user-agent: "curl/8.7.1" accept: "*/*" content-type: "application/json" content-length: "2"}} httpResponse: {status: 500 bytes: 167 elapsed: 0.301917}
```
2025-01-13 05:47:46 +00:00
Twisha Bansal
ae732e637f tests(sdk): e2e tests for langchain sdk (#176)
This PR contains toolbox Set up and e2e tests for the following
functionality:

- Load tools
- Load toolsets
- Running tools
- Auth for tools
- Auth for tool parameters

---------

Co-authored-by: Anubhav Dhawan <anubhav756@gmail.com>
2025-01-10 08:25:37 +00:00
Anubhav Dhawan
c58f0104f8 doc(langchain-sdk): Update LangChain SDK example to use Gemini Pro model for better tool selection. (#196) 2025-01-10 11:02:23 +05:30
Anubhav Dhawan
cccc34d019 doc(langchain-sdk): Use Gemini 1.5 Flash model in LangGraph example in the README. (#194) 2025-01-08 19:44:45 +05:30