Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .ci/integration.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,28 @@ steps:
"Serverless Spark" \
serverlessspark

- id: "singlestore"
name: golang:1
waitFor: ["compile-test-binary"]
entrypoint: /bin/bash
env:
- "GOPATH=/gopath"
- "SINGLESTORE_PORT=$_SINGLESTORE_PORT"
- "SINGLESTORE_USER=$_SINGLESTORE_USER"
- "SINGLESTORE_DATABASE=$_SINGLESTORE_DATABASE"
- "SERVICE_ACCOUNT_EMAIL=$SERVICE_ACCOUNT_EMAIL"
secretEnv: ["SINGLESTORE_PASSWORD", "SINGLESTORE_HOST", "CLIENT_ID"]
volumes:
- name: "go"
path: "/gopath"
args:
- -c
- |
.ci/test_with_coverage.sh \
"SingleStore" \
singlestore \
singlestore

availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/cloud_sql_pg_user/versions/latest
Expand Down Expand Up @@ -892,6 +914,10 @@ availableSecrets:
env: ORACLE_PASS
- versionName: projects/$PROJECT_ID/secrets/oracle_host/versions/latest
env: ORACLE_HOST
- versionName: projects/$PROJECT_ID/secrets/singlestore_pass/versions/latest
env: SINGLESTORE_PASSWORD
- versionName: projects/$PROJECT_ID/secrets/singlestore_host/versions/latest
env: SINGLESTORE_HOST

