From 8c45a3056d4628ea81a09f9685a605032c244071 Mon Sep 17 00:00:00 2001 From: yingying Date: Mon, 18 Nov 2024 16:49:41 +0800 Subject: [PATCH] chore: change the logo --- assistant/package.json | 4 +- assistant/src/Chat/index.tsx | 116 ++++++++++++++------------ client/package.json | 2 +- client/public/images/logo-footer.svg | 18 ++-- client/public/images/logo-inverse.svg | 26 +++--- client/public/images/logo.svg | 26 +++--- client/yarn.lock | 24 +----- petercat_utils/README.md | 8 +- 8 files changed, 107 insertions(+), 117 deletions(-) diff --git a/assistant/package.json b/assistant/package.json index be59f484..ce09dab2 100644 --- a/assistant/package.json +++ b/assistant/package.json @@ -1,7 +1,7 @@ { "name": "@petercatai/assistant", - "version": "1.0.7", - "description": "Peter Cat Assistant Application", + "version": "1.0.9", + "description": "PeterCat Assistant Application", "module": "dist/esm/index.js", "types": "dist/esm/index.d.ts", "style": "dist/esm/style.css", diff --git a/assistant/src/Chat/index.tsx b/assistant/src/Chat/index.tsx index 2a1026ad..989e6b7f 100644 --- a/assistant/src/Chat/index.tsx +++ b/assistant/src/Chat/index.tsx @@ -10,6 +10,7 @@ import { isEmpty, map } from 'lodash'; import React, { ReactNode, memo, + useCallback, useEffect, useRef, useState, @@ -89,6 +90,65 @@ const Chat: FC = memo( starters: starters, }); + const request = useCallback( + async (messages: any[]) => { + const newMessages = messages + .filter( + (item) => item.role !== Role.tool && item.role !== Role.knowledge, + ) + .map((message) => { + if (message.role === Role.user) { + try { + return { + role: message.role, + // @ts-ignore + content: JSON.parse(message?.content), + }; + } catch (e) { + return message; + } + } else { + const originMessage = convertChunkToJson( + message?.content as string, + ) as any; + const text = + typeof originMessage === 'string' + ? originMessage + : originMessage.message; + return { + role: message.role, + content: [ + { + type: 'text', + text: text, + }, + ], + }; + } + }) as Message[]; + + try { + const response = await streamChat( + newMessages, + apiDomain, + apiUrl, + prompt, + token, + ); + return handleStream(response); + } catch (e: any) { + // 处理请求错误,例如网络错误 + return new Response( + `data: ${JSON.stringify({ + status: 'error', + message: e.message, + })}`, + ); + } + }, + [apiDomain, apiUrl, prompt, token], + ); + useEffect(() => { setBotInfo({ assistantMeta: { @@ -394,61 +454,7 @@ const Chat: FC = memo( } return []; }} - request={async (messages) => { - const newMessages = messages - .filter( - (item) => - item.role !== Role.tool && item.role !== Role.knowledge, - ) - .map((message) => { - if (message.role === Role.user) { - try { - return { - role: message.role, - // @ts-ignore - content: JSON.parse(message?.content), - }; - } catch (e) { - return message; - } - } else { - const originMessage = convertChunkToJson( - message?.content as string, - ) as any; - const text = - typeof originMessage === 'string' - ? originMessage - : originMessage.message; - return { - role: message.role, - content: [ - { - type: 'text', - text: text, - }, - ], - }; - } - }) as Message[]; - try { - const response = await streamChat( - newMessages, - apiDomain, - apiUrl, - prompt, - token, - ); - return handleStream(response); - } catch (e: any) { - // catch query error,such as network error. then return error response for message render - return new Response( - `data: ${JSON.stringify({ - status: 'error', - message: e.message, - })}`, - ); - } - }} + request={request} inputAreaRender={( _: ReactNode, onMessageSend: (message: string) => void | Promise, diff --git a/client/package.json b/client/package.json index f59b66ac..8f513ef6 100644 --- a/client/package.json +++ b/client/package.json @@ -22,7 +22,7 @@ "@fullpage/react-fullpage": "^0.1.42", "@next/bundle-analyzer": "^13.4.19", "@nextui-org/react": "^2.2.9", - "@petercatai/assistant": "^1.0.7", + "@petercatai/assistant": "^1.0.9", "@sentry/nextjs": "^8.28.0", "@supabase/supabase-js": "^2.32.0", "@tanstack/react-query": "^5.17.19", diff --git a/client/public/images/logo-footer.svg b/client/public/images/logo-footer.svg index d0b6639f..a72485e3 100644 --- a/client/public/images/logo-footer.svg +++ b/client/public/images/logo-footer.svg @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + diff --git a/client/public/images/logo-inverse.svg b/client/public/images/logo-inverse.svg index 89e1d2bc..eb90d7fc 100644 --- a/client/public/images/logo-inverse.svg +++ b/client/public/images/logo-inverse.svg @@ -1,14 +1,14 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/client/public/images/logo.svg b/client/public/images/logo.svg index a63534f5..fa217b67 100644 --- a/client/public/images/logo.svg +++ b/client/public/images/logo.svg @@ -1,14 +1,14 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/client/yarn.lock b/client/yarn.lock index ef379798..ca82a6f6 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -2927,10 +2927,10 @@ resolved "https://registry.npmjs.org/@panva/hkdf/-/hkdf-1.2.1.tgz#cb0d111ef700136f4580349ff0226bf25c853f23" integrity sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw== -"@petercatai/assistant@^1.0.7": - version "1.0.7" - resolved "https://registry.npmjs.org/@petercatai/assistant/-/assistant-1.0.7.tgz#d3f55048c2dbae901ac7ba0f59f2eb6594a081e6" - integrity sha512-FE/i8ZxakbD9pl2K12KBE1G2PeUhj7HnxB0S8r8GfWwDzq7GZgjwOvnIP6/ooW17e6xhm5J/AWPAldBVjk6RMQ== +"@petercatai/assistant@^1.0.9": + version "1.0.9" + resolved "https://registry.npmjs.org/@petercatai/assistant/-/assistant-1.0.9.tgz#96f2dd4a4d0713627b4a52a5ee61f742e8a2157f" + integrity sha512-mSyF5vwfJ6ucNAVLQvnhsTJd/QuWIRes8GDACrbhlV1iY4mW5RonrPkUL6MtNLb2PSqSxDLEv8beH4UpnJ5Wng== dependencies: "@ant-design/icons" "^5.3.5" "@ant-design/pro-chat" "^1.9.0" @@ -11343,15 +11343,6 @@ string-width@^2.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -11465,13 +11456,6 @@ strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" diff --git a/petercat_utils/README.md b/petercat_utils/README.md index e2018ac4..4f1e21fd 100644 --- a/petercat_utils/README.md +++ b/petercat_utils/README.md @@ -1,6 +1,6 @@ ![banner](https://mdn.alipayobjects.com/huamei_j8gzmo/afts/img/A*m23lS7sVRDgAAAAAAAAAAAAADrPSAQ/original) -

Peter Cat

+

PeterCat

@@ -29,7 +29,7 @@ ### 对话即创造 -仅需要告知你的仓库地址或名称,Peter Cat 即可自动完成创建机器人的全部流程 +仅需要告知你的仓库地址或名称,PeterCat 即可自动完成创建机器人的全部流程 ![对话即创造](https://mdn.alipayobjects.com/huamei_j8gzmo/afts/img/A*aQ9uRoNZGe8AAAAAAAAAAAAADrPSAQ/original) @@ -143,7 +143,7 @@ ## 🤝 参与贡献 -> Peter Cat 使用 yarn 作为包管理器 +> PeterCat 使用 yarn 作为包管理器 ```bash git clone https://github.com/petercat-ai/petercat.git @@ -208,4 +208,4 @@ yarn run publish:pypi ## 📄 License -MIT@[Peter Cat](https://github.com/petercat-ai/petercat/blob/main/LICENSE) +MIT@[PeterCat](https://github.com/petercat-ai/petercat/blob/main/LICENSE)