plugin-custom-llm 1.2.3 → 1.3.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.
@@ -1,139 +1,148 @@
1
- import React from 'react';
2
- import { SchemaComponent } from '@nocobase/client';
3
- import { tval } from '@nocobase/utils/client';
4
- import { namespace, useT } from '../../locale';
5
- import { Collapse } from 'antd';
6
- import { ModelSelect } from '@nocobase/plugin-ai/client';
7
-
8
- const Options: React.FC = () => {
9
- const t = useT();
10
- return (
11
- <div style={{ marginBottom: 24 }}>
12
- <Collapse
13
- bordered={false}
14
- size="small"
15
- items={[
16
- {
17
- key: 'options',
18
- label: t('Options'),
19
- forceRender: true,
20
- children: (
21
- <SchemaComponent
22
- schema={{
23
- type: 'void',
24
- name: 'custom-llm',
25
- properties: {
26
- temperature: {
27
- title: tval('Temperature', { ns: namespace }),
28
- type: 'number',
29
- 'x-decorator': 'FormItem',
30
- 'x-component': 'InputNumber',
31
- default: 0.7,
32
- 'x-component-props': {
33
- step: 0.1,
34
- min: 0.0,
35
- max: 2.0,
36
- },
37
- },
38
- maxCompletionTokens: {
39
- title: tval('Max completion tokens', { ns: namespace }),
40
- type: 'number',
41
- 'x-decorator': 'FormItem',
42
- 'x-component': 'InputNumber',
43
- default: -1,
44
- },
45
- topP: {
46
- title: tval('Top P', { ns: namespace }),
47
- type: 'number',
48
- 'x-decorator': 'FormItem',
49
- 'x-component': 'InputNumber',
50
- default: 1.0,
51
- 'x-component-props': {
52
- step: 0.1,
53
- min: 0.0,
54
- max: 1.0,
55
- },
56
- },
57
- frequencyPenalty: {
58
- title: tval('Frequency penalty', { ns: namespace }),
59
- type: 'number',
60
- 'x-decorator': 'FormItem',
61
- 'x-component': 'InputNumber',
62
- default: 0.0,
63
- 'x-component-props': {
64
- step: 0.1,
65
- min: -2.0,
66
- max: 2.0,
67
- },
68
- },
69
- presencePenalty: {
70
- title: tval('Presence penalty', { ns: namespace }),
71
- type: 'number',
72
- 'x-decorator': 'FormItem',
73
- 'x-component': 'InputNumber',
74
- default: 0.0,
75
- 'x-component-props': {
76
- step: 0.1,
77
- min: -2.0,
78
- max: 2.0,
79
- },
80
- },
81
- responseFormat: {
82
- title: tval('Response format', { ns: namespace }),
83
- type: 'string',
84
- 'x-decorator': 'FormItem',
85
- 'x-component': 'Select',
86
- enum: [
87
- { label: t('Text'), value: 'text' },
88
- { label: t('JSON'), value: 'json_object' },
89
- ],
90
- default: 'text',
91
- },
92
- timeout: {
93
- title: tval('Timeout (ms)', { ns: namespace }),
94
- type: 'number',
95
- 'x-decorator': 'FormItem',
96
- 'x-component': 'InputNumber',
97
- default: 60000,
98
- },
99
- maxRetries: {
100
- title: tval('Max retries', { ns: namespace }),
101
- type: 'number',
102
- 'x-decorator': 'FormItem',
103
- 'x-component': 'InputNumber',
104
- default: 1,
105
- },
106
- },
107
- }}
108
- />
109
- ),
110
- },
111
- ]}
112
- />
113
- </div>
114
- );
115
- };
116
-
117
- export const ModelSettingsForm: React.FC = () => {
118
- return (
119
- <SchemaComponent
120
- components={{ Options, ModelSelect }}
121
- schema={{
122
- type: 'void',
123
- properties: {
124
- model: {
125
- title: tval('Model', { ns: namespace }),
126
- type: 'string',
127
- required: true,
128
- 'x-decorator': 'FormItem',
129
- 'x-component': 'ModelSelect',
130
- },
131
- options: {
132
- type: 'void',
133
- 'x-component': 'Options',
134
- },
135
- },
136
- }}
137
- />
138
- );
139
- };
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import React from 'react';
11
+ import { SchemaComponent } from '@nocobase/client';
12
+ import { tval } from '@nocobase/utils/client';
13
+ import { namespace, useT } from '../../locale';
14
+ import { Collapse } from 'antd';
15
+ import { ModelSelect } from '@nocobase/plugin-ai/client';
16
+
17
+ const Options: React.FC = () => {
18
+ const t = useT();
19
+ return (
20
+ <div style={{ marginBottom: 24 }}>
21
+ <Collapse
22
+ bordered={false}
23
+ size="small"
24
+ items={[
25
+ {
26
+ key: 'options',
27
+ label: t('Options'),
28
+ forceRender: true,
29
+ children: (
30
+ <SchemaComponent
31
+ schema={{
32
+ type: 'void',
33
+ name: 'custom-llm',
34
+ properties: {
35
+ temperature: {
36
+ title: tval('Temperature', { ns: namespace }),
37
+ type: 'number',
38
+ 'x-decorator': 'FormItem',
39
+ 'x-component': 'InputNumber',
40
+ default: 0.7,
41
+ 'x-component-props': {
42
+ step: 0.1,
43
+ min: 0.0,
44
+ max: 2.0,
45
+ },
46
+ },
47
+ maxCompletionTokens: {
48
+ title: tval('Max completion tokens', { ns: namespace }),
49
+ type: 'number',
50
+ 'x-decorator': 'FormItem',
51
+ 'x-component': 'InputNumber',
52
+ default: -1,
53
+ },
54
+ topP: {
55
+ title: tval('Top P', { ns: namespace }),
56
+ type: 'number',
57
+ 'x-decorator': 'FormItem',
58
+ 'x-component': 'InputNumber',
59
+ default: 1.0,
60
+ 'x-component-props': {
61
+ step: 0.1,
62
+ min: 0.0,
63
+ max: 1.0,
64
+ },
65
+ },
66
+ frequencyPenalty: {
67
+ title: tval('Frequency penalty', { ns: namespace }),
68
+ type: 'number',
69
+ 'x-decorator': 'FormItem',
70
+ 'x-component': 'InputNumber',
71
+ default: 0.0,
72
+ 'x-component-props': {
73
+ step: 0.1,
74
+ min: -2.0,
75
+ max: 2.0,
76
+ },
77
+ },
78
+ presencePenalty: {
79
+ title: tval('Presence penalty', { ns: namespace }),
80
+ type: 'number',
81
+ 'x-decorator': 'FormItem',
82
+ 'x-component': 'InputNumber',
83
+ default: 0.0,
84
+ 'x-component-props': {
85
+ step: 0.1,
86
+ min: -2.0,
87
+ max: 2.0,
88
+ },
89
+ },
90
+ responseFormat: {
91
+ title: tval('Response format', { ns: namespace }),
92
+ type: 'string',
93
+ 'x-decorator': 'FormItem',
94
+ 'x-component': 'Select',
95
+ enum: [
96
+ { label: t('Text'), value: 'text' },
97
+ { label: t('JSON'), value: 'json_object' },
98
+ ],
99
+ default: 'text',
100
+ },
101
+ timeout: {
102
+ title: tval('Timeout (ms)', { ns: namespace }),
103
+ type: 'number',
104
+ 'x-decorator': 'FormItem',
105
+ 'x-component': 'InputNumber',
106
+ default: 60000,
107
+ },
108
+ maxRetries: {
109
+ title: tval('Max retries', { ns: namespace }),
110
+ type: 'number',
111
+ 'x-decorator': 'FormItem',
112
+ 'x-component': 'InputNumber',
113
+ default: 1,
114
+ },
115
+ },
116
+ }}
117
+ />
118
+ ),
119
+ },
120
+ ]}
121
+ />
122
+ </div>
123
+ );
124
+ };
125
+
126
+ export const ModelSettingsForm: React.FC = () => {
127
+ return (
128
+ <SchemaComponent
129
+ components={{ Options, ModelSelect }}
130
+ schema={{
131
+ type: 'void',
132
+ properties: {
133
+ model: {
134
+ title: tval('Model', { ns: namespace }),
135
+ type: 'string',
136
+ required: true,
137
+ 'x-decorator': 'FormItem',
138
+ 'x-component': 'ModelSelect',
139
+ },
140
+ options: {
141
+ type: 'void',
142
+ 'x-component': 'Options',
143
+ },
144
+ },
145
+ }}
146
+ />
147
+ );
148
+ };
@@ -1,115 +1,133 @@
1
- import React from 'react';
2
- import { SchemaComponent } from '@nocobase/client';
3
- import { tval } from '@nocobase/utils/client';
4
- import { namespace } from '../../locale';
5
-
6
- export const ProviderSettingsForm: React.FC = () => {
7
- return (
8
- <SchemaComponent
9
- schema={{
10
- type: 'void',
11
- properties: {
12
- apiKey: {
13
- title: tval('API Key', { ns: namespace }),
14
- type: 'string',
15
- required: true,
16
- 'x-decorator': 'FormItem',
17
- 'x-component': 'TextAreaWithGlobalScope',
18
- },
19
- disableStream: {
20
- title: tval('Disable streaming', { ns: namespace }),
21
- type: 'boolean',
22
- 'x-decorator': 'FormItem',
23
- 'x-component': 'Checkbox',
24
- 'x-content': tval('Disable streaming description', { ns: namespace }),
25
- },
26
- streamKeepAlive: {
27
- title: tval('Stream keepalive', { ns: namespace }),
28
- type: 'boolean',
29
- 'x-decorator': 'FormItem',
30
- 'x-component': 'Checkbox',
31
- 'x-content': tval('Stream keepalive description', { ns: namespace }),
32
- },
33
- keepAliveIntervalMs: {
34
- title: tval('Keepalive interval (ms)', { ns: namespace }),
35
- type: 'number',
36
- 'x-decorator': 'FormItem',
37
- 'x-component': 'InputNumber',
38
- 'x-component-props': {
39
- placeholder: '5000',
40
- min: 1000,
41
- step: 1000,
42
- style: { width: '100%' },
43
- },
44
- description: tval('Keepalive interval description', { ns: namespace }),
45
- },
46
- keepAliveContent: {
47
- title: tval('Keepalive content', { ns: namespace }),
48
- type: 'string',
49
- 'x-decorator': 'FormItem',
50
- 'x-component': 'Input',
51
- 'x-component-props': {
52
- placeholder: '...',
53
- },
54
- description: tval('Keepalive content description', { ns: namespace }),
55
- },
56
- timeout: {
57
- title: tval('Timeout (ms)', { ns: namespace }),
58
- type: 'number',
59
- 'x-decorator': 'FormItem',
60
- 'x-component': 'InputNumber',
61
- 'x-component-props': {
62
- placeholder: '120000',
63
- min: 0,
64
- step: 1000,
65
- style: { width: '100%' },
66
- },
67
- description: tval('Timeout description', { ns: namespace }),
68
- },
69
- requestConfig: {
70
- title: tval('Request config (JSON)', { ns: namespace }),
71
- type: 'string',
72
- 'x-decorator': 'FormItem',
73
- 'x-component': 'Input.TextArea',
74
- 'x-component-props': {
75
- placeholder: JSON.stringify(
76
- {
77
- extraHeaders: {},
78
- extraBody: {},
79
- modelKwargs: {},
80
- },
81
- null,
82
- 2,
83
- ),
84
- rows: 6,
85
- style: { fontFamily: 'monospace', fontSize: 12 },
86
- },
87
- description: tval('Request config description', { ns: namespace }),
88
- },
89
- responseConfig: {
90
- title: tval('Response config (JSON)', { ns: namespace }),
91
- type: 'string',
92
- 'x-decorator': 'FormItem',
93
- 'x-component': 'Input.TextArea',
94
- 'x-component-props': {
95
- placeholder: JSON.stringify(
96
- {
97
- contentPath: 'auto',
98
- reasoningKey: 'reasoning_content',
99
- responseMapping: {
100
- content: 'message.response',
101
- },
102
- },
103
- null,
104
- 2,
105
- ),
106
- rows: 8,
107
- style: { fontFamily: 'monospace', fontSize: 12 },
108
- },
109
- description: tval('Response config description', { ns: namespace }),
110
- },
111
- },
112
- }}
113
- />
114
- );
115
- };
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import React from 'react';
11
+ import { SchemaComponent } from '@nocobase/client';
12
+ import { tval } from '@nocobase/utils/client';
13
+ import { namespace } from '../../locale';
14
+
15
+ export const ProviderSettingsForm: React.FC = () => {
16
+ return (
17
+ <SchemaComponent
18
+ schema={{
19
+ type: 'void',
20
+ properties: {
21
+ apiKey: {
22
+ title: tval('API Key', { ns: namespace }),
23
+ type: 'string',
24
+ required: true,
25
+ 'x-decorator': 'FormItem',
26
+ 'x-component': 'TextAreaWithGlobalScope',
27
+ },
28
+ disableStream: {
29
+ title: tval('Disable streaming', { ns: namespace }),
30
+ type: 'boolean',
31
+ 'x-decorator': 'FormItem',
32
+ 'x-component': 'Checkbox',
33
+ 'x-content': tval('Disable streaming description', { ns: namespace }),
34
+ },
35
+ enableReasoning: {
36
+ title: tval('Enable reasoning', { ns: namespace }),
37
+ type: 'boolean',
38
+ 'x-decorator': 'FormItem',
39
+ 'x-component': 'Checkbox',
40
+ 'x-content': tval('Enable reasoning description', { ns: namespace }),
41
+ },
42
+ streamKeepAlive: {
43
+ title: tval('Stream keepalive', { ns: namespace }),
44
+ type: 'boolean',
45
+ 'x-decorator': 'FormItem',
46
+ 'x-component': 'Checkbox',
47
+ 'x-content': tval('Stream keepalive description', { ns: namespace }),
48
+ },
49
+ keepAliveIntervalMs: {
50
+ title: tval('Keepalive interval (ms)', { ns: namespace }),
51
+ type: 'number',
52
+ 'x-decorator': 'FormItem',
53
+ 'x-component': 'InputNumber',
54
+ 'x-component-props': {
55
+ placeholder: '5000',
56
+ min: 1000,
57
+ step: 1000,
58
+ style: { width: '100%' },
59
+ },
60
+ description: tval('Keepalive interval description', { ns: namespace }),
61
+ },
62
+ keepAliveContent: {
63
+ title: tval('Keepalive content', { ns: namespace }),
64
+ type: 'string',
65
+ 'x-decorator': 'FormItem',
66
+ 'x-component': 'Input',
67
+ 'x-component-props': {
68
+ placeholder: '...',
69
+ },
70
+ description: tval('Keepalive content description', { ns: namespace }),
71
+ },
72
+ timeout: {
73
+ title: tval('Timeout (ms)', { ns: namespace }),
74
+ type: 'number',
75
+ 'x-decorator': 'FormItem',
76
+ 'x-component': 'InputNumber',
77
+ 'x-component-props': {
78
+ placeholder: '120000',
79
+ min: 0,
80
+ step: 1000,
81
+ style: { width: '100%' },
82
+ },
83
+ description: tval('Timeout description', { ns: namespace }),
84
+ },
85
+ requestConfig: {
86
+ title: tval('Request config (JSON)', { ns: namespace }),
87
+ type: 'string',
88
+ 'x-decorator': 'FormItem',
89
+ 'x-component': 'Input.TextArea',
90
+ 'x-component-props': {
91
+ placeholder: JSON.stringify(
92
+ {
93
+ extraHeaders: {},
94
+ extraBody: {},
95
+ modelKwargs: {},
96
+ },
97
+ null,
98
+ 2,
99
+ ),
100
+ rows: 6,
101
+ style: { fontFamily: 'monospace', fontSize: 12 },
102
+ },
103
+ description: tval('Request config description', { ns: namespace }),
104
+ },
105
+ responseConfig: {
106
+ title: tval('Response config (JSON)', { ns: namespace }),
107
+ type: 'string',
108
+ 'x-decorator': 'FormItem',
109
+ 'x-component': 'Input.TextArea',
110
+ 'x-component-props': {
111
+ placeholder: JSON.stringify(
112
+ {
113
+ contentPath: 'auto',
114
+ reasoningKey: 'reasoning_content',
115
+ responseMapping: {
116
+ content: 'message.response',
117
+ tool_calls: 'message.tool_calls',
118
+ finish_reason: 'finish_reason',
119
+ },
120
+ },
121
+ null,
122
+ 2,
123
+ ),
124
+ rows: 8,
125
+ style: { fontFamily: 'monospace', fontSize: 12 },
126
+ },
127
+ description: tval('Response config description', { ns: namespace }),
128
+ },
129
+ },
130
+ }}
131
+ />
132
+ );
133
+ };
@@ -1,10 +1,19 @@
1
- import { LLMProviderOptions } from '@nocobase/plugin-ai/client';
2
- import { ProviderSettingsForm } from './ProviderSettings';
3
- import { ModelSettingsForm } from './ModelSettings';
4
-
5
- export const customLLMProviderOptions: LLMProviderOptions = {
6
- components: {
7
- ProviderSettingsForm,
8
- ModelSettingsForm,
9
- },
10
- };
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import { LLMProviderOptions } from '@nocobase/plugin-ai/client';
11
+ import { ProviderSettingsForm } from './ProviderSettings';
12
+ import { ModelSettingsForm } from './ModelSettings';
13
+
14
+ export const customLLMProviderOptions: LLMProviderOptions = {
15
+ components: {
16
+ ProviderSettingsForm,
17
+ ModelSettingsForm,
18
+ },
19
+ };
@@ -1,8 +1,17 @@
1
- import { useTranslation } from 'react-i18next';
2
-
3
- export const namespace = '@nocobase/plugin-custom-llm';
4
-
5
- export function useT() {
6
- const { t } = useTranslation(namespace, { nsMode: 'fallback' });
7
- return t;
8
- }
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import { useTranslation } from 'react-i18next';
11
+
12
+ export const namespace = '@nocobase/plugin-custom-llm';
13
+
14
+ export function useT() {
15
+ const { t } = useTranslation(namespace, { nsMode: 'fallback' });
16
+ return t;
17
+ }
@@ -1,3 +1,12 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
1
10
  import { Plugin } from '@nocobase/client';
2
11
  import models from './models';
3
12
 
package/src/index.ts CHANGED
@@ -1,2 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
1
10
  export * from './server';
2
11
  export { default } from './server';