UNPKG

@copilotkit/react-ui

Version:

<div align="center"> <a href="https://copilotkit.ai" target="_blank"> <img src="https://github.com/copilotkit/copilotkit/raw/main/assets/banner.png" alt="CopilotKit Logo"> </a>

124 lines (123 loc) 4.18 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/components/chat/messages/RenderAgentStateMessage.tsx var RenderAgentStateMessage_exports = {}; __export(RenderAgentStateMessage_exports, { RenderAgentStateMessage: () => RenderAgentStateMessage }); module.exports = __toCommonJS(RenderAgentStateMessage_exports); var import_react_core = require("@copilotkit/react-core"); var import_jsx_runtime = require("react/jsx-runtime"); function RenderAgentStateMessage(props) { const { chatComponentsCache } = (0, import_react_core.useCopilotContext)(); const { message, inProgress, index, isCurrentMessage, AssistantMessage } = props; if (message.isAgentStateMessage()) { let render; if (chatComponentsCache.current !== null) { render = chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-${message.nodeName}`] || chatComponentsCache.current.coAgentStateRenders[`${message.agentName}-global`]; } if (render) { if (typeof render === "string") { if (isCurrentMessage && inProgress) { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( AssistantMessage, { rawData: message, message: render, "data-message-role": "assistant", isLoading: true, isGenerating: true }, index ); } else { return null; } } else { const state = message.state; let status = message.active ? "inProgress" : "complete"; const toRender = render({ status, state, nodeName: message.nodeName }); if (!toRender && status === "complete") { return null; } if (!toRender && isCurrentMessage && inProgress) { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( AssistantMessage, { "data-message-role": "assistant", rawData: message, isLoading: true, isGenerating: true }, index ); } else if (!toRender) { return null; } if (typeof toRender === "string") { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( AssistantMessage, { rawData: message, message: toRender, isLoading: true, isGenerating: true, "data-message-role": "assistant" }, index ); } else { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( AssistantMessage, { rawData: message, "data-message-role": "agent-state-render", isLoading: false, isGenerating: false, subComponent: toRender }, index ); } } } else if (!inProgress || !isCurrentMessage) { return null; } else { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( AssistantMessage, { rawData: message, isLoading: true, isGenerating: true, "data-message-role": "assistant" }, index ); } } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { RenderAgentStateMessage }); //# sourceMappingURL=RenderAgentStateMessage.js.map