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.
@@ -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 modelMessages = await ai.convertToModelMessages(messages);
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
  },
@@ -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 modelMessages = await convertToModelMessages(messages);
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
  },
@@ -5,6 +5,8 @@ declare const _default: {
5
5
  chatModel: string;
6
6
  baseURL: any;
7
7
  systemPrompt: string;
8
+ maxOutputTokens: number;
9
+ maxConversationMessages: number;
8
10
  mcp: {
9
11
  sessionTimeoutMs: number;
10
12
  maxSessions: number;
@@ -16,6 +16,8 @@ declare const _default: {
16
16
  chatModel: string;
17
17
  baseURL: any;
18
18
  systemPrompt: string;
19
+ maxOutputTokens: number;
20
+ maxConversationMessages: number;
19
21
  mcp: {
20
22
  sessionTimeoutMs: number;
21
23
  maxSessions: number;
@@ -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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.0",
2
+ "version": "0.5.0",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",