@xpert-ai/plugin-openai 0.0.2 → 0.0.4
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.
- package/dist/index.js +2 -2
- package/dist/llm/_position.yaml +3 -0
- package/dist/llm/gpt-5.2-codex.yaml +2 -2
- package/dist/llm/gpt-5.2-pro.yaml +2 -31
- package/dist/llm/gpt-5.2.yaml +4 -3
- package/dist/llm/gpt-5.3-codex.yaml +2 -2
- package/dist/llm/gpt-5.4-pro.yaml +62 -0
- package/dist/llm/gpt-5.4.yaml +93 -0
- package/dist/llm/gpt-5.yaml +92 -0
- package/dist/llm/llm.d.ts +2 -0
- package/dist/llm/llm.d.ts.map +1 -1
- package/dist/llm/llm.js +33 -7
- package/dist/llm/reasoning.d.ts +8 -0
- package/dist/llm/reasoning.d.ts.map +1 -0
- package/dist/llm/reasoning.js +54 -0
- package/dist/openai.yaml +2 -2
- package/dist/provider.strategy.d.ts.map +1 -1
- package/dist/provider.strategy.js +44 -10
- package/dist/types.d.ts +7 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +70 -2
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -17,8 +17,8 @@ const plugin = {
|
|
|
17
17
|
value: SvgIcon,
|
|
18
18
|
},
|
|
19
19
|
displayName: 'OpenAI',
|
|
20
|
-
description: 'Provide OpenAI GPT-5
|
|
21
|
-
keywords: ['OpenAI', 'GPT-5', 'model', 'llm', 'reasoning', 'Responses API'],
|
|
20
|
+
description: 'Provide OpenAI GPT-5 and GPT-5.4 models via Responses API',
|
|
21
|
+
keywords: ['OpenAI', 'GPT-5', 'GPT-5.4', 'model', 'llm', 'reasoning', 'Responses API'],
|
|
22
22
|
author: 'XpertAI Team',
|
|
23
23
|
},
|
|
24
24
|
config: {
|
package/dist/llm/_position.yaml
CHANGED
|
@@ -52,8 +52,8 @@ parameter_rules:
|
|
|
52
52
|
- high
|
|
53
53
|
- xhigh
|
|
54
54
|
help:
|
|
55
|
-
zh_Hans: 控制模型推理的深度。xhigh
|
|
56
|
-
en_US: Controls how much reasoning effort the model uses. xhigh provides the deepest reasoning.
|
|
55
|
+
zh_Hans: 控制模型推理的深度。xhigh 提供最深推理,适合更复杂的编码任务。
|
|
56
|
+
en_US: Controls how much reasoning effort the model uses. xhigh provides the deepest reasoning for more complex coding tasks.
|
|
57
57
|
- name: frequency_penalty
|
|
58
58
|
use_template: frequency_penalty
|
|
59
59
|
default: 0
|
|
@@ -8,21 +8,12 @@ features:
|
|
|
8
8
|
- tool-call
|
|
9
9
|
- multi-tool-call
|
|
10
10
|
- stream-tool-call
|
|
11
|
-
- structured-output
|
|
12
11
|
- vision
|
|
13
12
|
model_properties:
|
|
14
13
|
mode: chat
|
|
15
14
|
context_size: 400000
|
|
16
15
|
max_output: 128000
|
|
17
16
|
parameter_rules:
|
|
18
|
-
- name: temperature
|
|
19
|
-
use_template: temperature
|
|
20
|
-
default: 1
|
|
21
|
-
min: 0.0
|
|
22
|
-
max: 2.0
|
|
23
|
-
help:
|
|
24
|
-
zh_Hans: 采样温度,控制输出的随机性。
|
|
25
|
-
en_US: Sampling temperature, controls the randomness of the output.
|
|
26
17
|
- name: max_tokens
|
|
27
18
|
use_template: max_tokens
|
|
28
19
|
default: 32768
|
|
@@ -31,14 +22,6 @@ parameter_rules:
|
|
|
31
22
|
help:
|
|
32
23
|
zh_Hans: 最大输出 token 数量。
|
|
33
24
|
en_US: Maximum number of output tokens.
|
|
34
|
-
- name: top_p
|
|
35
|
-
use_template: top_p
|
|
36
|
-
default: 1
|
|
37
|
-
min: 0.0
|
|
38
|
-
max: 1.0
|
|
39
|
-
help:
|
|
40
|
-
zh_Hans: 核采样参数,控制输出的多样性。
|
|
41
|
-
en_US: Nucleus sampling parameter, controls output diversity.
|
|
42
25
|
- name: reasoning_effort
|
|
43
26
|
label:
|
|
44
27
|
zh_Hans: 推理力度
|
|
@@ -51,8 +34,8 @@ parameter_rules:
|
|
|
51
34
|
- high
|
|
52
35
|
- xhigh
|
|
53
36
|
help:
|
|
54
|
-
zh_Hans: 控制模型推理的深度。xhigh
|
|
55
|
-
en_US: Controls how much reasoning effort the model uses. xhigh
|
|
37
|
+
zh_Hans: 控制模型推理的深度。Pro 模型从 medium 起步,xhigh 适合最复杂的问题。
|
|
38
|
+
en_US: Controls how much reasoning effort the model uses. Pro models start at medium, while xhigh is best for the hardest problems.
|
|
56
39
|
- name: frequency_penalty
|
|
57
40
|
use_template: frequency_penalty
|
|
58
41
|
default: 0
|
|
@@ -72,18 +55,6 @@ parameter_rules:
|
|
|
72
55
|
help:
|
|
73
56
|
zh_Hans: 提高讨论新话题的可能性。
|
|
74
57
|
en_US: Increases the likelihood of discussing new topics.
|
|
75
|
-
- name: response_format
|
|
76
|
-
label:
|
|
77
|
-
zh_Hans: 回复格式
|
|
78
|
-
en_US: Response Format
|
|
79
|
-
type: string
|
|
80
|
-
help:
|
|
81
|
-
zh_Hans: 指定模型必须输出的格式。
|
|
82
|
-
en_US: Specifying the format that the model must output.
|
|
83
|
-
required: false
|
|
84
|
-
options:
|
|
85
|
-
- text
|
|
86
|
-
- json_object
|
|
87
58
|
pricing:
|
|
88
59
|
input: '21'
|
|
89
60
|
output: '168'
|
package/dist/llm/gpt-5.2.yaml
CHANGED
|
@@ -45,15 +45,16 @@ parameter_rules:
|
|
|
45
45
|
en_US: Reasoning Effort
|
|
46
46
|
type: string
|
|
47
47
|
required: false
|
|
48
|
-
default:
|
|
48
|
+
default: none
|
|
49
49
|
options:
|
|
50
|
+
- none
|
|
50
51
|
- low
|
|
51
52
|
- medium
|
|
52
53
|
- high
|
|
53
54
|
- xhigh
|
|
54
55
|
help:
|
|
55
|
-
zh_Hans: 控制模型推理的深度。xhigh
|
|
56
|
-
en_US: Controls how much reasoning effort the model uses. xhigh provides the deepest reasoning.
|
|
56
|
+
zh_Hans: 控制模型推理的深度。none 为默认值,xhigh 提供最深推理但通常延迟更高。
|
|
57
|
+
en_US: Controls how much reasoning effort the model uses. none is the default, while xhigh provides the deepest reasoning at higher latency.
|
|
57
58
|
- name: frequency_penalty
|
|
58
59
|
use_template: frequency_penalty
|
|
59
60
|
default: 0
|
|
@@ -52,8 +52,8 @@ parameter_rules:
|
|
|
52
52
|
- high
|
|
53
53
|
- xhigh
|
|
54
54
|
help:
|
|
55
|
-
zh_Hans: 控制模型推理的深度。xhigh
|
|
56
|
-
en_US: Controls how much reasoning effort the model uses. xhigh provides the deepest reasoning.
|
|
55
|
+
zh_Hans: 控制模型推理的深度。xhigh 提供最深推理,适合更复杂的编码任务。
|
|
56
|
+
en_US: Controls how much reasoning effort the model uses. xhigh provides the deepest reasoning for more complex coding tasks.
|
|
57
57
|
- name: frequency_penalty
|
|
58
58
|
use_template: frequency_penalty
|
|
59
59
|
default: 0
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
model: gpt-5.4-pro
|
|
2
|
+
label:
|
|
3
|
+
en_US: GPT-5.4 Pro
|
|
4
|
+
zh_Hans: GPT-5.4 Pro
|
|
5
|
+
model_type: llm
|
|
6
|
+
features:
|
|
7
|
+
- agent-thought
|
|
8
|
+
- tool-call
|
|
9
|
+
- multi-tool-call
|
|
10
|
+
- stream-tool-call
|
|
11
|
+
- vision
|
|
12
|
+
model_properties:
|
|
13
|
+
mode: chat
|
|
14
|
+
context_size: 400000
|
|
15
|
+
max_output: 128000
|
|
16
|
+
parameter_rules:
|
|
17
|
+
- name: max_tokens
|
|
18
|
+
use_template: max_tokens
|
|
19
|
+
default: 32768
|
|
20
|
+
min: 1
|
|
21
|
+
max: 128000
|
|
22
|
+
help:
|
|
23
|
+
zh_Hans: 最大输出 token 数量。
|
|
24
|
+
en_US: Maximum number of output tokens.
|
|
25
|
+
- name: reasoning_effort
|
|
26
|
+
label:
|
|
27
|
+
zh_Hans: 推理力度
|
|
28
|
+
en_US: Reasoning Effort
|
|
29
|
+
type: string
|
|
30
|
+
required: false
|
|
31
|
+
default: medium
|
|
32
|
+
options:
|
|
33
|
+
- medium
|
|
34
|
+
- high
|
|
35
|
+
- xhigh
|
|
36
|
+
help:
|
|
37
|
+
zh_Hans: 控制模型推理的深度。Pro 模型从 medium 起步,xhigh 适合最复杂的问题。
|
|
38
|
+
en_US: Controls how much reasoning effort the model uses. Pro models start at medium, while xhigh is best for the hardest problems.
|
|
39
|
+
- name: frequency_penalty
|
|
40
|
+
use_template: frequency_penalty
|
|
41
|
+
default: 0
|
|
42
|
+
min: -2.0
|
|
43
|
+
max: 2.0
|
|
44
|
+
help:
|
|
45
|
+
zh_Hans: 降低重复内容的出现频率。
|
|
46
|
+
en_US: Reduces repetition in the output.
|
|
47
|
+
- name: presence_penalty
|
|
48
|
+
label:
|
|
49
|
+
zh_Hans: 存在惩罚
|
|
50
|
+
en_US: Presence Penalty
|
|
51
|
+
type: float
|
|
52
|
+
default: 0
|
|
53
|
+
min: -2.0
|
|
54
|
+
max: 2.0
|
|
55
|
+
help:
|
|
56
|
+
zh_Hans: 提高讨论新话题的可能性。
|
|
57
|
+
en_US: Increases the likelihood of discussing new topics.
|
|
58
|
+
pricing:
|
|
59
|
+
input: '25'
|
|
60
|
+
output: '200'
|
|
61
|
+
unit: '0.000001'
|
|
62
|
+
currency: USD
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
model: gpt-5.4
|
|
2
|
+
label:
|
|
3
|
+
en_US: GPT-5.4
|
|
4
|
+
zh_Hans: GPT-5.4
|
|
5
|
+
model_type: llm
|
|
6
|
+
features:
|
|
7
|
+
- agent-thought
|
|
8
|
+
- tool-call
|
|
9
|
+
- multi-tool-call
|
|
10
|
+
- stream-tool-call
|
|
11
|
+
- structured-output
|
|
12
|
+
- vision
|
|
13
|
+
model_properties:
|
|
14
|
+
mode: chat
|
|
15
|
+
context_size: 400000
|
|
16
|
+
max_output: 128000
|
|
17
|
+
parameter_rules:
|
|
18
|
+
- name: temperature
|
|
19
|
+
use_template: temperature
|
|
20
|
+
default: 1
|
|
21
|
+
min: 0.0
|
|
22
|
+
max: 2.0
|
|
23
|
+
help:
|
|
24
|
+
zh_Hans: 采样温度,控制输出的随机性。
|
|
25
|
+
en_US: Sampling temperature, controls the randomness of the output.
|
|
26
|
+
- name: max_tokens
|
|
27
|
+
use_template: max_tokens
|
|
28
|
+
default: 32768
|
|
29
|
+
min: 1
|
|
30
|
+
max: 128000
|
|
31
|
+
help:
|
|
32
|
+
zh_Hans: 最大输出 token 数量。GPT-5.4 支持最大 128K 输出。
|
|
33
|
+
en_US: Maximum number of output tokens. GPT-5.4 supports up to 128K output.
|
|
34
|
+
- name: top_p
|
|
35
|
+
use_template: top_p
|
|
36
|
+
default: 1
|
|
37
|
+
min: 0.0
|
|
38
|
+
max: 1.0
|
|
39
|
+
help:
|
|
40
|
+
zh_Hans: 核采样参数,控制输出的多样性。
|
|
41
|
+
en_US: Nucleus sampling parameter, controls output diversity.
|
|
42
|
+
- name: reasoning_effort
|
|
43
|
+
label:
|
|
44
|
+
zh_Hans: 推理力度
|
|
45
|
+
en_US: Reasoning Effort
|
|
46
|
+
type: string
|
|
47
|
+
required: false
|
|
48
|
+
default: none
|
|
49
|
+
options:
|
|
50
|
+
- none
|
|
51
|
+
- low
|
|
52
|
+
- medium
|
|
53
|
+
- high
|
|
54
|
+
- xhigh
|
|
55
|
+
help:
|
|
56
|
+
zh_Hans: 控制模型推理的深度。none 为默认值,xhigh 提供最深推理但通常延迟更高。
|
|
57
|
+
en_US: Controls how much reasoning effort the model uses. none is the default, while xhigh provides the deepest reasoning at higher latency.
|
|
58
|
+
- name: frequency_penalty
|
|
59
|
+
use_template: frequency_penalty
|
|
60
|
+
default: 0
|
|
61
|
+
min: -2.0
|
|
62
|
+
max: 2.0
|
|
63
|
+
help:
|
|
64
|
+
zh_Hans: 降低重复内容的出现频率。
|
|
65
|
+
en_US: Reduces repetition in the output.
|
|
66
|
+
- name: presence_penalty
|
|
67
|
+
label:
|
|
68
|
+
zh_Hans: 存在惩罚
|
|
69
|
+
en_US: Presence Penalty
|
|
70
|
+
type: float
|
|
71
|
+
default: 0
|
|
72
|
+
min: -2.0
|
|
73
|
+
max: 2.0
|
|
74
|
+
help:
|
|
75
|
+
zh_Hans: 提高讨论新话题的可能性。
|
|
76
|
+
en_US: Increases the likelihood of discussing new topics.
|
|
77
|
+
- name: response_format
|
|
78
|
+
label:
|
|
79
|
+
zh_Hans: 回复格式
|
|
80
|
+
en_US: Response Format
|
|
81
|
+
type: string
|
|
82
|
+
help:
|
|
83
|
+
zh_Hans: 指定模型必须输出的格式。
|
|
84
|
+
en_US: Specifying the format that the model must output.
|
|
85
|
+
required: false
|
|
86
|
+
options:
|
|
87
|
+
- text
|
|
88
|
+
- json_object
|
|
89
|
+
pricing:
|
|
90
|
+
input: '2'
|
|
91
|
+
output: '16'
|
|
92
|
+
unit: '0.000001'
|
|
93
|
+
currency: USD
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
model: gpt-5
|
|
2
|
+
label:
|
|
3
|
+
en_US: GPT-5
|
|
4
|
+
zh_Hans: GPT-5
|
|
5
|
+
model_type: llm
|
|
6
|
+
features:
|
|
7
|
+
- agent-thought
|
|
8
|
+
- tool-call
|
|
9
|
+
- multi-tool-call
|
|
10
|
+
- stream-tool-call
|
|
11
|
+
- structured-output
|
|
12
|
+
- vision
|
|
13
|
+
model_properties:
|
|
14
|
+
mode: chat
|
|
15
|
+
context_size: 400000
|
|
16
|
+
max_output: 128000
|
|
17
|
+
parameter_rules:
|
|
18
|
+
- name: temperature
|
|
19
|
+
use_template: temperature
|
|
20
|
+
default: 1
|
|
21
|
+
min: 0.0
|
|
22
|
+
max: 2.0
|
|
23
|
+
help:
|
|
24
|
+
zh_Hans: 采样温度,控制输出的随机性。
|
|
25
|
+
en_US: Sampling temperature, controls the randomness of the output.
|
|
26
|
+
- name: max_tokens
|
|
27
|
+
use_template: max_tokens
|
|
28
|
+
default: 32768
|
|
29
|
+
min: 1
|
|
30
|
+
max: 128000
|
|
31
|
+
help:
|
|
32
|
+
zh_Hans: 最大输出 token 数量。GPT-5 支持最大 128K 输出。
|
|
33
|
+
en_US: Maximum number of output tokens. GPT-5 supports up to 128K output.
|
|
34
|
+
- name: top_p
|
|
35
|
+
use_template: top_p
|
|
36
|
+
default: 1
|
|
37
|
+
min: 0.0
|
|
38
|
+
max: 1.0
|
|
39
|
+
help:
|
|
40
|
+
zh_Hans: 核采样参数,控制输出的多样性。
|
|
41
|
+
en_US: Nucleus sampling parameter, controls output diversity.
|
|
42
|
+
- name: reasoning_effort
|
|
43
|
+
label:
|
|
44
|
+
zh_Hans: 推理力度
|
|
45
|
+
en_US: Reasoning Effort
|
|
46
|
+
type: string
|
|
47
|
+
required: false
|
|
48
|
+
default: medium
|
|
49
|
+
options:
|
|
50
|
+
- minimal
|
|
51
|
+
- low
|
|
52
|
+
- medium
|
|
53
|
+
- high
|
|
54
|
+
help:
|
|
55
|
+
zh_Hans: 控制模型推理的深度。high 提供最深度的推理,minimal 适合更快的响应。
|
|
56
|
+
en_US: Controls how much reasoning effort the model uses. high provides the deepest reasoning, while minimal favors faster responses.
|
|
57
|
+
- name: frequency_penalty
|
|
58
|
+
use_template: frequency_penalty
|
|
59
|
+
default: 0
|
|
60
|
+
min: -2.0
|
|
61
|
+
max: 2.0
|
|
62
|
+
help:
|
|
63
|
+
zh_Hans: 降低重复内容的出现频率。
|
|
64
|
+
en_US: Reduces repetition in the output.
|
|
65
|
+
- name: presence_penalty
|
|
66
|
+
label:
|
|
67
|
+
zh_Hans: 存在惩罚
|
|
68
|
+
en_US: Presence Penalty
|
|
69
|
+
type: float
|
|
70
|
+
default: 0
|
|
71
|
+
min: -2.0
|
|
72
|
+
max: 2.0
|
|
73
|
+
help:
|
|
74
|
+
zh_Hans: 提高讨论新话题的可能性。
|
|
75
|
+
en_US: Increases the likelihood of discussing new topics.
|
|
76
|
+
- name: response_format
|
|
77
|
+
label:
|
|
78
|
+
zh_Hans: 回复格式
|
|
79
|
+
en_US: Response Format
|
|
80
|
+
type: string
|
|
81
|
+
help:
|
|
82
|
+
zh_Hans: 指定模型必须输出的格式。
|
|
83
|
+
en_US: Specifying the format that the model must output.
|
|
84
|
+
required: false
|
|
85
|
+
options:
|
|
86
|
+
- text
|
|
87
|
+
- json_object
|
|
88
|
+
pricing:
|
|
89
|
+
input: '1.25'
|
|
90
|
+
output: '10'
|
|
91
|
+
unit: '0.000001'
|
|
92
|
+
currency: USD
|
package/dist/llm/llm.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare class OpenAILargeLanguageModel extends LargeLanguageModel {
|
|
|
8
8
|
readonly modelProvider: OpenAIProviderStrategy;
|
|
9
9
|
constructor(modelProvider: OpenAIProviderStrategy);
|
|
10
10
|
validateCredentials(model: string, credentials: OpenAICredentials): Promise<void>;
|
|
11
|
+
private getReasoningOptions;
|
|
12
|
+
private toLangChainReasoning;
|
|
11
13
|
getChatModel(copilotModel: ICopilotModel, options?: TChatModelOptions): ChatOpenAI<import("@langchain/openai").ChatOpenAICallOptions>;
|
|
12
14
|
}
|
|
13
15
|
//# sourceMappingURL=llm.d.ts.map
|
package/dist/llm/llm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/llm/llm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,
|
|
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,kBAAkB,CAAA;AAEjE,OAAO,EAGL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAGL,iBAAiB,EAKlB,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"}
|
package/dist/llm/llm.js
CHANGED
|
@@ -7,8 +7,9 @@ import { AiModelTypeEnum } from '@metad/contracts';
|
|
|
7
7
|
import { Injectable, Logger } from '@nestjs/common';
|
|
8
8
|
import { CredentialsValidateFailedError, getErrorMessage, LargeLanguageModel, } from '@xpert-ai/plugin-sdk';
|
|
9
9
|
import { isNil, omitBy } from 'lodash-es';
|
|
10
|
-
import { shouldEnableSamplingParameters, toCredentialKwargs } from '../types.js';
|
|
10
|
+
import { getSupportedOpenAIReasoningEfforts, normalizeOpenAIReasoningEffort, shouldEnableResponseFormat, shouldEnableSamplingParameters, toCredentialKwargs } from '../types.js';
|
|
11
11
|
import { OpenAIProviderStrategy } from '../provider.strategy.js';
|
|
12
|
+
import { OpenAIReasoningResponsesModel } from './reasoning.js';
|
|
12
13
|
let OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = class OpenAILargeLanguageModel extends LargeLanguageModel {
|
|
13
14
|
#logger = new Logger(OpenAILargeLanguageModel_1.name);
|
|
14
15
|
constructor(modelProvider) {
|
|
@@ -31,6 +32,18 @@ let OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = class OpenAILargeLan
|
|
|
31
32
|
throw new CredentialsValidateFailedError(getErrorMessage(err));
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
getReasoningOptions(model, reasoningEffort) {
|
|
36
|
+
if (!getSupportedOpenAIReasoningEfforts(model)) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...(reasoningEffort ? { effort: reasoningEffort } : {}),
|
|
41
|
+
summary: 'auto'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
toLangChainReasoning(reasoning) {
|
|
45
|
+
return reasoning;
|
|
46
|
+
}
|
|
34
47
|
getChatModel(copilotModel, options) {
|
|
35
48
|
const { handleLLMTokens } = options ?? {};
|
|
36
49
|
const { copilot } = copilotModel;
|
|
@@ -38,10 +51,17 @@ let OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = class OpenAILargeLan
|
|
|
38
51
|
const credentials = modelProvider.credentials;
|
|
39
52
|
const params = toCredentialKwargs(credentials);
|
|
40
53
|
const modelOptions = copilotModel.options;
|
|
54
|
+
const model = copilotModel.model;
|
|
41
55
|
const hasCustomEndpoint = !!credentials?.endpoint_url?.trim();
|
|
42
56
|
const streaming = modelOptions?.streaming ?? !hasCustomEndpoint;
|
|
43
|
-
const supportsSamplingParams = shouldEnableSamplingParameters(credentials?.sampling_parameters, params.configuration?.baseURL);
|
|
44
|
-
const
|
|
57
|
+
const supportsSamplingParams = shouldEnableSamplingParameters(credentials?.sampling_parameters, params.configuration?.baseURL, model);
|
|
58
|
+
const reasoningEffort = normalizeOpenAIReasoningEffort(model, modelOptions?.reasoning_effort);
|
|
59
|
+
const reasoning = this.getReasoningOptions(model, reasoningEffort);
|
|
60
|
+
const langChainReasoning = this.toLangChainReasoning(reasoning);
|
|
61
|
+
const supportsResponseFormat = shouldEnableResponseFormat(params.configuration?.baseURL, model);
|
|
62
|
+
const responseFormat = supportsResponseFormat && modelOptions?.response_format
|
|
63
|
+
? { type: modelOptions.response_format }
|
|
64
|
+
: undefined;
|
|
45
65
|
const fields = omitBy({
|
|
46
66
|
...params,
|
|
47
67
|
model,
|
|
@@ -53,12 +73,15 @@ let OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = class OpenAILargeLan
|
|
|
53
73
|
presencePenalty: modelOptions?.presence_penalty,
|
|
54
74
|
maxRetries: modelOptions?.maxRetries,
|
|
55
75
|
useResponsesApi: true,
|
|
56
|
-
reasoning:
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
reasoning: langChainReasoning,
|
|
77
|
+
responses: new OpenAIReasoningResponsesModel({
|
|
78
|
+
...params,
|
|
79
|
+
model,
|
|
80
|
+
reasoning: langChainReasoning
|
|
81
|
+
}),
|
|
59
82
|
streamUsage: streaming,
|
|
60
83
|
}, isNil);
|
|
61
|
-
|
|
84
|
+
const chatModel = new ChatOpenAI({
|
|
62
85
|
...fields,
|
|
63
86
|
verbose: options?.verbose,
|
|
64
87
|
callbacks: [
|
|
@@ -69,6 +92,9 @@ let OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = class OpenAILargeLan
|
|
|
69
92
|
profile: this.getModelProfile(model, credentials)
|
|
70
93
|
}
|
|
71
94
|
});
|
|
95
|
+
return responseFormat
|
|
96
|
+
? chatModel.withConfig({ response_format: responseFormat })
|
|
97
|
+
: chatModel;
|
|
72
98
|
}
|
|
73
99
|
};
|
|
74
100
|
OpenAILargeLanguageModel = OpenAILargeLanguageModel_1 = __decorate([
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AIMessage } from '@langchain/core/messages';
|
|
2
|
+
import { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
3
|
+
import { ChatOpenAIResponses, OpenAIClient } from '@langchain/openai';
|
|
4
|
+
export declare class OpenAIReasoningResponsesModel extends ChatOpenAIResponses {
|
|
5
|
+
protected _convertResponsesMessageToBaseMessage(response: OpenAIClient.Responses.Response): AIMessage;
|
|
6
|
+
protected _convertResponsesDeltaToBaseMessageChunk(chunk: OpenAIClient.Responses.ResponseStreamEvent): ChatGenerationChunk | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=reasoning.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ChatOpenAIResponses } from '@langchain/openai';
|
|
2
|
+
function extractReasoningSummaryText(reasoning) {
|
|
3
|
+
if (!reasoning || typeof reasoning !== 'object') {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
const summary = reasoning.summary;
|
|
7
|
+
if (!Array.isArray(summary)) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const text = summary
|
|
11
|
+
.map((item) => (typeof item?.text === 'string' ? item.text : ''))
|
|
12
|
+
.join('')
|
|
13
|
+
.trim();
|
|
14
|
+
return text || undefined;
|
|
15
|
+
}
|
|
16
|
+
function extractReasoningDeltaText(chunk) {
|
|
17
|
+
if (chunk.type === 'response.reasoning_summary_text.delta') {
|
|
18
|
+
return chunk.delta || undefined;
|
|
19
|
+
}
|
|
20
|
+
if (chunk.type === 'response.reasoning_summary_part.added' && typeof chunk.part?.text === 'string') {
|
|
21
|
+
return chunk.part.text || undefined;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
export class OpenAIReasoningResponsesModel extends ChatOpenAIResponses {
|
|
26
|
+
_convertResponsesMessageToBaseMessage(response) {
|
|
27
|
+
const message = super._convertResponsesMessageToBaseMessage(response);
|
|
28
|
+
const reasoningContent = extractReasoningSummaryText(message.additional_kwargs?.reasoning);
|
|
29
|
+
if (reasoningContent) {
|
|
30
|
+
message.additional_kwargs = {
|
|
31
|
+
...message.additional_kwargs,
|
|
32
|
+
reasoning_content: reasoningContent
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return message;
|
|
36
|
+
}
|
|
37
|
+
_convertResponsesDeltaToBaseMessageChunk(chunk) {
|
|
38
|
+
const generationChunk = super._convertResponsesDeltaToBaseMessageChunk(chunk);
|
|
39
|
+
if (!generationChunk) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const message = generationChunk.message;
|
|
43
|
+
const reasoningContent = extractReasoningDeltaText(chunk) ?? extractReasoningSummaryText(message.additional_kwargs?.reasoning);
|
|
44
|
+
if (reasoningContent) {
|
|
45
|
+
message.additional_kwargs = {
|
|
46
|
+
...message.additional_kwargs,
|
|
47
|
+
reasoning_content: reasoningContent
|
|
48
|
+
};
|
|
49
|
+
message.content = '';
|
|
50
|
+
generationChunk.text = '';
|
|
51
|
+
}
|
|
52
|
+
return generationChunk;
|
|
53
|
+
}
|
|
54
|
+
}
|
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 model service via Responses API.
|
|
7
|
-
zh_Hans: OpenAI GPT-5 模型服务,通过 Responses API 提供。
|
|
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 提供。
|
|
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":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAGL,aAAa,EACd,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAEL,iBAAiB,EAElB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.strategy.d.ts","sourceRoot":"","sources":["../src/provider.strategy.ts"],"names":[],"mappings":"AAAA,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,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"}
|
|
@@ -4,6 +4,25 @@ import { Injectable, Logger } from '@nestjs/common';
|
|
|
4
4
|
import { AIModelProviderStrategy, CredentialsValidateFailedError, ModelProvider, } from '@xpert-ai/plugin-sdk';
|
|
5
5
|
import { AiModelTypeEnum } from '@metad/contracts';
|
|
6
6
|
import { OpenAIProvider, toCredentialKwargs, } from './types.js';
|
|
7
|
+
const OpenAIValidationModels = ['gpt-5.4', 'gpt-5', 'gpt-5.2'];
|
|
8
|
+
const OpenAIValidationFallbackPatterns = [
|
|
9
|
+
'model is not supported',
|
|
10
|
+
'unsupported model',
|
|
11
|
+
'does not exist',
|
|
12
|
+
'unknown model',
|
|
13
|
+
'invalid model',
|
|
14
|
+
'unrecognized model',
|
|
15
|
+
'no such model',
|
|
16
|
+
'not found',
|
|
17
|
+
'not available',
|
|
18
|
+
];
|
|
19
|
+
function shouldRetryWithNextValidationModel(error) {
|
|
20
|
+
if (!(error instanceof CredentialsValidateFailedError)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const message = error.message.toLowerCase();
|
|
24
|
+
return OpenAIValidationFallbackPatterns.some((pattern) => message.includes(pattern));
|
|
25
|
+
}
|
|
7
26
|
let OpenAIProviderStrategy = OpenAIProviderStrategy_1 = class OpenAIProviderStrategy extends ModelProvider {
|
|
8
27
|
constructor() {
|
|
9
28
|
super(...arguments);
|
|
@@ -17,19 +36,34 @@ let OpenAIProviderStrategy = OpenAIProviderStrategy_1 = class OpenAIProviderStra
|
|
|
17
36
|
return `Bearer ${credentials.api_key}`;
|
|
18
37
|
}
|
|
19
38
|
async validateProviderCredentials(credentials) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
throw ex;
|
|
39
|
+
const modelInstance = this.getModelManager(AiModelTypeEnum.LLM);
|
|
40
|
+
let lastError;
|
|
41
|
+
for (const model of OpenAIValidationModels) {
|
|
42
|
+
try {
|
|
43
|
+
await modelInstance.validateCredentials(model, credentials);
|
|
44
|
+
return;
|
|
27
45
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
catch (ex) {
|
|
47
|
+
lastError = ex;
|
|
48
|
+
if (!shouldRetryWithNextValidationModel(ex)) {
|
|
49
|
+
if (ex instanceof CredentialsValidateFailedError) {
|
|
50
|
+
throw ex;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.logger.error(`${this.getProviderSchema().provider}: credentials verification failed`, ex?.stack);
|
|
54
|
+
throw ex;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.logger.warn(`${this.getProviderSchema().provider}: validation model '${model}' unavailable, trying next candidate`);
|
|
31
58
|
}
|
|
32
59
|
}
|
|
60
|
+
if (lastError instanceof CredentialsValidateFailedError) {
|
|
61
|
+
throw lastError;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.logger.error(`${this.getProviderSchema().provider}: credentials verification failed`, lastError?.stack);
|
|
65
|
+
throw lastError;
|
|
66
|
+
}
|
|
33
67
|
}
|
|
34
68
|
};
|
|
35
69
|
OpenAIProviderStrategy = OpenAIProviderStrategy_1 = __decorate([
|
package/dist/types.d.ts
CHANGED
|
@@ -8,18 +8,23 @@ export interface OpenAICredentials {
|
|
|
8
8
|
endpoint_url?: string;
|
|
9
9
|
sampling_parameters?: 'auto' | 'enabled' | 'disabled';
|
|
10
10
|
}
|
|
11
|
+
export type OpenAIReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
11
12
|
export interface OpenAIModelOptions extends CommonChatModelParameters {
|
|
12
13
|
streaming?: boolean;
|
|
13
14
|
top_p?: number;
|
|
14
15
|
max_tokens?: number;
|
|
15
16
|
frequency_penalty?: number;
|
|
16
17
|
presence_penalty?: number;
|
|
17
|
-
reasoning_effort?:
|
|
18
|
+
reasoning_effort?: OpenAIReasoningEffort;
|
|
18
19
|
response_format?: 'text' | 'json_object';
|
|
19
20
|
}
|
|
20
21
|
export declare function normalizeOpenAIBaseUrl(endpointUrl?: string): string;
|
|
21
22
|
export declare function isOpenAIOfficialBaseUrl(baseURL?: string): boolean;
|
|
22
|
-
export declare function
|
|
23
|
+
export declare function isOpenAIGPT5ProModel(model?: string): boolean;
|
|
24
|
+
export declare function getSupportedOpenAIReasoningEfforts(model?: string): readonly OpenAIReasoningEffort[] | undefined;
|
|
25
|
+
export declare function normalizeOpenAIReasoningEffort(model?: string, effort?: OpenAIReasoningEffort): OpenAIReasoningEffort | undefined;
|
|
26
|
+
export declare function shouldEnableSamplingParameters(mode: OpenAICredentials['sampling_parameters'], baseURL?: string, model?: string): boolean;
|
|
27
|
+
export declare function shouldEnableResponseFormat(baseURL?: string, model?: string): boolean;
|
|
23
28
|
export declare function toCredentialKwargs(credentials: OpenAICredentials): {
|
|
24
29
|
configuration: ClientOptions;
|
|
25
30
|
temperature: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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;AAI/D,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,WAAW,kBAAmB,SAAQ,yBAAyB;IACpE,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,
|
|
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;AAI/D,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,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,qBAAqB,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;CACxC;AAID,wBAAgB,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAuBnE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAWjE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,wBAAgB,kCAAkC,CACjD,KAAK,CAAC,EAAE,MAAM,GACZ,SAAS,qBAAqB,EAAE,GAAG,SAAS,CAM9C;AAED,wBAAgB,8BAA8B,CAC7C,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,qBAAqB,GAC5B,qBAAqB,GAAG,SAAS,CA2BnC;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,EAC9C,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CAcT;AAED,wBAAgB,0BAA0B,CACzC,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CAMT;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;EAYhE"}
|
package/dist/types.js
CHANGED
|
@@ -7,6 +7,33 @@ export const OpenAIDefaultBaseUrl = 'https://api.openai.com/v1';
|
|
|
7
7
|
const OpenAIApiVersionPath = '/v1';
|
|
8
8
|
const OpenAIOfficialHost = 'api.openai.com';
|
|
9
9
|
export const SvgIcon = readFileSync(join(moduleDir, '_assets/icon_s_en.svg'), 'utf8');
|
|
10
|
+
const OpenAIReasoningEffortScale = [
|
|
11
|
+
'none',
|
|
12
|
+
'minimal',
|
|
13
|
+
'low',
|
|
14
|
+
'medium',
|
|
15
|
+
'high',
|
|
16
|
+
'xhigh',
|
|
17
|
+
];
|
|
18
|
+
const OpenAIReasoningEffortProfiles = [
|
|
19
|
+
{
|
|
20
|
+
pattern: /^gpt-5$/,
|
|
21
|
+
supported: ['minimal', 'low', 'medium', 'high'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
pattern: /^gpt-5\.(2|4)$/,
|
|
25
|
+
supported: ['none', 'low', 'medium', 'high', 'xhigh'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pattern: /^gpt-5\.[23]-codex$/,
|
|
29
|
+
supported: ['low', 'medium', 'high', 'xhigh'],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
pattern: /^gpt-5\.(2|4)-pro$/,
|
|
33
|
+
supported: ['medium', 'high', 'xhigh'],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
const OpenAIGPT5ProModelPattern = /^gpt-5(?:\.\d+)?-pro$/;
|
|
10
37
|
export function normalizeOpenAIBaseUrl(endpointUrl) {
|
|
11
38
|
if (!endpointUrl?.trim()) {
|
|
12
39
|
return OpenAIDefaultBaseUrl;
|
|
@@ -41,14 +68,55 @@ export function isOpenAIOfficialBaseUrl(baseURL) {
|
|
|
41
68
|
return baseURL.includes(OpenAIOfficialHost);
|
|
42
69
|
}
|
|
43
70
|
}
|
|
44
|
-
export function
|
|
71
|
+
export function isOpenAIGPT5ProModel(model) {
|
|
72
|
+
return !!model?.trim() && OpenAIGPT5ProModelPattern.test(model.trim());
|
|
73
|
+
}
|
|
74
|
+
export function getSupportedOpenAIReasoningEfforts(model) {
|
|
75
|
+
if (!model?.trim()) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return OpenAIReasoningEffortProfiles.find(({ pattern }) => pattern.test(model.trim()))?.supported;
|
|
79
|
+
}
|
|
80
|
+
export function normalizeOpenAIReasoningEffort(model, effort) {
|
|
81
|
+
if (!effort) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const supported = getSupportedOpenAIReasoningEfforts(model);
|
|
85
|
+
if (!supported?.length) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
if (supported.includes(effort)) {
|
|
89
|
+
return effort;
|
|
90
|
+
}
|
|
91
|
+
const requestedIndex = OpenAIReasoningEffortScale.indexOf(effort);
|
|
92
|
+
if (requestedIndex === -1) {
|
|
93
|
+
return supported[0];
|
|
94
|
+
}
|
|
95
|
+
return supported.reduce((closest, candidate) => {
|
|
96
|
+
const candidateIndex = OpenAIReasoningEffortScale.indexOf(candidate);
|
|
97
|
+
const closestIndex = OpenAIReasoningEffortScale.indexOf(closest);
|
|
98
|
+
const candidateDistance = Math.abs(candidateIndex - requestedIndex);
|
|
99
|
+
const closestDistance = Math.abs(closestIndex - requestedIndex);
|
|
100
|
+
return candidateDistance < closestDistance ? candidate : closest;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export function shouldEnableSamplingParameters(mode, baseURL, model) {
|
|
45
104
|
if (mode === 'enabled') {
|
|
46
105
|
return true;
|
|
47
106
|
}
|
|
48
107
|
if (mode === 'disabled') {
|
|
49
108
|
return false;
|
|
50
109
|
}
|
|
51
|
-
|
|
110
|
+
if (!isOpenAIOfficialBaseUrl(baseURL)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return !isOpenAIGPT5ProModel(model);
|
|
114
|
+
}
|
|
115
|
+
export function shouldEnableResponseFormat(baseURL, model) {
|
|
116
|
+
if (!isOpenAIOfficialBaseUrl(baseURL)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return !isOpenAIGPT5ProModel(model);
|
|
52
120
|
}
|
|
53
121
|
export function toCredentialKwargs(credentials) {
|
|
54
122
|
const credentialsKwargs = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-openai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "OpenAI GPT-5 model plugin for XpertAI platform using Responses API",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "XpertAI",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"lodash-es": "4.17.21"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
|
+
"build": "tsc --build tsconfig.lib.json && node ./scripts/copy-assets.mjs",
|
|
49
50
|
"test": "jest"
|
|
50
51
|
}
|
|
51
52
|
}
|