options:
logging: CLOUD_LOGGING_ONLY
Expand Down Expand Up @@ -947,3 +973,7 @@ substitutions:
_YUGABYTEDB_PORT: "5433"
_YUGABYTEDB_LOADBALANCE: "false"
_ORACLE_SERVER_NAME: "FREEPDB1"
_SINGLESTORE_HOST: 127.0.0.1
_SINGLESTORE_PORT: "3308"
_SINGLESTORE_DATABASE: "singlestore"
_SINGLESTORE_USER: "root"
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ import (
_ "github.com/googleapis/genai-toolbox/internal/tools/serverlessspark/serverlesssparkcancelbatch"
_ "github.com/googleapis/genai-toolbox/internal/tools/serverlessspark/serverlesssparkgetbatch"
_ "github.com/googleapis/genai-toolbox/internal/tools/serverlessspark/serverlesssparklistbatches"
_ "github.com/googleapis/genai-toolbox/internal/tools/singlestore/singlestoreexecutesql"
_ "github.com/googleapis/genai-toolbox/internal/tools/singlestore/singlestoresql"
_ "github.com/googleapis/genai-toolbox/internal/tools/spanner/spannerexecutesql"
_ "github.com/googleapis/genai-toolbox/internal/tools/spanner/spannerlisttables"
_ "github.com/googleapis/genai-toolbox/internal/tools/spanner/spannersql"
Expand Down Expand Up @@ -212,6 +214,7 @@ import (
_ "github.com/googleapis/genai-toolbox/internal/sources/postgres"
_ "github.com/googleapis/genai-toolbox/internal/sources/redis"
_ "github.com/googleapis/genai-toolbox/internal/sources/serverlessspark"
_ "github.com/googleapis/genai-toolbox/internal/sources/singlestore"
_ "github.com/googleapis/genai-toolbox/internal/sources/spanner"
_ "github.com/googleapis/genai-toolbox/internal/sources/sqlite"
_ "github.com/googleapis/genai-toolbox/internal/sources/tidb"
Expand Down
63 changes: 63 additions & 0 deletions docs/en/resources/sources/singlestore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: "SingleStore"
type: docs
weight: 1
description: >
SingleStore is the cloud-native database built with speed and scale to power data-intensive applications.
---

## About

[SingleStore][singlestore-docs] is a distributed SQL database built to power intelligent applications. It is both relational and multi-model, enabling developers to easily build and scale applications and workloads.

SingleStore is built around Universal Storage which combines in-memory rowstore and on-disk columnstore data formats to deliver a single table type that is optimized to handle both transactional and analytical workloads.

[singlestore-docs]: https://docs.singlestore.com/

## Available Tools

- [`singlestore-sql`](../tools/singlestore/singlestore-sql.md)
Execute pre-defined prepared SQL queries in SingleStore.

- [`singlestore-execute-sql`](../tools/singlestore/singlestore-execute-sql.md)
Run parameterized SQL queries in SingleStore.

## Requirements

### Database User

This source only uses standard authentication. You will need to [create a
database user][singlestore-user] to login to the database with.

[singlestore-user]: https://docs.singlestore.com/cloud/reference/sql-reference/security-management-commands/create-user/

## Example

```yaml
sources:
my-singlestore-source:
kind: singlestore
host: 127.0.0.1
port: 3306
database: my_db
user: ${USER_NAME}
password: ${PASSWORD}
queryTimeout: 30s # Optional: query timeout duration
```

{{< notice tip >}}
Use environment variable replacement with the format ${ENV_NAME}
instead of hardcoding your secrets into the configuration file.
{{< /notice >}}

## Reference

| **field** | **type** | **required** | **description** |
| ------------ | :------: | :----------: | ----------------------------------------------------------------------------------------------- |
| kind | string | true | Must be "singlestore". |
| host | string | true | IP address to connect to (e.g. "127.0.0.1"). |
| port | string | true | Port to connect to (e.g. "3306"). |
| database | string | true | Name of the SingleStore database to connect to (e.g. "my_db"). |
| user | string | true | Name of the SingleStore database user to connect as (e.g. "admin"). |
| password | string | true | Password of the SingleStore database user. |
| queryTimeout | string | false | Maximum time to wait for query execution (e.g. "30s", "2m"). By default, no timeout is applied. |
7 changes: 7 additions & 0 deletions docs/en/resources/tools/singlestore/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "SingleStore"
type: docs
weight: 1
description: >
Tools that work with SingleStore Sources
---
41 changes: 41 additions & 0 deletions docs/en/resources/tools/singlestore/singlestore-execute-sql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: "singlestore-execute-sql"
type: docs
weight: 1
description: >
A "singlestore-execute-sql" tool executes a SQL statement against a SingleStore
database.
aliases:
- /resources/tools/singlestore-execute-sql
---

## About

A `singlestore-execute-sql` tool executes a SQL statement against a SingleStore
database. It's compatible with the following sources:

- [singlestore](../../sources/singlestore.md)

`singlestore-execute-sql` takes one input parameter `sql` and runs the sql
statement against the `source`.

> **Note:** This tool is intended for developer assistant workflows with
> human-in-the-loop and shouldn't be used for production agents.
## Example

```yaml
tools:
execute_sql_tool:
kind: singlestore-execute-sql
source: my-s2-instance
description: Use this tool to execute sql statement
```
## Reference
| **field** | **type** | **required** | **description** |
|-------------|:------------------------------------------:|:------------:|--------------------------------------------------------------------------------------------------|
| kind | string | true | Must be "singlestore-execute-sql". |
| source | string | true | Name of the source the SQL should execute on. |
| description | string | true | Description of the tool that is passed to the LLM. |
102 changes: 102 additions & 0 deletions docs/en/resources/tools/singlestore/singlestore-sql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: "singlestore-sql"
type: docs
weight: 1
description: >
A "singlestore-sql" tool executes a pre-defined SQL statement against a SingleStore
database.
aliases:
- /resources/tools/singlestore-sql
---

## About

A `singlestore-execute-sql` tool executes a SQL statement against a SingleStore
database. It's compatible with the following sources:

- [singlestore](../../sources/singlestore.md)

The specified SQL statement expects parameters in the SQL query to be in the form of placeholders `?`.

## Example

> **Note:** This tool uses parameterized queries to prevent SQL injections.
> Query parameters can be used as substitutes for arbitrary expressions.
> Parameters cannot be used as substitutes for identifiers, column names, table
> names, or other parts of the query.

```yaml
tools:
search_flights_by_number:
kind: singlestore-sql
source: my-s2-instance
statement: |
SELECT * FROM flights
WHERE airline = ?
AND flight_number = ?
LIMIT 10
description: |
Use this tool to get information for a specific flight.
Takes an airline code and flight number and returns info on the flight.
Do NOT use this tool with a flight id. Do NOT guess an airline code or flight number.
A airline code is a code for an airline service consisting of two-character
airline designator and followed by flight number, which is 1 to 4 digit number.
For example, if given CY 0123, the airline is "CY", and flight_number is "123".
Another example for this is DL 1234, the airline is "DL", and flight_number is "1234".
If the tool returns more than one option choose the date closes to today.
Example:
{{
"airline": "CY",
"flight_number": "888",
}}
Example:
{{
"airline": "DL",
"flight_number": "1234",
}}
parameters:
- name: airline
type: string
description: Airline unique 2 letter identifier
- name: flight_number
type: string
description: 1 to 4 digit number
```

### Example with Template Parameters

> **Note:** This tool allows direct modifications to the SQL statement,
> including identifiers, column names, and table names. **This makes it more
> vulnerable to SQL injections**. Using basic parameters only (see above) is
> recommended for performance and safety reasons. For more details, please check
> [templateParameters](..#template-parameters).

```yaml
tools:
list_table:
kind: singlestore-sql
source: my-s2-instance
statement: |
SELECT * FROM {{.tableName}};
description: |
Use this tool to list all information from a specific table.
Example:
{{
"tableName": "flights",
}}
templateParameters:
- name: tableName
type: string
description: Table to select from
```

## Reference

| **field** | **type** | **required** | **description** |
|--------------------|:------------------------------------------------:|:------------:|--------------------------------------------------------------------------------------------------------------------------------------------|
| kind | string | true | Must be "singlestore-sql". |
| source | string | true | Name of the source the SQL should execute on. |
| description | string | true | Description of the tool that is passed to the LLM. |
| statement | string | true | SQL statement to execute on. |
| parameters | [parameters](../#specifying-parameters) | false | List of [parameters](../#specifying-parameters) that will be inserted into the SQL statement. |
| templateParameters | [templateParameters](..#template-parameters) | false | List of [templateParameters](..#template-parameters) that will be inserted into the SQL statement before executing prepared statement. |
5 changes: 5 additions & 0 deletions internal/prebuiltconfigs/prebuiltconfigs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var expectedToolSources = []string{
"oceanbase",
"postgres",
"serverless-spark",
"singlestore",
"spanner-postgres",
"spanner",
"sqlite",
Expand Down Expand Up @@ -118,6 +119,7 @@ func TestGetPrebuiltTool(t *testing.T) {
mssql_config, _ := Get("mssql")
oceanbase_config, _ := Get("oceanbase")
postgresconfig, _ := Get("postgres")
singlestore_config, _ := Get("singlestore")
spanner_config, _ := Get("spanner")
spannerpg_config, _ := Get("spanner-postgres")
mindsdb_config, _ := Get("mindsdb")
Expand Down Expand Up @@ -190,6 +192,9 @@ func TestGetPrebuiltTool(t *testing.T) {
if len(postgresconfig) <= 0 {
t.Fatalf("unexpected error: could not fetch postgres prebuilt tools yaml")
}
if len(singlestore_config) <= 0 {
t.Fatalf("unexpected error: could not fetch singlestore prebuilt tools yaml")
}
if len(spanner_config) <= 0 {
t.Fatalf("unexpected error: could not fetch spanner prebuilt tools yaml")
}
Expand Down
Loading
Loading