-
Notifications
You must be signed in to change notification settings - Fork 297
fix: don't prompt for creds for local models #567
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
Conversation
Signed-off-by: Grant Linville <[email protected]>
var env map[string]string | ||
if err := json.Unmarshal([]byte(authCfg.Password), &env); err != nil { | ||
return Credential{}, err | ||
if authCfg.Password != "" { |
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.
This fixes a bug where we would try to unmarshal an empty string.
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) |
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.
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
.
@@ -108,7 +108,7 @@ func (c *Client) clientFromURL(ctx context.Context, apiURL string) (*openai.Clie | |||
env := "GPTSCRIPT_PROVIDER_" + env2.ToEnvLike(parsed.Hostname()) + "_API_KEY" | |||
key := os.Getenv(env) | |||
|
|||
if key == "" { | |||
if key == "" && !isLocalhost(apiURL) { |
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.
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.
if alias != "" && !isAlphaNumeric(alias) { | ||
return "", "", nil, fmt.Errorf("credential alias must be alphanumeric") | ||
} |
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 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.
Signed-off-by: Grant Linville <[email protected]>
for #509
Details in comments.