-
Notifications
You must be signed in to change notification settings - Fork 1
[EVAL] API key from Env Var support #20
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
[EVAL] API key from Env Var support #20
Conversation
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
…ssage Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
…viders Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
OPENAI_API_KEY env var Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
whole process.env into webview Signed-off-by: Geoff Wilson <[email protected]>
of api key env var; use constants for env var keys. Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
errant keys in test file Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
vercel copy/pasta Signed-off-by: Geoff Wilson <[email protected]>
Signed-off-by: Geoff Wilson <[email protected]>
| FIREWORKS: 'FIREWORKS_API_KEY', | ||
| HUGGING_FACE: 'HUGGINGFACE_API_KEY', | ||
| IO_INTELLIGENCE: 'IOINTELLIGENCE_API_KEY', | ||
| MOONSHOOT: 'MOONSHOT_API_KEY', |
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.
Typo: MOONSHOOT should be MOONSHOT to match the environment variable name MOONSHOT_API_KEY. This typo will cause the constant to be named incorrectly throughout the codebase.
| </div> | ||
| <ApiKey | ||
| apiKey={apiConfiguration?.moonshotApiKey || ""} | ||
| apiKeyEnvVar={API_KEYS.MOONSHOOT} |
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.
Using typo MOONSHOOT instead of MOONSHOT. This references the misspelled constant from constants.ts line 25. Should be API_KEYS.MOONSHOT to correctly reference MOONSHOT_API_KEY.
| return new QwenCodeHandler(options) | ||
| case "moonshot": | ||
| if (options.moonshotConfigUseEnvVars) { | ||
| options.moonshotApiKey = getEnvVar(API_KEYS.MOONSHOOT, options.moonshotApiKey) |
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.
Using typo MOONSHOOT instead of MOONSHOT. This references the misspelled constant from constants.ts line 25. Should be API_KEYS.MOONSHOT to correctly reference MOONSHOT_API_KEY.
| }: ApiKeyProps) => { | ||
| const envVarExists = (window as any).ENV_VAR_EXISTS || {} | ||
| const apiKeyEnvVarExists = !!envVarExists[apiKeyEnvVar] | ||
| const [useEnvVar, setUseEnvVar] = useState(configUseEnvVars && apiKeyEnvVarExists) |
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.
Missing useEffect to sync local state with prop changes. The useEnvVar state is initialized from configUseEnvVars but won't update if the prop changes later (e.g., when switching between provider profiles). Add:
useEffect(() => {
setUseEnvVar(configUseEnvVars && apiKeyEnvVarExists)
}, [configUseEnvVars, apiKeyEnvVarExists])| @@ -0,0 +1,72 @@ | |||
| import { useState, ReactNode } from "react" | |||
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.
Missing useEffect import. The suggested fix in the comment on line 34 requires importing useEffect from React.
| const exists = !!process.env[envVar] | ||
| result[envVar] = exists | ||
| if (exists) { | ||
| console.log(`[ClineProvider] Found environment variable: ${envVar}`) |
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.
Use this.log() instead of console.log() for consistency with the rest of the ClineProvider class. The class has a dedicated logging method that outputs to both the output channel and console.
🧪 Evaluation PR for Testing
This is an automated test PR created for evaluation purposes.
Related GitHub Issue
Closes: #4337
Description
This PR adds support for obtaining API keys from the environment. A checkbox is added to each configuration that allows inputting an API key -- when checked, a given environment variable (eg, OPENAI_API_KEY, etc) is consulted for the key and the user is not required to provide one in the configuration. Env Var key is predictable but not editable.
Test Procedure
I tested this using VS Code run configurations, where the expected environment variable could be provided or omitted.
Pre-Submission Checklist
A documentation update is advised, to describe environment variable usage to supply API keys.
Summary
Adds support for using environment variables for API keys across multiple providers, updates UI components to reflect this, and enhances testing and translation capabilities.