-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple tool registries #1193
Support multiple tool registries #1193
Conversation
dbd6582
to
d9f6434
Compare
9682fd7
to
2c704cd
Compare
4c2258b
to
c928b8f
Compare
Still need to test the workflow, but I think this is ready for some reviews. See this commit message for an example of how to build the enterprise image locally. You'll need to tweak the docker build --build-arg TOOL_REGISTRY_REPOS='github.com/njhale/enterprise-tools,github.com/njhale/tools' \
--secret id=GITHUB_TOKEN \
-t obot-enterprise:latest . |
We'll also want to disable model providers and oauthapps in the UI when their tools aren't present. We don't want to show the options for the "OSS" build if you can't use them. |
1. Clone `github.com/obot-platform/tools` to your local machine. | ||
2. In the root directory of the tools repo on your local machine, run `make build`. | ||
3. Run the Obot server, either with `make dev` or in your IDE, with the `OBOT_SERVER_TOOL_REGISTRY` environment variable set to the root directory of the tools repo. | ||
3. Run the Obot server, either with `make dev` or in your IDE, with the `GPTSCRIPT_TOOL_REMAP` environment variable set to `github.com/obot-platform/tools=<local-tools-fork-root-directory>`; e.g. If you cloned the tools repo to the directory "above" the Obot repo, you'd use `GPTSCRIPT_TOOL_REMAP='github.com/obot-platform/tools=../tools' make dev`. | ||
|
||
Now, any time one of these tools is run, your local copy will be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about putting the docs for developing for "enterprise" in the enterprise-tools repo. LMK if folks would prefer it here in the obot repo instead.
@@ -88,7 +95,33 @@ func setupSQLite(toolRegistry, dsn string) (string, []string, error) { | |||
|
|||
dbFile = strings.TrimSuffix(dbFile, ".db") + "-credentials.db" | |||
|
|||
return toolRegistry + "/credential-stores/sqlite", []string{ | |||
toolRef, err := resolveToolRef(toolRegistries, "credential-stores/sqlite") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do this because we're not guaranteed that the default tool registry is present in toolRegistries
, so we make a best-effort attempt to find the required credential-stores
tools in the available registries.
WorkspaceTool string `usage:"The tool reference for the workspace provider" default:"github.com/gptscript-ai/workspace-provider"` | ||
DatasetsTool string `usage:"The tool reference for the dataset provider" default:"github.com/gptscript-ai/datasets"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are being removed because they can now be remapped directly with the GPTSCRIPT_TOOL_REMAP
environment variable; e.g. export GPTSCRIPT_TOOL_REMAP=github.com/gptscript-ai/workspace-provider=../tools/workspace-provider
@@ -201,7 +194,11 @@ func New(ctx context.Context, config Config) (*Services, error) { | |||
// that use postgres | |||
config.DSN = strings.Replace(config.DSN, "postgresql://", "postgres://", 1) | |||
|
|||
credStore, credStoreEnv, err := credstores.Init(ctx, config.ToolRegistry, config.DSN, credstores.Options{ | |||
if len(config.ToolRegistries) < 1 { | |||
config.ToolRegistries = []string{"github.com/obot-platform/tools"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github.com/gptscript-ai/cmd
's struct tag defaulting for []slice
types doesn't work. Setting it here until I can push a fix to that package.
cd obot-tools | ||
cat <<EOF > .envrc.tools | ||
export GPTSCRIPT_SYSTEM_TOOLS_DIR=/obot-tools/ | ||
export GPTSCRIPT_TOOL_REMAP="$(IFS=','; echo "${REGISTRY_REMAP[*]}")" | ||
export OBOT_SERVER_TOOL_REGISTRIES="${TOOL_REGISTRY_REPOS}" | ||
export OBOT_SERVER_VERSIONS="${OBOT_SERVER_VERSIONS}" | ||
export TOOLS_VENV_BIN=/obot-tools/venv/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not the prettiest solution -- and breaks outside the context of the container image since all the paths assume are absolute off of the root dir -- but I think it de-spaghettifies the construction of these settings a bit
c928b8f
to
addb333
Compare
addb333
to
2868c13
Compare
Support consuming tools from more than one tool registry at a time. Replaces the `OBOT_SERVER_TOOL_REGISTRY` option with `OBOT_SERVER_TOOL_REGISTRIES`. The new option accepts a comma-delimited string of registry URIs. e.g. ```bash export OBOT_SERVER_TOOL_REGISTRIES='github.com/obot-platform/tools,github.com/obot-platform/enterprise-tools'` ``` When overriding a remote registry with a directory in the local filesystem, the `GPTSCRIPT_TOOL_REMAP` environment variable is used to provide tool reference remapping in GPTScript/Obot. e.g. Replacing `github.com/obot-platform/tools` with `../tools`: ```bash export GPTSCRIPT_TOOL_REMAP='github.com/obot-platform/tools=../tools' ``` e.g. Replacing `github.com/obot-platform/tools` with `../tools` and `github.com/obot-platform/enterprise-tools` with `../enterprise-tools`: ```bash export GPTSCRIPT_TOOL_REMAP='github.com/obot-platform/tools=../tools,github.com/obot-platform/enterprise-tools=../enterprise-tools' export OBOT_SERVER_TOOL_REGISTRIES='github.com/obot-platform/tools,github.com/obot-platform/enterprise-tools'` ``` Note: - `OBOT_SERVER_TOOL_REGISTRIES` should always reference remote tool registry repos, never local file paths - Only `GPTSCRIPT_TOOL_REMAP` needs to be set to swap the default tool registry (`github.com/obot-platform/tools`) with a local fork Signed-off-by: Nick Hale <[email protected]>
Add support for: - Pulling multiple tool registries into the image at build-time via the `TOOL_REGISTY_REPOS` build arg - Cloning private tool registry repos via the `GITHUB_TOKEN` Docker secret e.g. Building the "enterprise" Obot image ```bash export GITHUB_TOKEN=$(gh auth token) docker build --build-arg TOOL_REGISTRY_REPOS='github.com/obot-platform/enterprise-tools,github.com/obot-platform/tools' \ --secret id=GITHUB_TOKEN \ -t obot-enterprise:latest . ``` Signed-off-by: Nick Hale <[email protected]>
2868c13
to
3590aed
Compare
This change adds support for consuming tools from more than one tool registry at a time.
It replaces the
OBOT_SERVER_TOOL_REGISTRY
option withOBOT_SERVER_TOOL_REGISTRIES
. The new option accepts a comma-delimited string of registry URIs.e.g.
When overriding a remote registry with a directory in the local filesystem, the
GPTSCRIPT_TOOL_REMAP
environment variable is used to provide tool reference remapping in GPTScript/Obot.e.g. Replacing
github.com/obot-platform/tools
with../tools
:e.g. Replacing
github.com/obot-platform/tools
with../tools
andgithub.com/obot-platform/enterprise-tools
with../enterprise-tools
:Note:
OBOT_SERVER_TOOL_REGISTRIES
should always reference remote tool registry repos, never local file pathsGPTSCRIPT_TOOL_REMAP
needs to be set to swap the default tool registry (github.com/obot-platform/tools
) with a local forkThis change also updates the container image build to support
TOOL_REGISTY_REPOS
build argGITHUB_TOKEN
Docker secrete.g. Building the "enterprise" Obot image
e.g. Building the "OSS" Obot image
Part of #877