@xpert-ai/plugin-openai 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,98 @@
1
+ # https://developers.openai.com/api/docs/models/gpt-6.2-astra
2
+ model: gpt-6.2-astra
3
+ native_protocols:
4
+ - openai_responses
5
+ label:
6
+ en_US: GPT-6.2 Astra
7
+ zh_Hans: GPT-6.2 Astra
8
+ model_type: llm
9
+ features:
10
+ - agent-thought
11
+ - tool-call
12
+ - multi-tool-call
13
+ - stream-tool-call
14
+ - structured-output
15
+ - vision
16
+ model_properties:
17
+ mode: chat
18
+ context_size: 1050000
19
+ max_output: 128000
20
+ parameter_rules:
21
+ - name: max_tokens
22
+ use_template: max_tokens
23
+ default: 32768
24
+ min: 16
25
+ max: 128000
26
+ help:
27
+ en_US: Maximum output tokens, including reasoning tokens. Input and output must fit within the context window.
28
+ zh_Hans: 最大输出 Token 数,包含推理 Token;输入和输出合计须在上下文窗口内。
29
+ - name: reasoning_effort
30
+ label:
31
+ en_US: Reasoning Effort
32
+ zh_Hans: 推理力度
33
+ type: string
34
+ required: false
35
+ default: medium
36
+ options:
37
+ - low
38
+ - medium
39
+ - high
40
+ - xhigh
41
+ - max
42
+ help:
43
+ en_US: Higher effort can improve reasoning at the cost of latency and output tokens. Sampling parameters apply only with none.
44
+ zh_Hans: 更高档位可增强推理,但会增加延迟和输出 Token;采样参数仅在 none 档位生效。
45
+ - name: response_format
46
+ label:
47
+ en_US: Response Format
48
+ zh_Hans: 回复格式
49
+ type: string
50
+ required: false
51
+ options:
52
+ - text
53
+ - json_object
54
+ pricing:
55
+ input: '8'
56
+ output: '40'
57
+ unit: '0.000001'
58
+ currency: USD
59
+ tiered_pricing:
60
+ - input: 8
61
+ output: 40
62
+ max_tokens: 272000
63
+ - input: 16
64
+ output: 60.0
65
+ max_tokens: 1050000
66
+ rules:
67
+ - component: input
68
+ unit_price: 8
69
+ unit_size: 1000000
70
+ max_input_tokens: 272000
71
+ - component: output
72
+ unit_price: 40
73
+ unit_size: 1000000
74
+ max_input_tokens: 272000
75
+ - component: cache_read_input
76
+ unit_price: 0.4
77
+ unit_size: 1000000
78
+ max_input_tokens: 272000
79
+ - component: cache_write_input
80
+ unit_price: 10.0
81
+ unit_size: 1000000
82
+ max_input_tokens: 272000
83
+ - component: input
84
+ unit_price: 16
85
+ unit_size: 1000000
86
+ min_input_tokens: 272001
87
+ - component: output
88
+ unit_price: 60.0
89
+ unit_size: 1000000
90
+ min_input_tokens: 272001
91
+ - component: cache_read_input
92
+ unit_price: 0.8
93
+ unit_size: 1000000
94
+ min_input_tokens: 272001
95
+ - component: cache_write_input
96
+ unit_price: 20.0
97
+ unit_size: 1000000
98
+ min_input_tokens: 272001
@@ -0,0 +1,98 @@
1
+ # https://developers.openai.com/api/docs/models/gpt-6.2-sol
2
+ model: gpt-6.2-sol
3
+ native_protocols:
4
+ - openai_responses
5
+ label:
6
+ en_US: GPT-6.2 Sol
7
+ zh_Hans: GPT-6.2 Sol
8
+ model_type: llm
9
+ features:
10
+ - agent-thought
11
+ - tool-call
12
+ - multi-tool-call
13
+ - stream-tool-call
14
+ - structured-output
15
+ - vision
16
+ model_properties:
17
+ mode: chat
18
+ context_size: 1050000
19
+ max_output: 128000
20
+ parameter_rules:
21
+ - name: max_tokens
22
+ use_template: max_tokens
23
+ default: 32768
24
+ min: 16
25
+ max: 128000
26
+ help:
27
+ en_US: Maximum output tokens, including reasoning tokens. Input and output must fit within the context window.
28
+ zh_Hans: 最大输出 Token 数,包含推理 Token;输入和输出合计须在上下文窗口内。
29
+ - name: reasoning_effort
30
+ label:
31
+ en_US: Reasoning Effort
32
+ zh_Hans: 推理力度
33
+ type: string
34
+ required: false
35
+ default: medium
36
+ options:
37
+ - low
38
+ - medium
39
+ - high
40
+ - xhigh
41
+ - max
42
+ help:
43
+ en_US: Higher effort can improve reasoning at the cost of latency and output tokens. Sampling parameters apply only with none.
44
+ zh_Hans: 更高档位可增强推理,但会增加延迟和输出 Token;采样参数仅在 none 档位生效。
45
+ - name: response_format
46
+ label:
47
+ en_US: Response Format
48
+ zh_Hans: 回复格式
49
+ type: string
50
+ required: false
51
+ options:
52
+ - text
53
+ - json_object
54
+ pricing:
55
+ input: '2'
56
+ output: '10'
57
+ unit: '0.000001'
58
+ currency: USD
59
+ tiered_pricing:
60
+ - input: 2
61
+ output: 10
62
+ max_tokens: 272000
63
+ - input: 4
64
+ output: 15.0
65
+ max_tokens: 1050000
66
+ rules:
67
+ - component: input
68
+ unit_price: 2
69
+ unit_size: 1000000
70
+ max_input_tokens: 272000
71
+ - component: output
72
+ unit_price: 10
73
+ unit_size: 1000000
74
+ max_input_tokens: 272000
75
+ - component: cache_read_input
76
+ unit_price: 0.1
77
+ unit_size: 1000000
78
+ max_input_tokens: 272000
79
+ - component: cache_write_input
80
+ unit_price: 2.5
81
+ unit_size: 1000000
82
+ max_input_tokens: 272000
83
+ - component: input
84
+ unit_price: 4
85
+ unit_size: 1000000
86
+ min_input_tokens: 272001
87
+ - component: output
88
+ unit_price: 15.0
89
+ unit_size: 1000000
90
+ min_input_tokens: 272001
91
+ - component: cache_read_input
92
+ unit_price: 0.2
93
+ unit_size: 1000000
94
+ min_input_tokens: 272001
95
+ - component: cache_write_input
96
+ unit_price: 5.0
97
+ unit_size: 1000000
98
+ min_input_tokens: 272001
@@ -1 +1 @@
1
- {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/llm/llm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAmB,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEpE,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAIL,iBAAiB,EAMlB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAOhE,qBACa,wBAAyB,SAAQ,kBAAkB;;aAGhC,aAAa,EAAE,sBAAsB;gBAArC,aAAa,EAAE,sBAAsB;IAI7D,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBvF,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,oBAAoB;IAInB,YAAY,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,iBAAiB;CA+D/E"}
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/llm/llm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAmB,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEpE,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAIL,iBAAiB,EAMlB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAOhE,qBACa,wBAAyB,SAAQ,kBAAkB;;aAGhC,aAAa,EAAE,sBAAsB;gBAArC,aAAa,EAAE,sBAAsB;IAI7D,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBvF,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,oBAAoB;IAInB,YAAY,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,iBAAiB;CA6D/E"}
package/dist/llm/llm.js CHANGED
@@ -54,8 +54,8 @@ let OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = class OpenAILargeLan
54
54
  const model = copilotModel.model;
55
55
  const hasCustomEndpoint = !!credentials?.endpoint_url?.trim();
56
56
  const streaming = modelOptions?.streaming ?? !hasCustomEndpoint;
57
- const supportsSamplingParams = shouldEnableSamplingParameters(credentials?.sampling_parameters, params.configuration?.baseURL, model);
58
57
  const reasoningEffort = normalizeOpenAIReasoningEffort(model, modelOptions?.reasoning_effort);
58
+ const supportsSamplingParams = shouldEnableSamplingParameters(credentials?.sampling_parameters, params.configuration?.baseURL, model, reasoningEffort);
59
59
  const reasoning = this.getReasoningOptions(model, reasoningEffort);
60
60
  const langChainReasoning = this.toLangChainReasoning(reasoning);
61
61
  const supportsResponseFormat = shouldEnableResponseFormat(params.configuration?.baseURL, model);
@@ -74,15 +74,12 @@ let OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = class OpenAILargeLan
74
74
  maxRetries: modelOptions?.maxRetries,
75
75
  useResponsesApi: true,
76
76
  reasoning: langChainReasoning,
77
- responses: new OpenAIReasoningResponsesModel({
78
- ...params,
79
- model,
80
- reasoning: langChainReasoning
81
- }),
82
77
  streamUsage: streaming,
83
78
  }, isNil);
