strapi-plugin-ai-sdk 0.4.0 → 0.5.0
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/server/index.js
CHANGED
|
@@ -147,6 +147,8 @@ function createTTSRegistry() {
|
|
|
147
147
|
}
|
|
148
148
|
const DEFAULT_MODEL = "claude-sonnet-4-20250514";
|
|
149
149
|
const DEFAULT_TEMPERATURE = 0.7;
|
|
150
|
+
const DEFAULT_MAX_OUTPUT_TOKENS = 8192;
|
|
151
|
+
const DEFAULT_MAX_CONVERSATION_MESSAGES = 40;
|
|
150
152
|
function isPromptInput(input) {
|
|
151
153
|
return "prompt" in input;
|
|
152
154
|
}
|
|
@@ -849,6 +851,8 @@ const config = {
|
|
|
849
851
|
chatModel: "claude-sonnet-4-20250514",
|
|
850
852
|
baseURL: void 0,
|
|
851
853
|
systemPrompt: "",
|
|
854
|
+
maxOutputTokens: 8192,
|
|
855
|
+
maxConversationMessages: 40,
|
|
852
856
|
mcp: {
|
|
853
857
|
sessionTimeoutMs: 4 * 60 * 60 * 1e3,
|
|
854
858
|
maxSessions: 100,
|
|
@@ -1807,7 +1811,10 @@ const service = ({ strapi }) => {
|
|
|
1807
1811
|
*/
|
|
1808
1812
|
async chat(messages, options2) {
|
|
1809
1813
|
const config2 = strapi.config.get("plugin::ai-sdk");
|
|
1810
|
-
const
|
|
1814
|
+
const maxMessages = config2?.maxConversationMessages ?? DEFAULT_MAX_CONVERSATION_MESSAGES;
|
|
1815
|
+
const maxOutputTokens = config2?.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS;
|
|
1816
|
+
const trimmedMessages = messages.length > maxMessages ? messages.slice(-maxMessages) : messages;
|
|
1817
|
+
const modelMessages = await ai.convertToModelMessages(trimmedMessages);
|
|
1811
1818
|
const tools = createTools(strapi, { adminUserId: options2?.adminUserId });
|
|
1812
1819
|
const toolsDescription = describeTools(tools);
|
|
1813
1820
|
let system = composeSystemPrompt(config2, toolsDescription, options2?.system);
|
|
@@ -1832,6 +1839,7 @@ ${lines.join("\n")}`;
|
|
|
1832
1839
|
messages: modelMessages,
|
|
1833
1840
|
system,
|
|
1834
1841
|
tools,
|
|
1842
|
+
maxOutputTokens,
|
|
1835
1843
|
stopWhen: ai.stepCountIs(6)
|
|
1836
1844
|
});
|
|
1837
1845
|
},
|
package/dist/server/index.mjs
CHANGED
|
@@ -146,6 +146,8 @@ function createTTSRegistry() {
|
|
|
146
146
|
}
|
|
147
147
|
const DEFAULT_MODEL = "claude-sonnet-4-20250514";
|
|
148
148
|
const DEFAULT_TEMPERATURE = 0.7;
|
|
149
|
+
const DEFAULT_MAX_OUTPUT_TOKENS = 8192;
|
|
150
|
+
const DEFAULT_MAX_CONVERSATION_MESSAGES = 40;
|
|
149
151
|
function isPromptInput(input) {
|
|
150
152
|
return "prompt" in input;
|
|
151
153
|
}
|
|
@@ -848,6 +850,8 @@ const config = {
|
|
|
848
850
|
chatModel: "claude-sonnet-4-20250514",
|
|
849
851
|
baseURL: void 0,
|
|
850
852
|
systemPrompt: "",
|
|
853
|
+
maxOutputTokens: 8192,
|
|
854
|
+
maxConversationMessages: 40,
|
|
851
855
|
mcp: {
|
|
852
856
|
sessionTimeoutMs: 4 * 60 * 60 * 1e3,
|
|
853
857
|
maxSessions: 100,
|
|
@@ -1806,7 +1810,10 @@ const service = ({ strapi }) => {
|
|
|
1806
1810
|
*/
|
|
1807
1811
|
async chat(messages, options2) {
|
|
1808
1812
|
const config2 = strapi.config.get("plugin::ai-sdk");
|
|
1809
|
-
const
|
|
1813
|
+
const maxMessages = config2?.maxConversationMessages ?? DEFAULT_MAX_CONVERSATION_MESSAGES;
|
|
1814
|
+
const maxOutputTokens = config2?.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS;
|
|
1815
|
+
const trimmedMessages = messages.length > maxMessages ? messages.slice(-maxMessages) : messages;
|
|
1816
|
+
const modelMessages = await convertToModelMessages(trimmedMessages);
|
|
1810
1817
|
const tools = createTools(strapi, { adminUserId: options2?.adminUserId });
|
|
1811
1818
|
const toolsDescription = describeTools(tools);
|
|
1812
1819
|
let system = composeSystemPrompt(config2, toolsDescription, options2?.system);
|
|
@@ -1831,6 +1838,7 @@ ${lines.join("\n")}`;
|
|
|
1831
1838
|
messages: modelMessages,
|
|
1832
1839
|
system,
|
|
1833
1840
|
tools,
|
|
1841
|
+
maxOutputTokens,
|
|
1834
1842
|
stopWhen: stepCountIs(6)
|
|
1835
1843
|
});
|
|
1836
1844
|
},
|
|
@@ -16,12 +16,16 @@ export interface MCPConfig {
|
|
|
16
16
|
maxSessions?: number;
|
|
17
17
|
cleanupInterval?: number;
|
|
18
18
|
}
|
|
19
|
+
export declare const DEFAULT_MAX_OUTPUT_TOKENS = 8192;
|
|
20
|
+
export declare const DEFAULT_MAX_CONVERSATION_MESSAGES = 40;
|
|
19
21
|
export interface PluginConfig {
|
|
20
22
|
anthropicApiKey: string;
|
|
21
23
|
provider?: string;
|
|
22
24
|
chatModel?: string;
|
|
23
25
|
baseURL?: string;
|
|
24
26
|
systemPrompt?: string;
|
|
27
|
+
maxOutputTokens?: number;
|
|
28
|
+
maxConversationMessages?: number;
|
|
25
29
|
typecastApiKey?: string;
|
|
26
30
|
typecastActorId?: string;
|
|
27
31
|
mcp?: MCPConfig;
|
package/package.json
CHANGED