Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@
"default": 0,
"description": "Starting point of the column containing the tag description (if any, e.g. AI-generated).\n0 to make it adaptive (default, no alignment), a positive number to fix the starting point.\nNote that if the tag previous values take over the specified starting point, the column will be shifted."
},
"jsdoc-generator.generativeEndpoint": {
"type": "string",
"default": "",
"description": "Set your own OpenAI server endpoint for generative AI.\nIt's required only if you wish to use the automatic generation of descriptions."
Comment thread
ITsPro-CN marked this conversation as resolved.
},
"jsdoc-generator.generativeApiKey": {
"type": "string",
"default": "",
Expand All @@ -176,6 +181,7 @@
"jsdoc-generator.generativeModel": {
"type": "string",
"enum": [
"custom",
"gpt-5",
"gpt-5-mini",
"gpt-5-nano",
Expand All @@ -188,7 +194,12 @@
"gpt-o3-mini"
],
"default": "gpt-5",
"description": "Generative AI model to use to generate JSDoc decriptions.\nCurrently, only OpenAI models are supported.\nEnable the model with an API key."
"description": "Generative AI model to use to generate JSDoc decriptions.\nFor more models, please select 'custom'.\nEnable the model with an API key."
},
"jsdoc-generator.generativeModelCustom": {
"type": "string",
"default": "",
Comment thread
ITsPro-CN marked this conversation as resolved.
"description": "Custom generative AI model to use to generate JSDoc decriptions. Only Enabled while generativeModel select 'custom'."
Comment thread
ITsPro-CN marked this conversation as resolved.
Outdated
Comment thread
ITsPro-CN marked this conversation as resolved.
Outdated
},
"jsdoc-generator.generativeLanguage": {
"type": "string",
Expand Down
21 changes: 18 additions & 3 deletions src/GenerativeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ abstract class GenerativeModel<T> {
return getConfig('generativeLanguage', 'English');
}

/**
* AI endpoint.
*
* @protected
* @readonly
* @type {string}
*/
protected get baseURL() {
return getConfig('generativeEndpoint', '://api.openai.com/v1');
Comment thread
ITsPro-CN marked this conversation as resolved.
}

/**
* Model kind.
*
Expand All @@ -41,7 +52,9 @@ abstract class GenerativeModel<T> {
* @type {Model}
*/
protected get model() {
return getConfig('generativeModel', 'gpt-5');
const model = getConfig('generativeModel', 'gpt-5');
if (model === 'custom') { return getConfig('generativeModelCustom', 'gpt-5'); }
Comment thread
ITsPro-CN marked this conversation as resolved.
return model;
}

/**
Expand Down Expand Up @@ -123,7 +136,7 @@ class GenerativeOpenAI extends GenerativeModel<OpenAI> {
* @override
*/
protected override init(): OpenAI {
return new OpenAI({apiKey: this.apiKey});
return new OpenAI({baseURL: this.baseURL, apiKey: this.apiKey});
}
Comment thread
ITsPro-CN marked this conversation as resolved.

/**
Expand Down Expand Up @@ -432,7 +445,9 @@ class GenerativeAPI {
* @type {Model}
*/
protected get model() {
return getConfig('generativeModel', 'gpt-5');
const model = getConfig('generativeModel', 'gpt-5');
if (model === 'custom') { return getConfig('generativeModelCustom', 'gpt-5'); }
return model;
}
Comment thread
ITsPro-CN marked this conversation as resolved.

/**
Expand Down
14 changes: 13 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type NodeType = 'function' | 'class' | 'interface' | 'type' | 'enum' | 'property
*
* @typedef {Model}
*/
type Model = 'gpt-5' | 'gpt-5-mini' | 'gpt-5-nano' | 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4o' | 'gpt-4o-mini' | 'gpt-o3' | 'gpt-o3-mini';
type Model = string;

/**
* JSDoc custom tag.
Expand Down Expand Up @@ -198,6 +198,12 @@ interface Configuration {
* @type {number}
*/
tagDescriptionColumnStart: number;
/**
* Generative AI Endpoint.
*
* @type {string}
*/
generativeEndpoint: string;
/**
* Generative AI API key.
*
Expand All @@ -210,6 +216,12 @@ interface Configuration {
* @type {Model}
*/
generativeModel: Model;
/**
* Generative AI model.
*
* @type {Model}
*/
generativeModelCustom: Model;
Comment thread
ITsPro-CN marked this conversation as resolved.
/**
* Language of the generated descriptions.
*
Expand Down
Loading