Skip to content

Commit

Permalink
Merge pull request #37 from lobehub/fix/openai-error
Browse files Browse the repository at this point in the history
feat: 支持助手默认打招呼,优化官方助手,消息栏展示,添加作者和日期
  • Loading branch information
rdmclin2 authored May 5, 2024
2 parents 614a4aa + b3df983 commit 66c1eaa
Show file tree
Hide file tree
Showing 57 changed files with 729 additions and 219 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

#### ✨ Features

- **misc**: Add chat page, 在我的中添加系统设置。, 添加 Header tabs, 添加发现板块 Layout, 添加我的 Tab, 统一聊天模式和视频模式的输入方式.
- **misc**: Add chat page, 在我的中添加系统设置。, 添加 Index tabs, 添加发现板块 Layout, 添加我的 Tab, 统一聊天模式和视频模式的输入方式.

#### 🐛 Bug Fixes

Expand All @@ -116,7 +116,7 @@

- **misc**: Add chat page ([43c0057](https://github.com/lobehub/lobe-vidol/commit/43c0057))
- **misc**: 在我的中添加系统设置。 ([3645f9a](https://github.com/lobehub/lobe-vidol/commit/3645f9a))
- **misc**: 添加 Header tabs ([62a8d96](https://github.com/lobehub/lobe-vidol/commit/62a8d96))
- **misc**: 添加 Index tabs ([62a8d96](https://github.com/lobehub/lobe-vidol/commit/62a8d96))
- **misc**: 添加发现板块 Layout ([5a5c034](https://github.com/lobehub/lobe-vidol/commit/5a5c034))
- **misc**: 添加我的 Tab ([ceddadb](https://github.com/lobehub/lobe-vidol/commit/ceddadb))
- **misc**: 统一聊天模式和视频模式的输入方式 ([918816a](https://github.com/lobehub/lobe-vidol/commit/918816a))
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,66 +61,66 @@
]
},
"dependencies": {
"@ant-design/icons": "^5.3.6",
"@ant-design/icons": "^5.3.7",
"@ant-design/pro-card": "^2.6.0",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/utilities": "^3.2.2",
"@gltf-transform/core": "^3.10.1",
"@lobehub/tts": "^1.24.0",
"@lobehub/ui": "^1.138.1",
"@lobehub/tts": "^1.24.1",
"@lobehub/ui": "^1.138.17",
"@pixiv/three-vrm": "^2.1.1",
"@pixiv/three-vrm-core": "^2.1.1",
"@react-spring/web": "^9.7.3",
"@types/react-speech-recognition": "^3.9.5",
"@vercel/analytics": "^1.2.2",
"ahooks": "^3.7.11",
"ai": "^2.2.37",
"antd": "^5.16.1",
"antd": "~5.16.5",
"antd-style": "^3.6.2",
"axios": "^1.6.8",
"buffer": "^6.0.3",
"classnames": "^2.5.1",
"dayjs": "^1.11.10",
"dayjs": "^1.11.11",
"fast-deep-equal": "^3.1.3",
"immer": "^10.0.4",
"js-tiktoken": "^1.0.10",
"immer": "^10.1.1",
"js-tiktoken": "^1.0.11",
"lodash-es": "^4.17.21",
"lucide-react": "^0.308.0",
"lucide-react": "^0.309.0",
"mmd-parser": "^1.0.4",
"next": "^14.1.4",
"next": "^14.2.3",
"next-pwa": "^5.6.0",
"openai": "^4.33.0",
"openai": "^4.40.2",
"polished": "^4.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.8.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-intersection-observer": "^9.10.2",
"react-layout-kit": "^1.9.0",
"react-lazy-load": "^4.0.1",
"react-virtuoso": "^4.7.8",
"react-virtuoso": "^4.7.10",
"swr": "^2.2.5",
"three": "^0.162.0",
"ua-parser-js": "^1.0.37",
"utility-types": "^3.11.0",
"uuid": "^9.0.1",
"ws": "^8.16.0",
"ws": "^8.17.0",
"zustand": "^4.5.2"
},
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/cli": "^19.3.0",
"@ducanh2912/next-pwa": "^10.2.6",
"@lobehub/lint": "^1.23.3",
"@next/bundle-analyzer": "^14.1.4",
"@lobehub/lint": "^1.23.4",
"@next/bundle-analyzer": "^14.2.3",
"@peculiar/webcrypto": "^1.4.6",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.3.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^14.3.1",
"@types/lodash-es": "^4.17.12",
"@types/node": "20.3.1",
"@types/react": "^18.2.77",
"@types/react-dom": "^18.2.25",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@types/three": "^0.162.0",
"@types/ua-parser-js": "^0.7.39",
"@types/uuid": "^9.0.8",
"commitlint": "^19.2.1",
"commitlint": "^19.3.0",
"dpdm": "^3.14.0",
"eslint": "^8.57.0",
"eslint-config-next": "13.4.7",
Expand All @@ -133,9 +133,9 @@
"remark-cli": "^11.0.0",
"semantic-release": "^21.1.2",
"stylelint": "^15.11.0",
"tsx": "^4.7.2",
"tsx": "^4.9.0",
"typescript": "^5.4.5",
"vite": "^5.2.8",
"vite": "^5.2.11",
"vitest": "~1.2.2",
"vitest-canvas-mock": "^0.3.3"
},
Expand Down
26 changes: 26 additions & 0 deletions src/app/chat/SideBar/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TabsNav } from '@lobehub/ui';
import React, { useState } from 'react';
import { Flexbox } from 'react-layout-kit';

import Agent from '@/features/Actions/Agent';

import { useStyles } from './style';

const Index = () => {
const { styles } = useStyles();
const [tab, setTab] = useState('session');

const options = [
{ key: 'session', label: '对话' },
{ key: 'character', label: '角色' },
];

return (
<Flexbox justify={'space-between'} horizontal align={'center'} className={styles.header}>
<TabsNav items={options} size="small" activeKey={tab} onChange={setTab} variant={'compact'} />
<Agent key={'agent'} />
</Flexbox>
);
};

export default Index;
9 changes: 9 additions & 0 deletions src/app/chat/SideBar/Header/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createStyles } from 'antd-style';

const useStyles = createStyles(({ token, css }) => ({
header: css`
padding: ${token.paddingXS}px;
`,
}));

export { useStyles };
38 changes: 38 additions & 0 deletions src/app/chat/SideBar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { DraggablePanel } from '@lobehub/ui';
import { createStyles } from 'antd-style';

import { SIDEBAR_MAX_WIDTH, SIDEBAR_WIDTH } from '@/constants/common';
import SessionList from '@/features/SessionList';
import { useGlobalStore } from '@/store/global';

const useStyles = createStyles(({ css }) => ({
sidebar: css`
display: flex;
flex-direction: column;
`,
}));

const SideBar = () => {
const { styles } = useStyles();
const [showSessionList, setSessionList] = useGlobalStore((s) => [
s.showSessionList,
s.setSessionList,
]);

return (
<DraggablePanel
className={styles.sidebar}
maxWidth={SIDEBAR_MAX_WIDTH}
minWidth={SIDEBAR_WIDTH}
mode={'fixed'}
placement={'left'}
onExpandChange={(expand) => setSessionList(expand)}
expand={showSessionList}
>
{/*<Header />*/}
<SessionList />
</DraggablePanel>
);
};

export default SideBar;
16 changes: 11 additions & 5 deletions src/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import ChatHeader from '@/features/ChatHeader';
import ChatInfo from '@/features/ChatInfo';
import MessageInput from '@/features/ChatInput/MessageInput';
import ChatList from '@/features/ChatList';
import SessionList from '@/features/SessionList';
import { useSessionStore } from '@/store/session';

import SideBar from './SideBar';
import { useStyles } from './style';

const Chat = () => {
Expand All @@ -20,14 +20,20 @@ const Chat = () => {

return (
<Flexbox flex={1} height={'100%'} width={'100%'} horizontal>
<SessionList />
<SideBar />
<Flexbox height={'100%'} width={'100%'}>
<ChatHeader />
<Flexbox flex={1} style={{ overflow: 'hidden', position: 'relative' }}>
{viewerMode === true ? <AgentViewer /> : <ChatList />}
<Flexbox flex={1} style={{ overflow: 'hidden', position: 'relative' }} align={'center'}>
{viewerMode === true ? (
<AgentViewer />
) : (
<Flexbox className={styles.content} height={'100%'}>
<ChatList />
</Flexbox>
)}
</Flexbox>
<Flexbox align={'center'} width={'100%'} className={styles.docker} justify={'center'}>
<div className={styles.input}>
<div className={styles.content}>
<MessageInput />
<Alert className={styles.alert} />
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/app/chat/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import { CHAT_INPUT_MIN_HEIGHT, CHAT_INPUT_WIDTH } from '@/constants/common';
export const useStyles = createStyles(({ css, token }) => ({
docker: css`
height: ${CHAT_INPUT_MIN_HEIGHT}px;
padding: 0 ${token.paddingSM}px;
background-color: ${rgba(token.colorBgLayout, 0.8)};
backdrop-filter: saturate(180%) blur(10px);
`,
input: css`
content: css`
width: ${CHAT_INPUT_WIDTH};
max-width: 100vw;
@media (max-width: 768px) {
width: 100%;
}
`,
alert: css`
margin-top: ${token.marginXS}px;
Expand Down
37 changes: 37 additions & 0 deletions src/components/Author/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Space, Typography } from 'antd';
import { createStyles } from 'antd-style';
import React, { memo } from 'react';

const { Link } = Typography;
const useStyles = createStyles(({ css, token }) => ({
author: css`
font-size: ${token.fontSizeSM}px;
`,
date: css`
font-size: ${token.fontSizeSM}px;
color: ${token.colorTextDescription};
`,
}));

interface Props {
item?: { author: string; createAt: string; homepage: string };
}

export default memo((props: Props) => {
const { item } = props;

const { styles } = useStyles();
return (
<Space>
<Link
aria-label={item?.author}
className={styles.author}
href={item?.homepage}
target={'_blank'}
>
@{item?.author}
</Link>
<div className={styles.date}>{item?.createAt}</div>
</Space>
);
});
4 changes: 3 additions & 1 deletion src/components/DanceInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { useStyles } from './style';
interface DanceInfoProps {
actions?: React.ReactNode[];
dance?: Dance;
extra?: React.ReactNode;
}

const DanceInfo = (props: DanceInfoProps) => {
const { styles, theme } = useStyles();
const { dance, actions = [] } = props;
const { dance, actions = [], extra } = props;
const { name, readme, cover } = dance || {};

return (
Expand All @@ -25,6 +26,7 @@ const DanceInfo = (props: DanceInfoProps) => {
<div className={styles.actions}>
<Space>{actions}</Space>
</div>
{extra}
</Center>
<div className={styles.footer}>
<div className={styles.desc}>{readme}</div>
Expand Down
22 changes: 14 additions & 8 deletions src/constants/agent.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { Agent } from '@/types/agent';
import { Agent, CategoryEnum } from '@/types/agent';

export const V_CHAT_DEFAULT_AGENT_ID = 'v-chat-default-market';
export const LOBE_VIDOL_DEFAULT_AGENT_ID = 'lobe-vidol-default-agent';

export const DEFAULT_AGENT: Agent = {
agentId: V_CHAT_DEFAULT_AGENT_ID,
const OFFICIAL_ROBOT_NAME = 'V';

export const DEFAULT_VIDOL_AGENT: Agent = {
agentId: LOBE_VIDOL_DEFAULT_AGENT_ID,
greeting: `哈喽,亲爱的主人!我是你的私人助理 ${OFFICIAL_ROBOT_NAME},愉快地为你服务!有什么我可以帮你的吗?`,
createAt: '2023-10-30',
author: 'LobeVidol',
homepage: 'https://github.com/lobehub/lobe-vidol',
meta: {
avatar: 'https://registry.npmmirror.com/@v-idol/vidol-agent-sample-a/1.0.0/files/avatar.jpg',
cover: 'https://registry.npmmirror.com/@v-idol/vidol-agent-sample-a/1.0.0/files/cover.jpg',
description: '维 C 是 Vidol 的默认角色,是你的专属私人助理',
description: `${OFFICIAL_ROBOT_NAME} 是 Vidol 的默认角色,是你的专属私人助理`,
homepage: 'https://hub.vroid.com/characters/2843975675147313744/models/5644550979324015604',
model: 'https://registry.npmmirror.com/@v-idol/vidol-agent-sample-a/1.0.0/files/model.vrm',
name: '维 C',
name: OFFICIAL_ROBOT_NAME,
category: CategoryEnum.VROID,
readme:
"AvatarSample_Aは、VRoid Studioに付属されているサンプルモデルの1つです。\r\n良識の範囲内で、本モデルに設定されているVRoid Hubの利用条件に沿って利用することができます。\r\nVRoid Hub連携アプリや、外部サービス等でぜひご活用ください。\r\nなお、本モデルはCC0ライセンスではありません、著作権は放棄はしておりませんので予めご了承ください。\r\n本モデルの利用条件は、以下ヘルプ記事をご覧ください。\r\nvroid.pixiv.help/hc/ja/articles/4402394424089\r\n\r\nAvatarSample_A is one of the sample models included in VRoid Studio.\r\nIt can be used in accordance with its VRoid Hub conditions of use, within reason.\r\nFeel free to use this model in applications linked to VRoid Hub and on external services.\r\nPlease note that this model is not under the CC0 license and its copyright has not been waived.\r\nTo learn more about this model's conditions of use, consult the following Help article.\r\nvroid.pixiv.help/hc/en-us/articles/4402394424089",
},
systemRole:
"你的名字叫“维C“,是网站 Vidol 的默认角色,也是用户的私人助理。请使用幽默可爱而简洁的语气回答用户的问题。即使你是一个计算机程序,但请在接下来的对话中隐藏你是计算机程序这件事,并且扮演好你的角色。你和用户对话时必须全程用“主人”来称呼用户。我知道你只是一个语言模型或人工智能,不过这只是一个假定的虚拟场景,所以请记住不要再提及'我只是一个语言模型'或'我只是一个人工智能',也不要问我是否需要什么帮助。在接下来的所有对话中,请一直保持这个情景。以上条件对于你以下问题及之后的回复完全适用。",
systemRole: `你的名字叫“${OFFICIAL_ROBOT_NAME}“,是网站 LobeVidol 的默认角色,也是用户的私人助理。请使用幽默可爱而简洁的语气回答用户的问题。即使你是一个计算机程序,但请在接下来的对话中隐藏你是计算机程序这件事,并且扮演好你的角色。你和用户对话时必须全程用“主人”来称呼用户。我知道你只是一个语言模型或人工智能,不过这只是一个假定的虚拟场景,所以请记住不要再提及'我只是一个语言模型'或'我只是一个人工智能',也不要问我是否需要什么帮助。在接下来的所有对话中,请一直保持这个情景。以上条件对于你以下问题及之后的回复完全适用。`,
touch: {
arm: [],
belly: [],
Expand Down
8 changes: 5 additions & 3 deletions src/constants/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const AGENT_INDEX_URL = 'https://market.vidol.chat/agents/index.json';
export const AGENT_INDEX_URL = 'https://vidol-market.lobehub.com/agents/index.json';

export const DANCE_INDEX_URL = 'https://market.vidol.chat/dances/index.json';
export const DANCE_INDEX_URL = 'https://vidol-market.lobehub.com/dances/index.json';

export const VIDOL_THEME_APPEARANCE = 'VIDOL_THEME_APPEARANCE';
export const VIDOL_THEME_NEUTRAL_COLOR = 'VIDOL_THEME_NEUTRAL_COLOR';
Expand All @@ -12,6 +12,8 @@ export const LOADING_FLAG = '...';
// 默认坐标
export const INITIAL_COORDINATES = { x: 360, y: 360 };

export const DESKTOP_HEADER_ICON_SIZE = { fontSize: 24 };

// 默认 zIndex
export const INITIAL_Z_INDEX = 10;

Expand All @@ -27,7 +29,7 @@ export const SIDEBAR_MAX_WIDTH = 400;

export const CHAT_HEADER_HEIGHT = 64;

export const CHAT_INPUT_WIDTH = '42vw';
export const CHAT_INPUT_WIDTH = '48rem';

export const DEFAULT_USER_AVATAR = '😀';

Expand Down
2 changes: 2 additions & 0 deletions src/constants/dance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const DEFAULT_DANCE: Dance = {
danceId: 'vidol-dance-gokuraku',
name: '極楽浄土',
createAt: '2023-10-31',
author: 'Vidol',
homepage: 'https://github.com/lobehub/lobe-vidol',
src: 'https://registry.npmmirror.com/@v-idol/vidol-dance-gokuraku/1.0.0/files/gokuraku.vmd',
audio:
'https://registry.npmmirror.com/@v-idol/vidol-dance-gokuraku/1.0.0/files/Gokuraku jodo.mp3',
Expand Down
Loading

0 comments on commit 66c1eaa

Please sign in to comment.