84
79
  const chatModel = new ChatOpenAI({
85
80
  ...fields,
81
+ // Custom Responses instances do not inherit ChatOpenAI constructor fields.
82
+ responses: new OpenAIReasoningResponsesModel(fields),
86
83
  verbose: options?.verbose,
87
84
  callbacks: [
88
85
  ...this.createHandleUsageCallbacks(copilot, model, credentials, handleLLMTokens),
@@ -2,6 +2,8 @@ import { AIMessage } from '@langchain/core/messages';
2
2
  import { ChatGenerationChunk } from '@langchain/core/outputs';
3
3
  import { ChatOpenAIResponses, OpenAIClient } from '@langchain/openai';
4
4
  export declare class OpenAIReasoningResponsesModel extends ChatOpenAIResponses {
5
+ protected _getReasoningParams(options?: this['ParsedCallOptions']): OpenAIClient.Reasoning | undefined;
6
+ invocationParams(options?: this['ParsedCallOptions']): ReturnType<ChatOpenAIResponses['invocationParams']>;
5
7
  protected _convertResponsesMessageToBaseMessage(response: OpenAIClient.Responses.Response): AIMessage;
6
8
  protected _convertResponsesDeltaToBaseMessageChunk(chunk: OpenAIClient.Responses.ResponseStreamEvent): ChatGenerationChunk | null;
7
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"reasoning.d.ts","sourceRoot":"","sources":["../../src/llm/reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAwCrE,qBAAa,6BAA8B,SAAQ,mBAAmB;cACjD,qCAAqC,CACtD,QAAQ,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ;cAexB,wCAAwC,CACzD,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,mBAAmB,GAChD,mBAAmB,GAAG,IAAI;CAqB9B"}
1
+ {"version":3,"file":"reasoning.d.ts","sourceRoot":"","sources":["../../src/llm/reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAkDrE,qBAAa,6BAA8B,SAAQ,mBAAmB;cACjD,mBAAmB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,GAAG,YAAY,CAAC,SAAS,GAAG,SAAS;IAQtG,gBAAgB,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,GAAG,UAAU,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;cAShG,qCAAqC,CACtD,QAAQ,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ;cAgBxB,wCAAwC,CACzD,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,mBAAmB,GAChD,mBAAmB,GAAG,IAAI;CAwB9B"}
@@ -1,4 +1,5 @@
1
1
  import { ChatOpenAIResponses } from '@langchain/openai';
2
+ import { getSupportedOpenAIReasoningEfforts, shouldEnableSamplingParameters } from '../types.js';
2
3
  function extractReasoningSummaryText(reasoning) {
3
4
  if (!reasoning || typeof reasoning !== 'object') {
4
5
  return undefined;
@@ -22,9 +23,34 @@ function extractReasoningDeltaText(chunk) {
22
23
  }
23
24
  return undefined;
24
25
  }
26
+ function normalizeResponseUsage(usage) {
27
+ if (!usage)
28
+ return undefined;
29
+ return {
30
+ ...usage,
31
+ ...(usage.input_tokens_details ? { input_token_details: { cache_read: usage.input_tokens_details.cached_tokens } } : {}),
32
+ ...(usage.output_tokens_details ? { output_token_details: { reasoning: usage.output_tokens_details.reasoning_tokens } } : {})
33
+ };
34
+ }
25
35
  export class OpenAIReasoningResponsesModel extends ChatOpenAIResponses {
36
+ _getReasoningParams(options) {
37
+ // LangChain 0.6.9 only recognizes GPT-5/o-series reasoning; use our explicit catalog.
38
+ if (getSupportedOpenAIReasoningEfforts(this.model)) {
39
+ return { ...this.reasoning, ...options?.reasoning };
40
+ }
41
+ return super._getReasoningParams(options);
42
+ }
43
+ invocationParams(options) {
44
+ const params = super.invocationParams(options);
45
+ if (!shouldEnableSamplingParameters('enabled', this.clientConfig.baseURL, this.model, params.reasoning?.effort)) {
46
+ delete params.temperature;
47
+ delete params.top_p;
48
+ }
49
+ return params;
50
+ }
26
51
  _convertResponsesMessageToBaseMessage(response) {
27
52
  const message = super._convertResponsesMessageToBaseMessage(response);
53
+ message.usage_metadata = normalizeResponseUsage(response.usage);
28
54
  const reasoningContent = extractReasoningSummaryText(message.additional_kwargs?.reasoning);
29
55
  if (reasoningContent) {
30
56
  message.additional_kwargs = {
@@ -40,6 +66,9 @@ export class OpenAIReasoningResponsesModel extends ChatOpenAIResponses {
40
66
  return null;
41
67
  }
42
68
  const message = generationChunk.message;
69
+ if (chunk.type === 'response.completed') {
70
+ message.usage_metadata = normalizeResponseUsage(chunk.response.usage);
71
+ }
43
72
  const reasoningContent = extractReasoningDeltaText(chunk) ?? extractReasoningSummaryText(message.additional_kwargs?.reasoning);
44
73
  if (reasoningContent) {
45
74
  message.additional_kwargs = {
package/dist/openai.yaml CHANGED
@@ -3,8 +3,8 @@ label:
3
3
  en_US: OpenAI
4
4
  zh_Hans: OpenAI
5
5
  description:
6
- en_US: OpenAI GPT-5 and GPT-5.4 model service via Responses API.
7
- zh_Hans: OpenAI GPT-5 与 GPT-5.4 模型服务,通过 Responses API 提供。
6
+ en_US: OpenAI GPT-6 and GPT-5 model service via Responses API.
7
+ zh_Hans: OpenAI GPT-6 与 GPT-5 模型服务,通过 Responses API 提供。
8
8
  icon_small:
9
9
  en_US: icon_s_en.svg
10
10
  icon_large:
@@ -1 +1 @@
1
- {"version":3,"file":"provider.strategy.d.ts","sourceRoot":"","sources":["../src/provider.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,wBAAwB,EAAsB,MAAM,sBAAsB,CAAA;AAC9G,OAAO,EAAc,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAGL,aAAa,EACd,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAEL,iBAAiB,EAElB,MAAM,YAAY,CAAA;AAyBnB,qBAEa,sBAAuB,SAAQ,aAAa;IAC9C,MAAM,SAA0C;IAEzD,QAAQ,CAAC,oBAAoB,EAAE,wBAAwB,CAStD;IAED,UAAU,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM;IAKlD,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM;IAIlD,2BAA2B,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAoCjF"}
1
+ {"version":3,"file":"provider.strategy.d.ts","sourceRoot":"","sources":["../src/provider.strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,wBAAwB,EAAsB,MAAM,sBAAsB,CAAA;AAC9G,OAAO,EAAc,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAGL,aAAa,EACd,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAEL,iBAAiB,EAGlB,MAAM,YAAY,CAAA;AAuBnB,qBAEa,sBAAuB,SAAQ,aAAa;IAC9C,MAAM,SAA0C;IAEzD,QAAQ,CAAC,oBAAoB,EAAE,wBAAwB,CAStD;IAED,UAAU,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM;IAKlD,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM;IAIlD,2BAA2B,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAwCjF"}
@@ -5,8 +5,8 @@ import { nativeModelTransport } from '@xpert-ai/plugin-sdk';
5
5
  import { Injectable, Logger } from '@nestjs/common';
6
6
  import { AIModelProviderStrategy, CredentialsValidateFailedError, ModelProvider, } from '@xpert-ai/plugin-sdk';
7
7
  import { AiModelTypeEnum } from '@xpert-ai/contracts';
8
- import { OpenAIProvider, toCredentialKwargs, } from './types.js';
9
- const OpenAIValidationModels = ['gpt-5.4', 'gpt-5', 'gpt-5.2'];
8
+ import { OpenAIClient } from '@langchain/openai';
9
+ import { OpenAIProvider, toCredentialKwargs, isOpenAIOfficialBaseUrl, } from './types.js';
10
10
  const OpenAIValidationFallbackPatterns = [
11
11
  'model is not supported',
12
12
  'unsupported model',
@@ -48,34 +48,42 @@ let OpenAIProviderStrategy = OpenAIProviderStrategy_1 = class OpenAIProviderStra
48
48
  return `Bearer ${credentials.api_key}`;
49
49
  }
50
50
  async validateProviderCredentials(credentials) {
51
+ const params = toCredentialKwargs(credentials);
52
+ if (isOpenAIOfficialBaseUrl(params.configuration.baseURL)) {
53
+ // Authentication must not depend on access to an older generation's probe model.
54
+ try {
55
+ const client = new OpenAIClient({ apiKey: params.apiKey, ...params.configuration });
56
+ await client.models.list();
57
+ return;
58
+ }
59
+ catch (error) {
60
+ throw new CredentialsValidateFailedError(error instanceof Error ? error.message : 'OpenAI credentials verification failed');
61
+ }
62
+ }
51
63
  const modelInstance = this.getModelManager(AiModelTypeEnum.LLM);
64
+ const models = this.getProviderModels(AiModelTypeEnum.LLM);
52
65
  let lastError;
53
- for (const model of OpenAIValidationModels) {
66
+ for (const { model } of models) {
54
67
  try {
55
68
  await modelInstance.validateCredentials(model, credentials);
56
69
  return;
57
70
  }
58
71
  catch (ex) {
59
- lastError = ex;
60
72
  if (!shouldRetryWithNextValidationModel(ex)) {
61
73
  if (ex instanceof CredentialsValidateFailedError) {
62
74
  throw ex;
63
75
  }
64
76
  else {
65
- this.logger.error(`${this.getProviderSchema().provider}: credentials verification failed`, ex?.stack);
77
+ this.logger.error(`${this.getProviderSchema().provider}: credentials verification failed`, ex instanceof Error ? ex.stack : undefined);
66
78
  throw ex;
67
79
  }
68
80
  }
81
+ if (ex instanceof CredentialsValidateFailedError)
82
+ lastError = ex;
69
83
  this.logger.warn(`${this.getProviderSchema().provider}: validation model '${model}' unavailable, trying next candidate`);
70
84
  }
71
85
  }
72
- if (lastError instanceof CredentialsValidateFailedError) {
73
- throw lastError;
74
- }
75
- else {
76
- this.logger.error(`${this.getProviderSchema().provider}: credentials verification failed`, lastError?.stack);
77
- throw lastError;
78
- }
86
+ throw lastError ?? new CredentialsValidateFailedError('No OpenAI models are available for credentials verification');
79
87
  }
80
88
  };
81
89
  OpenAIProviderStrategy = OpenAIProviderStrategy_1 = __decorate([
package/dist/types.d.ts CHANGED
@@ -9,8 +9,8 @@ export interface OpenAICredentials {
9
9
  endpoint_url?: string;
10
10
  sampling_parameters?: 'auto' | 'enabled' | 'disabled';
11
11
  }
12
- export type OpenAIReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
13
- export interface OpenAIModelOptions extends CommonChatModelParameters {
12
+ export type OpenAIReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
13
+ export interface OpenAIModelOptions extends Partial<CommonChatModelParameters> {
14
14
  streaming?: boolean;
15
15
  top_p?: number;
16
16
  max_tokens?: number;
@@ -24,7 +24,7 @@ export declare function isOpenAIOfficialBaseUrl(baseURL?: string): boolean;
24
24
  export declare function isOpenAIGPT5ProModel(model?: string): boolean;
25
25
  export declare function getSupportedOpenAIReasoningEfforts(model?: string): readonly OpenAIReasoningEffort[] | undefined;
26
26
  export declare function normalizeOpenAIReasoningEffort(model?: string, effort?: OpenAIReasoningEffort): OpenAIReasoningEffort | undefined;
27
- export declare function shouldEnableSamplingParameters(mode: OpenAICredentials['sampling_parameters'], baseURL?: string, model?: string): boolean;
27
+ export declare function shouldEnableSamplingParameters(mode: OpenAICredentials['sampling_parameters'], baseURL?: string, model?: string, reasoningEffort?: OpenAIReasoningEffort): boolean;
28
28
  export declare function shouldEnableResponseFormat(baseURL?: string, model?: string): boolean;
29
29
  export declare function normalizeOpenAIMaxTokens(maxTokens?: number, baseURL?: string): number | undefined;
30
30
  export declare function toCredentialKwargs(credentials: OpenAICredentials): {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAmB,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAOhE,eAAO,MAAM,cAAc,WAAW,CAAA;AACtC,eAAO,MAAM,oBAAoB,8BAA8B,CAAA;AAC/D,eAAO,MAAM,8BAA8B,KAAK,CAAA;AAIhD,eAAO,MAAM,OAAO,QAAiE,CAAA;AAErF,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;CACrD;AAED,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AA8B5F,MAAM,WAAW,kBAAmB,SAAQ,yBAAyB;IACpE,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iB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AAiB,CAAC,qBAAqB,CAAC,EAC9C,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,qBAAqB,GACrC,OAAO,CAuBT;AAED,wBAAgB,0BAA0B,CACzC,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CAMT;AAED,wBAAgB,wBAAwB,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUjG;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;EAYhE"}
package/dist/types.js CHANGED
@@ -8,6 +8,18 @@ export const OpenAIResponsesMinOutputTokens = 16;
8
8
  const OpenAIApiVersionPath = '/v1';
9
9
  const OpenAIOfficialHost = 'api.openai.com';
10
10
  export const SvgIcon = readFileSync(join(moduleDir, '_assets/icon_s_en.svg'), 'utf8');
11
+ const OpenAICurrentModelProfiles = [
12
+ { model: 'gpt-6.2-astra', supported: ['low', 'medium', 'high', 'xhigh', 'max'], defaultEffort: 'medium' },
13
+ { model: 'gpt-6.2-sol', supported: ['low', 'medium', 'high', 'xhigh', 'max'], defaultEffort: 'medium' },
14
+ { model: 'gpt-6-astra', supported: ['low', 'medium', 'high', 'xhigh', 'max'], defaultEffort: 'medium' },
15
+ { model: 'gpt-6.1-sol', supported: ['low', 'medium', 'high', 'xhigh', 'max'], defaultEffort: 'medium' },
16
+ { model: 'gpt-6.1-terra', supported: ['none', 'low', 'medium', 'high', 'xhigh', 'max'], defaultEffort: 'medium' },
17
+ { model: 'gpt-6-luna', supported: ['none', 'low', 'medium', 'high', 'xhigh', 'max'], defaultEffort: 'medium' },
18
+ { model: 'gpt-6-sol', supported: ['none', 'low', 'medium', 'high', 'xhigh', 'max'], defaultEffort: 'medium' },
19
+ ];
20
+ function getCurrentModelProfile(model) {
21
+ return OpenAICurrentModelProfiles.find((profile) => profile.model === model?.trim());
22
+ }
11
23
  const OpenAIReasoningEffortScale = [
12
24
  'none',
13
25
  'minimal',
@@ -15,6 +27,7 @@ const OpenAIReasoningEffortScale = [
15
27
  'medium',
16
28
  'high',
17
29
  'xhigh',
30
+ 'max',
18
31
  ];
19
32
  const OpenAIReasoningEffortProfiles = [
20
33
  {
@@ -76,11 +89,16 @@ export function getSupportedOpenAIReasoningEfforts(model) {
76
89
  if (!model?.trim()) {
77
90
  return undefined;
78
91
  }
79
- return OpenAIReasoningEffortProfiles.find(({ pattern }) => pattern.test(model.trim()))?.supported;
92
+ return getCurrentModelProfile(model)?.supported ??
93
+ OpenAIReasoningEffortProfiles.find(({ pattern }) => pattern.test(model.trim()))?.supported;
80
94
  }
81
95
  export function normalizeOpenAIReasoningEffort(model, effort) {
96
+ const currentProfile = getCurrentModelProfile(model);
82
97
  if (!effort) {
83
- return undefined;
98
+ return currentProfile?.defaultEffort;
99
+ }
100
+ if (currentProfile && effort === 'minimal') {
101
+ return 'low';
84
102
  }
85
103
  const supported = getSupportedOpenAIReasoningEfforts(model);
86
104
  if (!supported?.length) {
@@ -101,7 +119,16 @@ export function normalizeOpenAIReasoningEffort(model, effort) {
101
119
  return candidateDistance < closestDistance ? candidate : closest;
102
120
  });
103
121
  }
104
- export function shouldEnableSamplingParameters(mode, baseURL, model) {
122
+ export function shouldEnableSamplingParameters(mode, baseURL, model, reasoningEffort) {
123
+ // An endpoint override must not send parameters forbidden by the official model contract.
124
+ // GPT-5.2 and GPT-5.4 default to none when the request omits reasoning effort.
125
+ const defaultsToNone = model?.trim() === 'gpt-5.2' || model?.trim() === 'gpt-5.4';
126
+ const effectiveEffort = normalizeOpenAIReasoningEffort(model, reasoningEffort) ??
127
+ (defaultsToNone ? 'none' : undefined);
128
+ if (isOpenAIOfficialBaseUrl(baseURL) && getSupportedOpenAIReasoningEfforts(model) &&
129
+ effectiveEffort !== 'none') {
130
+ return false;
131
+ }
105
132
  if (mode === 'enabled') {
106
133
  return true;
107
134
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-openai",
3
- "version": "0.1.0",
4
- "description": "OpenAI GPT-5 model plugin for XpertAI platform using Responses API",
3
+ "version": "0.2.1",
4
+ "description": "OpenAI GPT-6 and GPT-5 model plugin for XpertAI platform using Responses API",
5
5
  "author": {
6
6
  "name": "XpertAI",
7
7
  "url": "https://xpertai.cn"
@@ -1,79 +0,0 @@
1
- native_protocols:
2
- - openai_responses
3
- model: gpt-5.2-chat
4
- label:
5
- en_US: GPT-5.2 Chat
6
- zh_Hans: GPT-5.2 Chat
7
- model_type: llm
8
- features:
9
- - agent-thought
10
- - tool-call
11
- - multi-tool-call
12
- - stream-tool-call
13
- - structured-output
14
- - vision
15
- model_properties:
16
- mode: chat
17
- context_size: 128000
18
- max_output: 16384
19
- parameter_rules:
20
- - name: temperature
21
- use_template: temperature
22
- default: 1
23
- min: 0.0
24
- max: 2.0
25
- help:
26
- zh_Hans: 采样温度,控制输出的随机性。
27
- en_US: Sampling temperature, controls the randomness of the output.
28
- - name: max_tokens
29
- use_template: max_tokens
30
- default: 4096
31
- min: 16
32
- max: 16384
33
- help:
34
- zh_Hans: 最大输出 token 数量。
35
- en_US: Maximum number of output tokens.
36
- - name: top_p
37
- use_template: top_p
38
- default: 1
39
- min: 0.0
40
- max: 1.0
41
- help:
42
- zh_Hans: 核采样参数,控制输出的多样性。
43
- en_US: Nucleus sampling parameter, controls output diversity.
44
- - name: frequency_penalty
45
- use_template: frequency_penalty
46
- default: 0
47
- min: -2.0
48
- max: 2.0
49
- help:
50
- zh_Hans: 降低重复内容的出现频率。
51
- en_US: Reduces repetition in the output.
52
- - name: presence_penalty
53
- label:
54
- zh_Hans: 存在惩罚
55
- en_US: Presence Penalty
56
- type: float
57
- default: 0
58
- min: -2.0
59
- max: 2.0
60
- help:
61
- zh_Hans: 提高讨论新话题的可能性。
62
- en_US: Increases the likelihood of discussing new topics.
63
- - name: response_format
64
- label:
65
- zh_Hans: 回复格式
66
- en_US: Response Format
67
- type: string
68
- help:
69
- zh_Hans: 指定模型必须输出的格式。
70
- en_US: Specifying the format that the model must output.
71
- required: false
72
- options:
73
- - text
74
- - json_object
75
- pricing:
76
- input: '1.75'
77
- output: '14'
78
- unit: '0.000001'
79
- currency: USD
@@ -1,94 +0,0 @@
1
- native_protocols:
2
- - openai_responses
3
- model: gpt-5.2-codex
4
- label:
5
- en_US: GPT-5.2 Codex
6
- zh_Hans: GPT-5.2 Codex
7
- model_type: llm
8
- features:
9
- - agent-thought
10
- - tool-call
11
- - multi-tool-call
12
- - stream-tool-call
13
- - structured-output
14
- - vision
15
- model_properties:
16
- mode: chat
17
- context_size: 400000
18
- max_output: 128000
19
- parameter_rules:
20
- - name: temperature
21
- use_template: temperature
22
- default: 1
23
- min: 0.0
24
- max: 2.0
25
- help:
26
- zh_Hans: 采样温度,控制输出的随机性。
27
- en_US: Sampling temperature, controls the randomness of the output.
28
- - name: max_tokens
29
- use_template: max_tokens
30
- default: 32768
31
- min: 16
32
- max: 128000
33
- help:
34
- zh_Hans: 最大输出 token 数量。
35
- en_US: Maximum number of output tokens.
36
- - name: top_p
37
- use_template: top_p
38
- default: 1
39
- min: 0.0
40
- max: 1.0
41
- help:
42
- zh_Hans: 核采样参数,控制输出的多样性。
43
- en_US: Nucleus sampling parameter, controls output diversity.
44
- - name: reasoning_effort
45
- label:
46
- zh_Hans: 推理力度
47
- en_US: Reasoning Effort
48
- type: string
49
- required: false
50
- default: medium
51
- options:
52
- - low
53
- - medium
54
- - high
55
- - xhigh
56
- help:
57
- zh_Hans: 控制模型推理的深度。xhigh 提供最深推理,适合更复杂的编码任务。
58
- en_US: Controls how much reasoning effort the model uses. xhigh provides the deepest reasoning for more complex coding tasks.
59
- - name: frequency_penalty
60
- use_template: frequency_penalty
61
- default: 0
62
- min: -2.0
63
- max: 2.0
64
- help:
65
- zh_Hans: 降低重复内容的出现频率。
66
- en_US: Reduces repetition in the output.
67
- - name: presence_penalty
68
- label:
69
- zh_Hans: 存在惩罚
70
- en_US: Presence Penalty
71
- type: float
72
- default: 0
73
- min: -2.0
74
- max: 2.0
75
- help:
76
- zh_Hans: 提高讨论新话题的可能性。
77
- en_US: Increases the likelihood of discussing new topics.
78
- - name: response_format
79
- label:
80
- zh_Hans: 回复格式
81
- en_US: Response Format
82
- type: string
83
- help:
84
- zh_Hans: 指定模型必须输出的格式。
85
- en_US: Specifying the format that the model must output.
86
- required: false
87
- options:
88
- - text
89
- - json_object
90
- pricing:
91
- input: '1.75'
92
- output: '14'
93
- unit: '0.000001'
94
- currency: USD