From e76c4cdb6c0545a6c6f8f3db61b07ae4470d47be Mon Sep 17 00:00:00 2001 From: Shinji-Li <1349021570@qq.com> Date: Wed, 17 Jan 2024 18:36:02 +0800 Subject: [PATCH 1/8] :bug: fix: stream was done but loading icon is show (#45) --- src/ChatItem/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ChatItem/index.tsx b/src/ChatItem/index.tsx index 670e9059..9ddb7c2e 100644 --- a/src/ChatItem/index.tsx +++ b/src/ChatItem/index.tsx @@ -63,7 +63,7 @@ const ChatItem = memo((props) => { /> ); return chatItemRenderConfig?.avatarRender?.(props, dom) || dom; - }, [avatar, placement, mobile]); + }, [avatar, placement, mobile, loading]); const messageContentDom = useMemo(() => { if (chatItemRenderConfig?.contentRender === false) return null; From 929fc66c05fcf3a14e99da1b21fe52772348f673 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 17 Jan 2024 10:37:45 +0000 Subject: [PATCH 2/8] :bookmark: chore(release): v1.4.2 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### [Version 1.4.2](https://github.com/ant-design/pro-chat/compare/v1.4.1...v1.4.2) Released on **2024-01-17** #### 🐛 修复 - Stream was done but loading icon is show.
Improvements and Fixes #### What's fixed * Stream was done but loading icon is show, closes [#45](https://github.com/ant-design/pro-chat/issues/45) ([e76c4cd](https://github.com/ant-design/pro-chat/commit/e76c4cd))
[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
--- CHANGELOG.md | 25 +++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54fdce3a..63ac0cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +### [Version 1.4.2](https://github.com/ant-design/pro-chat/compare/v1.4.1...v1.4.2) + +Released on **2024-01-17** + +#### 🐛 修复 + +- Stream was done but loading icon is show. + +
+ +
+Improvements and Fixes + +#### What's fixed + +- Stream was done but loading icon is show, closes [#45](https://github.com/ant-design/pro-chat/issues/45) ([e76c4cd](https://github.com/ant-design/pro-chat/commit/e76c4cd)) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ ### [Version 1.4.1](https://github.com/ant-design/pro-chat/compare/v1.4.0...v1.4.1) Released on **2024-01-17** diff --git a/package.json b/package.json index 4f51e8b7..cf49a75b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ant-design/pro-chat", - "version": "1.4.1", + "version": "1.4.2", "description": "a solution for ai chat", "keywords": [ "ai", From f3c2dd1ad8c1b98dfcadd005701d707a6f8edc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=81=E5=AE=A2?= Date: Thu, 18 Jan 2024 20:58:11 +0800 Subject: [PATCH 3/8] =?UTF-8?q?docs(qwen):=20qwen=20next=20demo=E4=B8=8B?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=B8=B2=E6=9F=93=E6=8A=A5=E9=94=99=20(#46)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatgpt-nextjs/src/app/chatgpt/index.tsx | 38 +++++++++------- demos/qwen-nextjs/src/app/page.tsx | 38 +++++++++------- docs/guide/chatgpt.md | 44 +++++++++++-------- docs/guide/qwen.md | 43 ++++++++++-------- 4 files changed, 97 insertions(+), 66 deletions(-) diff --git a/demos/chatgpt-nextjs/src/app/chatgpt/index.tsx b/demos/chatgpt-nextjs/src/app/chatgpt/index.tsx index 4d479850..3addb399 100644 --- a/demos/chatgpt-nextjs/src/app/chatgpt/index.tsx +++ b/demos/chatgpt-nextjs/src/app/chatgpt/index.tsx @@ -1,30 +1,38 @@ 'use client'; - +import { useState, useEffect } from 'react' import { ProChat } from '@ant-design/pro-chat'; import { useTheme } from 'antd-style'; export default function Home() { + const theme = useTheme(); + const [showComponent, setShowComponent] = useState(false) + + useEffect(() => setShowComponent(true), []) + return (
- ) => { - const response = await fetch('/api/openai', { - method: 'POST', - body: JSON.stringify({ messages: messages }), - }); - - return response; - }} - /> + { + showComponent && { + const response = await fetch('/api/qwen', { + method: 'POST', + body: JSON.stringify({ messages: messages }), + }); + const data = await response.json(); + return new Response(data.output?.text); + }} + /> + }
); } + diff --git a/demos/qwen-nextjs/src/app/page.tsx b/demos/qwen-nextjs/src/app/page.tsx index fd0f77cd..3addb399 100644 --- a/demos/qwen-nextjs/src/app/page.tsx +++ b/demos/qwen-nextjs/src/app/page.tsx @@ -1,30 +1,38 @@ 'use client'; - +import { useState, useEffect } from 'react' import { ProChat } from '@ant-design/pro-chat'; import { useTheme } from 'antd-style'; export default function Home() { + const theme = useTheme(); + const [showComponent, setShowComponent] = useState(false) + + useEffect(() => setShowComponent(true), []) + return (
- { - const response = await fetch('/api/qwen', { - method: 'POST', - body: JSON.stringify({ messages: messages }), - }); - const data = await response.json(); - return new Response(data.output?.text); - }} - /> + { + showComponent && { + const response = await fetch('/api/qwen', { + method: 'POST', + body: JSON.stringify({ messages: messages }), + }); + const data = await response.json(); + return new Response(data.output?.text); + }} + /> + }
); } + diff --git a/docs/guide/chatgpt.md b/docs/guide/chatgpt.md index 4dcc9549..782ee02c 100644 --- a/docs/guide/chatgpt.md +++ b/docs/guide/chatgpt.md @@ -59,36 +59,44 @@ export const POST = async (request: Request) => { ## 界面 ```ts -"use client"; - -import { ProChat } from "@ant-design/pro-chat"; -import { useTheme } from "antd-style"; +'use client'; +import { useState, useEffect } from 'react' +import { ProChat } from '@ant-design/pro-chat'; +import { useTheme } from 'antd-style'; export default function Home() { + const theme = useTheme(); + const [showComponent, setShowComponent] = useState(false) + + useEffect(() => setShowComponent(true), []) + return (
- ) => { - const response = await fetch("/api/openai", { - method: "POST", - body: JSON.stringify({ messages: messages }), - }); - - return response; - }} - /> + { + showComponent && { + const response = await fetch('/api/qwen', { + method: 'POST', + body: JSON.stringify({ messages: messages }), + }); + const data = await response.json(); + return new Response(data.output?.text); + }} + /> + }
); } + ``` ### 完整的代码 diff --git a/docs/guide/qwen.md b/docs/guide/qwen.md index 5c8d262d..e9c70ddc 100644 --- a/docs/guide/qwen.md +++ b/docs/guide/qwen.md @@ -89,33 +89,40 @@ export async function POST(request: Request) { 在你想要编写的页面上写入 ProChat 并拼接对应内容 ```ts -"use client"; - -import { useTheme } from "antd-style"; -import { ProChat } from "@ant-design/pro-chat"; +'use client'; +import { useState, useEffect } from 'react' +import { ProChat } from '@ant-design/pro-chat'; +import { useTheme } from 'antd-style'; export default function Home() { + const theme = useTheme(); + const [showComponent, setShowComponent] = useState(false) + + useEffect(() => setShowComponent(true), []) + return (
- { - const response = await fetch("/api/qwen", { - method: "POST", - body: JSON.stringify({ messages: messages }), - }); - const data = await response.json(); - return new Response(data.output?.text); - }} - /> + { + showComponent && { + const response = await fetch('/api/qwen', { + method: 'POST', + body: JSON.stringify({ messages: messages }), + }); + const data = await response.json(); + return new Response(data.output?.text); + }} + /> + }
); } From 0e04f7a7ffe0ba8f866a9c18d81622e52dc4c9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9F=E8=B4=A4?= Date: Thu, 18 Jan 2024 20:27:25 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=90=9B=20fix:=20ChatItem=20support=20?= =?UTF-8?q?originData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ChatItem/type.ts | 4 +++- src/ChatList/ChatListItem.tsx | 12 ++++++++---- src/ChatList/index.tsx | 7 ++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ChatItem/type.ts b/src/ChatItem/type.ts index c83efd56..dc54d0c5 100644 --- a/src/ChatItem/type.ts +++ b/src/ChatItem/type.ts @@ -6,7 +6,7 @@ import { DivProps, MetaData } from '@/types'; export type WithFalse = T | false; -export interface ChatItemProps { +export interface ChatItemProps> { /** * @description Actions to be displayed in the chat item */ @@ -97,4 +97,6 @@ export interface ChatItemProps { ) => ReactNode >; }; + + originData?: T; } diff --git a/src/ChatList/ChatListItem.tsx b/src/ChatList/ChatListItem.tsx index d0218f11..ca5d1a8c 100644 --- a/src/ChatList/ChatListItem.tsx +++ b/src/ChatList/ChatListItem.tsx @@ -19,7 +19,7 @@ export type RenderMessageExtra = FC; export type RenderErrorMessage = FC; export type RenderAction = FC; -export interface ListItemProps { +export interface ListItemProps> { groupNav?: ChatItemProps['avatarAddon']; loading?: boolean; /** @@ -85,16 +85,19 @@ export interface ListItemProps { * @description 聊天项的渲染函数 */ chatItemRenderConfig?: ChatItemProps['chatItemRenderConfig']; + + originData?: ChatItemProps['originData']; } -export type ChatListItemProps = ChatMessage & ListItemProps; +export type ChatListItemProps> = ChatMessage & ListItemProps; -const Item = (props: ChatListItemProps) => { +const ChatListItem = (props: ChatListItemProps) => { const { renderMessagesExtra, showTitle, onActionsClick, onMessageChange, + originData, type, text, renderMessages, @@ -204,6 +207,7 @@ const Item = (props: ChatListItemProps) => { avatar={(item as any).meta} avatarAddon={groupNav} editing={editing} + originData={originData} error={error} errorMessage={} loading={loading} @@ -237,4 +241,4 @@ const Item = (props: ChatListItemProps) => { return memoItem; }; -export default Item; +export default ChatListItem; diff --git a/src/ChatList/index.tsx b/src/ChatList/index.tsx index 6d92a71e..c74dc4a4 100644 --- a/src/ChatList/index.tsx +++ b/src/ChatList/index.tsx @@ -82,7 +82,12 @@ const ChatList = memo( > - + ); From 6ed7a04da042ff331f5aefb160436c5569e5c690 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 18 Jan 2024 13:20:16 +0000 Subject: [PATCH 5/8] :bookmark: chore(release): v1.4.3 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### [Version 1.4.3](https://github.com/ant-design/pro-chat/compare/v1.4.2...v1.4.3) Released on **2024-01-18** #### 🐛 修复 - ChatItem support originData.
Improvements and Fixes #### What's fixed * ChatItem support originData ([0e04f7a](https://github.com/ant-design/pro-chat/commit/0e04f7a))
[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
--- CHANGELOG.md | 25 +++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63ac0cbe..3aa504cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +### [Version 1.4.3](https://github.com/ant-design/pro-chat/compare/v1.4.2...v1.4.3) + +Released on **2024-01-18** + +#### 🐛 修复 + +- ChatItem support originData. + +
+ +
+Improvements and Fixes + +#### What's fixed + +- ChatItem support originData ([0e04f7a](https://github.com/ant-design/pro-chat/commit/0e04f7a)) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ ### [Version 1.4.2](https://github.com/ant-design/pro-chat/compare/v1.4.1...v1.4.2) Released on **2024-01-17** diff --git a/package.json b/package.json index cf49a75b..511ca904 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ant-design/pro-chat", - "version": "1.4.2", + "version": "1.4.3", "description": "a solution for ai chat", "keywords": [ "ai", From e021e7b99e427cc0decde1a081afad471373b9ed Mon Sep 17 00:00:00 2001 From: Scarqin Date: Fri, 19 Jan 2024 10:57:04 +0800 Subject: [PATCH 6/8] fix: chrome extension csp error (#47) --- src/ProChat/store/action.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/ProChat/store/action.ts b/src/ProChat/store/action.ts index 7dc570b7..2aefe746 100644 --- a/src/ProChat/store/action.ts +++ b/src/ProChat/store/action.ts @@ -142,7 +142,6 @@ export const chatAction: StateCreator{ + const compiler = template(config.inputTemplate, { interpolate: /{{([\S\s]+?)}}/g }); + return slicedMessages.map((m) => { + if (m.role === 'user') { + try { + return { ...m, content: compiler({ text: m.content }) }; + } catch (error) { + console.error(error); + + return m; + } + } + return m; + }); + } const postMessages = !config.inputTemplate ? slicedMessages - : slicedMessages.map((m) => { - if (m.role === 'user') { - try { - return { ...m, content: compiler({ text: m.content }) }; - } catch (error) { - console.error(error); - - return m; - } - } - return m; - }); + : compilerMessages(slicedMessages); // 3. 添加 systemRole if (config.systemRole) { From e77c39e66c56567bc6339b1cac3f780406ce5c52 Mon Sep 17 00:00:00 2001 From: Shinji-Li <1349021570@qq.com> Date: Fri, 19 Jan 2024 14:56:28 +0800 Subject: [PATCH 7/8] :bug: fix: Slove Editable Button was not work (#50) --- src/ChatItem/index.tsx | 1 - src/ChatList/ChatListItem.tsx | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ChatItem/index.tsx b/src/ChatItem/index.tsx index 9ddb7c2e..01ff2097 100644 --- a/src/ChatItem/index.tsx +++ b/src/ChatItem/index.tsx @@ -85,7 +85,6 @@ const ChatItem = memo((props) => { /> ); return chatItemRenderConfig?.contentRender?.(props, dom) || dom; - return; }, [ error, message, diff --git a/src/ChatList/ChatListItem.tsx b/src/ChatList/ChatListItem.tsx index ca5d1a8c..cef9b436 100644 --- a/src/ChatList/ChatListItem.tsx +++ b/src/ChatList/ChatListItem.tsx @@ -234,7 +234,14 @@ const ChatListItem = (props: ChatListItemProps) => { /> ); return dom; - }, [props.content, props.loading, props.id, (item as any).meta, item.updateAt || item.createAt]); + }, [ + props.content, + props.loading, + props.id, + (item as any).meta, + item.updateAt || item.createAt, + editing, + ]); if (RenderItem) return ; From 8e599843f1c8c88997fff01dc897f723dc0e90c9 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 19 Jan 2024 06:58:35 +0000 Subject: [PATCH 8/8] :bookmark: chore(release): v1.4.4 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### [Version 1.4.4](https://github.com/ant-design/pro-chat/compare/v1.4.3...v1.4.4) Released on **2024-01-19** #### 🐛 修复 - Slove Editable Button was not work.
Improvements and Fixes #### What's fixed * Slove Editable Button was not work, closes [#50](https://github.com/ant-design/pro-chat/issues/50) ([e77c39e](https://github.com/ant-design/pro-chat/commit/e77c39e))
[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
--- CHANGELOG.md | 25 +++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa504cd..1201fed6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +### [Version 1.4.4](https://github.com/ant-design/pro-chat/compare/v1.4.3...v1.4.4) + +Released on **2024-01-19** + +#### 🐛 修复 + +- Slove Editable Button was not work. + +
+ +
+Improvements and Fixes + +#### What's fixed + +- Slove Editable Button was not work, closes [#50](https://github.com/ant-design/pro-chat/issues/50) ([e77c39e](https://github.com/ant-design/pro-chat/commit/e77c39e)) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ ### [Version 1.4.3](https://github.com/ant-design/pro-chat/compare/v1.4.2...v1.4.3) Released on **2024-01-18** diff --git a/package.json b/package.json index 511ca904..6a04eeb5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ant-design/pro-chat", - "version": "1.4.3", + "version": "1.4.4", "description": "a solution for ai chat", "keywords": [ "ai",