strapi-plugin-ai-sdk 0.7.1 → 0.7.3

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.
@@ -6,7 +6,7 @@ const reactRouterDom = require("react-router-dom");
6
6
  const designSystem = require("@strapi/design-system");
7
7
  const react = require("react");
8
8
  const styled = require("styled-components");
9
- const index = require("./index-D0dDUeEO.js");
9
+ const index = require("./index-Cw2aiQ8K.js");
10
10
  const icons = require("@strapi/icons");
11
11
  const Markdown = require("react-markdown");
12
12
  const remarkGfm = require("remark-gfm");
@@ -101,11 +101,25 @@ function generateId() {
101
101
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
102
102
  }
103
103
  function toUIMessages(messages) {
104
- return messages.map((message) => ({
105
- id: message.id,
106
- role: message.role,
107
- parts: [{ type: "text", text: message.content }]
108
- }));
104
+ return messages.map((message) => {
105
+ const parts = [];
106
+ if (message.content) {
107
+ parts.push({ type: "text", text: message.content });
108
+ }
109
+ if (message.toolCalls) {
110
+ for (const tc of message.toolCalls) {
111
+ parts.push({
112
+ type: `tool-${tc.toolName}`,
113
+ toolCallId: tc.toolCallId,
114
+ toolName: tc.toolName,
115
+ state: tc.output !== void 0 ? "output-available" : "input-available",
116
+ input: tc.input,
117
+ ...tc.output !== void 0 ? { output: tc.output } : {}
118
+ });
119
+ }
120
+ }
121
+ return { id: message.id, role: message.role, parts };
122
+ });
109
123
  }
110
124
  async function fetchChatStream(messages, enabledToolSources) {
111
125
  const token = getToken();
@@ -4,7 +4,7 @@ import { Link, useNavigate, Routes, Route } from "react-router-dom";
4
4
  import { Box, Typography, TextInput, Button, Main, SearchForm, Searchbar, Table, Thead, Tr, Th, Tbody, Td, Flex, Pagination, Modal, Field, Textarea, SingleSelect, SingleSelectOption } from "@strapi/design-system";
5
5
  import { useState, useEffect, useCallback, useMemo, useRef, forwardRef } from "react";
6
6
  import styled from "styled-components";
7
- import { P as PLUGIN_ID } from "./index-skxI4tiW.mjs";
7
+ import { P as PLUGIN_ID } from "./index-BMrDQVQl.mjs";
8
8
  import { Plus, Trash, Sparkle, ArrowLeft, Pencil } from "@strapi/icons";
9
9
  import Markdown from "react-markdown";
10
10
  import remarkGfm from "remark-gfm";
@@ -95,11 +95,25 @@ function generateId() {
95
95
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`;
96
96
  }
97
97
  function toUIMessages(messages) {
98
- return messages.map((message) => ({
99
- id: message.id,
100
- role: message.role,
101
- parts: [{ type: "text", text: message.content }]
102
- }));
98
+ return messages.map((message) => {
99
+ const parts = [];
100
+ if (message.content) {
101
+ parts.push({ type: "text", text: message.content });
102
+ }
103
+ if (message.toolCalls) {
104
+ for (const tc of message.toolCalls) {
105
+ parts.push({
106
+ type: `tool-${tc.toolName}`,
107
+ toolCallId: tc.toolCallId,
108
+ toolName: tc.toolName,
109
+ state: tc.output !== void 0 ? "output-available" : "input-available",
110
+ input: tc.input,
111
+ ...tc.output !== void 0 ? { output: tc.output } : {}
112
+ });
113
+ }
114
+ }
115
+ return { id: message.id, role: message.role, parts };
116
+ });
103
117
  }
104
118
  async function fetchChatStream(messages, enabledToolSources) {
105
119
  const token = getToken();
@@ -36,7 +36,7 @@ const index = {
36
36
  defaultMessage: PLUGIN_ID
37
37
  },
38
38
  Component: async () => {
39
- const { App } = await import("./App-Dwx6guC-.mjs");
39
+ const { App } = await import("./App-DCV7o6Hc.mjs");
40
40
  return App;
41
41
  }
42
42
  });
@@ -37,7 +37,7 @@ const index = {
37
37
  defaultMessage: PLUGIN_ID
38
38
  },
39
39
  Component: async () => {
40
- const { App } = await Promise.resolve().then(() => require("./App-DcU3uMiY.js"));
40
+ const { App } = await Promise.resolve().then(() => require("./App-CEEsJsKL.js"));
41
41
  return App;
42
42
  }
43
43
  });
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-D0dDUeEO.js");
2
+ const index = require("../_chunks/index-Cw2aiQ8K.js");
3
3
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-skxI4tiW.mjs";
1
+ import { i } from "../_chunks/index-BMrDQVQl.mjs";
2
2
  export {
3
3
  i as default
4
4
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.1",
2
+ "version": "0.7.3",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",