Skip to content

SDKs need to support credential-override #553

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

Closed
cloudnautique opened this issue Jun 25, 2024 · 8 comments
Closed

SDKs need to support credential-override #553

cloudnautique opened this issue Jun 25, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@cloudnautique
Copy link
Contributor

We transitioned to using credentials for some of our tools, image-generation in particular, and when they are consumed programmatically through the APIs there is no way to programmatically set the credentials today.

The CLI supports both an environment variable and CLI argument approach. Both should be supported, but if one needs to be picked the CLI flag should be passable as a runtime option and the programming language can pull env vars and set them.

Today the environment variable is not picked for whatever reason, and there is no way to pass the CLI flag.

We need to provide a way to set this up.

@njhale
Copy link
Member

njhale commented Jul 2, 2024

@sangee2004 this is implemented in all SDKs as of v0.9.1.

@sangee2004
Copy link
Contributor

sangee2004 commented Jul 2, 2024

Tested with gptscript version v0.0.0-dev-134dcde9-dirty

  1. go SDK testing using TUI

I dont have openai key set (as credential or env variable) and I set it using credential-override when executing chat script that has image-generation tool using claude provider. I am still prompted for entering openai keys which should not be the case.

Following script was executed using - gptscript --default-model 'claude-3-5-sonnet-20240620 from github.com/gptscript-ai/claude3-anthropic-provider' --credential-override sys.openai:OPENAI_API_KEY=sk-**** --disable-cache imagechat.gpt

tools: github.com/gptscript-ai/dalle-image-generation, sys.download
chat: true

You are a good assistant. Wait for user to ask you for help.
 %gptscript --default-model 'claude-3-5-sonnet-20240620 from github.com/gptscript-ai/claude3-anthropic-provider' --credential-override sys.openai:OPENAI_API_KEY=sk-**** --disable-cache imagechat.gpt
12:36:18 WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.

  Certainly! I'm here and ready to assist. I'll wait for the user to ask for help or pose a question. When they do, I'll do my best to provide helpful and accurate information, using the available     
  tools when appropriate. Please feel free to ask anything when you're ready.                                                                                                                            

> Generate an image of rising sun

    ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Call Arguments:                                                                                                                                  │
    │                                                                                                                                                  │
    │ dalleImageGeneration {"prompt": "A beautiful image of a rising sun over the horizon, with warm orange and yellow hues spreading across the sky"} │
    └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
                                                                                                                                                        
Please provide your OpenAI API key
  1. node SDK testing using --ui

Executing the same script from above using "--ui" option also results in user being prompted to enter openai key which should not be the case.

Note - I am able to see credential-override feature work as expected in ui and tui when I have GPTSCRIPT_SDKSERVER_CREDENTIAL_OVERRIDE env variable set.

@sangee2004
Copy link
Contributor

Fixes for credential-override to work with ui and tui
#604 (UI)
gptscript-ai/tui#2 (TUI 1/2)
#605 (TUI 2/2)

@sangee2004
Copy link
Contributor

Tested with gptscript version - v0.0.0-dev-a0013e45-dirty

Able to see --credential-override take effect when testing with --ui option.

@sangee2004
Copy link
Contributor

Tested with gptscript version - v0.0.0-dev-3b38281a-dirty

Able to see --credential-override work as expected when testing with TUI.

@sangee2004
Copy link
Contributor

sangee2004 commented Jul 3, 2024

Tested with gptscript version - v0.0.0-dev-3b38281a-dirty

Able to use GPTSCRIPT_CREDENTIAL_OVERRIDE env variable to set credentials and not be prompted for the credentials when scripts requiring the credentials are executed using TUI or --ui option.

@sangee2004
Copy link
Contributor

sangee2004 commented Jul 12, 2024

When executing scripts using Node SDK, credential overrides can be set using credentialOverrides parameter .
Example usage:

        const run = await g.run('./image.gpt', { disableCache: true,
    				credentialOverrides: ["sys.openai:OPENAI_API_KEY"],

Note - Setting GPTSCRIPT_CREDENTIAL_OVERRIDE environment variable as alternative to using credentialOverrides parameter will not work in this case.
Setting GPTSCRIPT_SDKSERVER_CREDENTIAL_OVERRIDE environment variable does works in this case.

@njhale
Copy link
Member

njhale commented Jul 15, 2024

Note - Setting GPTSCRIPT_CREDENTIAL_OVERRIDE environment variable as alternative to using credentialOverrides parameter will not work in this case.

AFAIK this is expected. As of now, I'm not aware of a requirement for the SDKs to have first-class support for GPTSCRIPT_* environment variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants