Skip to content

Commit

Permalink
Refactor OpenAI adapter configuration and API key retrieval
Browse files Browse the repository at this point in the history
- Updated the OpenAI adapter settings structure to nest the API key under an 'openai' object for better organization.
- Enhanced the API key retrieval logic in the SmartEmbedModelApiAdapter to prioritize adapter-specific settings, improving flexibility in configuration.
- Removed the deprecated API key getter in the SmartEmbedOpenAIAdapter, streamlining the codebase.
  • Loading branch information
Brian Joseph Petro committed Dec 6, 2024
1 parent af78ec4 commit 9f74189
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
4 changes: 3 additions & 1 deletion smart-embed-model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ import { SmartEmbedOpenAIAdapter } from 'smart-embed-model/adapters/openai';
const model = new SmartEmbedModel({
model_key: 'text-embedding-3-small',
settings: {
openai_api_key: 'YOUR_API_KEY'
openai: {
api_key: 'YOUR_API_KEY'
}
},
adapters: {
openai: SmartEmbedOpenAIAdapter
Expand Down
2 changes: 1 addition & 1 deletion smart-embed-model/adapters/_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SmartEmbedModelApiAdapter extends SmartEmbedAdapter {
* @returns {string} API key
*/
get api_key() {
return this.settings.api_key || this.model_config.api_key;
return this.adapter_settings.api_key || this.settings.api_key || this.model_config.api_key;
}

/**
Expand Down
5 changes: 0 additions & 5 deletions smart-embed-model/adapters/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ export class SmartEmbedOpenAIAdapter extends SmartEmbedModelApiAdapter {
return SmartEmbedOpenAIResponseAdapter;
}

/** @returns {string} OpenAI API key */
get api_key() {
return this.settings.openai_api_key;
}

/** @returns {number} Maximum tokens per input */
get max_tokens() {
return this.model_config.max_tokens || 8191;
Expand Down

0 comments on commit 9f74189

Please sign in to comment.