-
Notifications
You must be signed in to change notification settings - Fork 286
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
feat: add stacked credential contexts #849
Merged
g-linville
merged 9 commits into
gptscript-ai:main
from
g-linville:stacked-credential-contexts
Sep 18, 2024
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2ce546c
WIP: stacked credential contexts
g-linville c329336
feedback from Darren
g-linville 318a1a8
fixes
g-linville 0b9fddf
gen-docs
g-linville cc244eb
tweaks
g-linville 92e81dd
docs
g-linville d2442f4
add integration test
g-linville 12999ac
PR feedback
g-linville c085b9b
PR feedback
g-linville File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: testcred_one | ||
credential: cred_one as testcred | ||
|
||
#!python3 | ||
|
||
import os | ||
|
||
print(os.environ.get("VALUE")) | ||
|
||
--- | ||
name: testcred_two | ||
credential: cred_two as testcred | ||
|
||
#!python3 | ||
|
||
import os | ||
|
||
print(os.environ.get("VALUE")) | ||
|
||
--- | ||
name: cred_one | ||
|
||
#!python3 | ||
|
||
import json | ||
|
||
print(json.dumps({"env": {"VALUE": "one"}})) | ||
|
||
--- | ||
name: cred_two | ||
|
||
#!python3 | ||
|
||
import json | ||
|
||
print(json.dumps({"env": {"VALUE": "two"}})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ type GPTScript struct { | |
Chdir string `usage:"Change current working directory" short:"C"` | ||
Daemon bool `usage:"Run tool as a daemon" local:"true" hidden:"true"` | ||
Ports string `usage:"The port range to use for ephemeral daemon ports (ex: 11000-12000)" hidden:"true"` | ||
CredentialContext string `usage:"Context name in which to store credentials" default:"default"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our |
||
CredentialContext []string `usage:"Context name(s) in which to store credentials"` | ||
CredentialOverride []string `usage:"Credentials to override (ex: --credential-override github.com/example/cred-tool:API_TOKEN=1234)"` | ||
ChatState string `usage:"The chat state to continue, or null to start a new chat and return the state" local:"true"` | ||
ForceChat bool `usage:"Force an interactive chat session if even the top level tool is not a chat tool" local:"true"` | ||
|
@@ -142,7 +142,7 @@ func (r *GPTScript) NewGPTScriptOpts() (gptscript.Options, error) { | |
}, | ||
Quiet: r.Quiet, | ||
Env: os.Environ(), | ||
CredentialContext: r.CredentialContext, | ||
CredentialContexts: r.CredentialContext, | ||
Workspace: r.Workspace, | ||
DisablePromptServer: r.UI, | ||
DefaultModelProvider: r.DefaultModelProvider, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There are a few places where you have added this logic. Can this logic be moved to the
Complete
function for the gptscript options instead?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.
I think it already is in the Complete function in the
gptscript/gptscript.go
file. But without it in places like this, thec.root.CredentialContext
still ends up being empty when the user doesn't specify anything. Not sure why that's the case. Should I be manually calling the Complete function here?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.
I'm surprised this isn't working as I expect, then.
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.
I took a longer look at this: instead of completing the entire
opts
(created on line 53), we are completing individual pieces of it (lines 55 and 56).It would be better to complete everything instead of the individual pieces, but I won't hold up merging this based on that.
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.
Sweet, that worked. Thanks. I should have spent more time looking at this myself, lol