Skip to content

Conversation

@g-linville
Copy link
Member

@g-linville g-linville commented Jun 26, 2024

for #509

Details in comments.

Signed-off-by: Grant Linville <grant@acorn.io>
var env map[string]string
if err := json.Unmarshal([]byte(authCfg.Password), &env); err != nil {
return Credential{}, err
if authCfg.Password != "" {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a bug where we would try to unmarshal an empty string.

Comment on lines +77 to 87
toolURL, err := url.Parse(toolName)
if err != nil {
return nil, err
}

// Save the path so we can put it back after removing it.
path := toolURL.Path
toolURL.Path = ""

toolName = toolURL.String() + ":" + possiblePortNumber + path
ctx = strings.TrimSuffix(ctx, ":"+possiblePortNumber)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a bug where we were putting the port after the path.
I.e., the string we're trying to fix is http://localhost/v1///default:5555 and we used to make it become http://localhost/v1:5555 rather than http://localhost:5555/v1.

key := os.Getenv(env)

if key == "" {
if key == "" && !isLocalhost(apiURL) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we no longer look for the credential in the store if the model is running locally. Not sure whether we care to support IPv6 (::1) here, but I can add that if we do.

Comment on lines +287 to +289
if alias != "" && !isAlphaNumeric(alias) {
return "", "", nil, fmt.Errorf("credential alias must be alphanumeric")
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to add a constraint that a credential alias needs to be alphanumeric. This is to avoid interfering with credentials for model providers and such.

@g-linville g-linville marked this pull request as ready for review June 26, 2024 19:45
Signed-off-by: Grant Linville <grant@acorn.io>
@g-linville g-linville requested a review from njhale June 26, 2024 19:54
@g-linville g-linville merged commit bcd9f33 into gptscript-ai:main Jun 27, 2024
@g-linville g-linville deleted the fix-local-prompting branch June 27, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants