New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

petercat-lui

Package Overview
Dependencies
Maintainers
0
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

petercat-lui - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

dist/assets/bubble_animation.json

7

dist/Chat/components/InputAreaRender.js

@@ -41,3 +41,3 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

url: file.url,
detail: 'auto'
detail: 'low'
}

@@ -142,3 +142,4 @@ };

}, /*#__PURE__*/React.createElement(Tooltip, {
title: disabled ? '上传图片不能超过 4 张' : ''
title: disabled ? '上传图片不能超过 4 张' : '',
trigger: "hover"
}, /*#__PURE__*/React.createElement(Button, {

@@ -164,3 +165,3 @@ type: "primary",

alt: "uploaded",
className: "object-cover rounded-lg shadow-sm"
className: "object-cover rounded-lg shadow-md"
}), /*#__PURE__*/React.createElement("div", {

@@ -167,0 +168,0 @@ className: "absolute w-[16px] h-[16px] bg-gray-800 top-[-8px] right-[-8px] text-white rounded-full cursor-pointer",

@@ -19,2 +19,3 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";

import InputArea from "./components/InputAreaRender";
import Loading from "./components/Loading";
import "../style/global.css";

@@ -41,5 +42,9 @@ var Chat = /*#__PURE__*/memo(function (_ref) {

setChats = _useState2[1];
var _useState3 = useState(false),
_useState4 = _slicedToArray(_useState3, 2),
complete = _useState4[0],
setComplete = _useState4[1];
var _useSWR = useSWR(token ? ["".concat(apiDomain, "/api/bot/detail?id=").concat(token)] : null, fetcher),
detail = _useSWR.data;
var _useState3 = useState({
var _useState5 = useState({
assistantMeta: {

@@ -53,5 +58,5 @@ avatar: assistantMeta === null || assistantMeta === void 0 ? void 0 : assistantMeta.avatar,

}),
_useState4 = _slicedToArray(_useState3, 2),
botInfo = _useState4[0],
setBotInfo = _useState4[1];
_useState6 = _slicedToArray(_useState5, 2),
botInfo = _useState6[0],
setBotInfo = _useState6[1];
useEffect(function () {

@@ -125,3 +130,31 @@ setBotInfo({

contentRender: function contentRender(props, defaultDom) {
var _proChatRef$current2, _proChatRef$current3;
var originData = props.originData || {};
// Function to render images and text content
var renderContent = function renderContent(images, text) {
return /*#__PURE__*/React.createElement("div", {
className: "ant-pro-chat-list-item-message-content"
}, images.map(function (image, index) {
var _image$image_url;
return /*#__PURE__*/React.createElement(Image, {
key: index,
src: (_image$image_url = image.image_url) === null || _image$image_url === void 0 ? void 0 : _image$image_url.url,
alt: "img",
style: {
maxWidth: '300px',
maxHeight: '400px',
borderRadius: '10px'
}
});
}), text && /*#__PURE__*/React.createElement(Markdown, {
style: {
overflowX: 'hidden',
overflowY: 'auto',
marginTop: '8px'
}
}, text));
};
// If user role, try to parse and render content
if ((originData === null || originData === void 0 ? void 0 : originData.role) === Role.user) {

@@ -131,7 +164,3 @@ try {

var _content$reduce = content.reduce(function (acc, item) {
if (item.type === 'image_url') {
acc.images.push(item);
} else if (item.type === 'text') {
acc.text += item.text;
}
if (item.type === 'image_url') acc.images.push(item);else if (item.type === 'text') acc.text += item.text;
return acc;

@@ -144,23 +173,3 @@ }, {

text = _content$reduce.text;
return /*#__PURE__*/React.createElement("div", {
className: "ant-pro-chat-list-item-message-content"
}, images.map(function (image, index) {
var _image$image_url;
return /*#__PURE__*/React.createElement(Image, {
key: index,
src: (_image$image_url = image.image_url) === null || _image$image_url === void 0 ? void 0 : _image$image_url.url,
alt: "img",
style: {
maxWidth: '300px',
maxHeight: '400px',
borderRadius: '10px'
}
});
}), text && /*#__PURE__*/React.createElement(Markdown, {
style: {
overflowX: 'hidden',
overflowY: 'auto',
marginTop: '8px'
}
}, text));
return renderContent(images, text);
} catch (err) {

@@ -172,6 +181,10 @@ console.error(err);

var originMessage = convertChunkToJson(originData.content);
// Default message content
var defaultMessageContent = /*#__PURE__*/React.createElement("div", {
className: "leftMessageContent"
}, defaultDom);
if (!originMessage || typeof originMessage === 'string') {
// If originMessage is invalid, return default message content
if ((!originMessage || typeof originMessage === 'string') && !!(proChatRef !== null && proChatRef !== void 0 && (_proChatRef$current2 = proChatRef.current) !== null && _proChatRef$current2 !== void 0 && _proChatRef$current2.getChatLoadingId())) {
return defaultMessageContent;

@@ -182,2 +195,16 @@ }

tools = _originMessage$tools === void 0 ? [] : _originMessage$tools;
console.log(answerStr);
// Handle chat loading state
if (!!(proChatRef !== null && proChatRef !== void 0 && (_proChatRef$current3 = proChatRef.current) !== null && _proChatRef$current3 !== void 0 && _proChatRef$current3.getChatLoadingId()) && answerStr === '...' && isEmpty(tools)) {
return /*#__PURE__*/React.createElement("div", {
className: "leftMessageContent"
}, /*#__PURE__*/React.createElement(Loading, {
loop: !complete,
onComplete: function onComplete() {
return setComplete(true);
}
}));
}
// If no tools, render the markdown content
if (isEmpty(tools)) {

@@ -197,5 +224,7 @@ return /*#__PURE__*/React.createElement("div", {

}
var lastTool = tools[tools.length - 1];
var type = lastTool.type,
extra = lastTool.extra;
// Handle tool or knowledge role
var _tools = tools[tools.length - 1],
type = _tools.type,
extra = _tools.extra;
if (![Role.knowledge, Role.tool].includes(type)) {

@@ -306,10 +335,10 @@ return defaultMessageContent;

inputAreaRender: function inputAreaRender(_, onMessageSend, onClear) {
var _proChatRef$current2;
var _proChatRef$current4;
return /*#__PURE__*/React.createElement(InputArea, {
isShowStop: !!(proChatRef !== null && proChatRef !== void 0 && (_proChatRef$current2 = proChatRef.current) !== null && _proChatRef$current2 !== void 0 && _proChatRef$current2.getChatLoadingId()),
isShowStop: !!(proChatRef !== null && proChatRef !== void 0 && (_proChatRef$current4 = proChatRef.current) !== null && _proChatRef$current4 !== void 0 && _proChatRef$current4.getChatLoadingId()),
onMessageSend: onMessageSend,
onClear: onClear,
onStop: function onStop() {
var _proChatRef$current3;
return proChatRef === null || proChatRef === void 0 || (_proChatRef$current3 = proChatRef.current) === null || _proChatRef$current3 === void 0 ? void 0 : _proChatRef$current3.stopGenerateMessage();
var _proChatRef$current5;
return proChatRef === null || proChatRef === void 0 || (_proChatRef$current5 = proChatRef.current) === null || _proChatRef$current5 === void 0 ? void 0 : _proChatRef$current5.stopGenerateMessage();
}

@@ -323,9 +352,9 @@ });

render: function render() {
var _proChatRef$current4;
var _proChatRef$current6;
return [/*#__PURE__*/React.createElement(StopBtn, {
key: "StopBtn",
visible: !!(proChatRef !== null && proChatRef !== void 0 && (_proChatRef$current4 = proChatRef.current) !== null && _proChatRef$current4 !== void 0 && _proChatRef$current4.getChatLoadingId()),
visible: !!(proChatRef !== null && proChatRef !== void 0 && (_proChatRef$current6 = proChatRef.current) !== null && _proChatRef$current6 !== void 0 && _proChatRef$current6.getChatLoadingId()),
action: function action() {
var _proChatRef$current5;
return proChatRef === null || proChatRef === void 0 || (_proChatRef$current5 = proChatRef.current) === null || _proChatRef$current5 === void 0 ? void 0 : _proChatRef$current5.stopGenerateMessage();
var _proChatRef$current7;
return proChatRef === null || proChatRef === void 0 || (_proChatRef$current7 = proChatRef.current) === null || _proChatRef$current7 === void 0 ? void 0 : _proChatRef$current7.stopGenerateMessage();
}

@@ -332,0 +361,0 @@ })];

{
"name": "petercat-lui",
"version": "0.1.2",
"version": "0.1.3",
"description": "A react library developed with dumi",

@@ -67,2 +67,3 @@ "module": "dist/index.js",

"swr": "^2.2.5",
"lottie-react": "^2.4.0",
"tailwindcss": "^3.4.1",

@@ -69,0 +70,0 @@ "tailwindcss-scoped-preflight": "^3.2.6",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc