feat: new agent center
This commit is contained in:
parent
00cf2d6b24
commit
af41cebe18
@ -73,6 +73,7 @@ export const PROVIDER_CONFIG = {
|
|||||||
baichuan: {
|
baichuan: {
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://www.baichuan-ai.com/',
|
official: 'https://www.baichuan-ai.com/',
|
||||||
|
apiKey: 'https://platform.baichuan-ai.com/console/apikey',
|
||||||
docs: 'https://platform.baichuan-ai.com/docs',
|
docs: 'https://platform.baichuan-ai.com/docs',
|
||||||
models: 'https://platform.baichuan-ai.com/price'
|
models: 'https://platform.baichuan-ai.com/price'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar'
|
import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar'
|
||||||
import { Button, Col, Row, Tooltip, Typography } from 'antd'
|
import { Col, Row, Typography } from 'antd'
|
||||||
import { find, groupBy } from 'lodash'
|
import { find, groupBy } from 'lodash'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { SystemAssistant } from '@renderer/types'
|
import { SystemAssistant } from '@renderer/types'
|
||||||
import { getDefaultAssistant } from '@renderer/services/assistant'
|
import { getDefaultAssistant } from '@renderer/services/assistant'
|
||||||
import { useAssistants } from '@renderer/hooks/useAssistant'
|
import { useAssistants } from '@renderer/hooks/useAssistant'
|
||||||
import { colorPrimary } from '@renderer/config/antd'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import SYSTEM_ASSISTANTS from '@renderer/config/assistants.json'
|
import SYSTEM_ASSISTANTS from '@renderer/config/assistants.json'
|
||||||
|
|
||||||
@ -20,6 +19,21 @@ const AppsPage: FC = () => {
|
|||||||
)
|
)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
const onAddAssistantConfirm = (assistant: SystemAssistant) => {
|
||||||
|
const added = find(assistants, { id: assistant.id })
|
||||||
|
|
||||||
|
window.modal.confirm({
|
||||||
|
title: assistant.name,
|
||||||
|
content: assistant.description || assistant.prompt,
|
||||||
|
icon: null,
|
||||||
|
closable: true,
|
||||||
|
maskClosable: true,
|
||||||
|
okButtonProps: { type: 'primary', disabled: Boolean(added) },
|
||||||
|
okText: added ? t('button.added') : t('button.add'),
|
||||||
|
onOk: () => onAddAssistant(assistant)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const onAddAssistant = (assistant: SystemAssistant) => {
|
const onAddAssistant = (assistant: SystemAssistant) => {
|
||||||
addAssistant({
|
addAssistant({
|
||||||
...getDefaultAssistant(),
|
...getDefaultAssistant(),
|
||||||
@ -39,47 +53,35 @@ const AppsPage: FC = () => {
|
|||||||
<NavbarCenter style={{ borderRight: 'none' }}>{t('apps.title')}</NavbarCenter>
|
<NavbarCenter style={{ borderRight: 'none' }}>{t('apps.title')}</NavbarCenter>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
<ContentContainer>
|
<ContentContainer>
|
||||||
{Object.keys(assistantGroups).map((group) => (
|
<AssistantsContainer>
|
||||||
<div key={group}>
|
{Object.keys(assistantGroups).map((group) => (
|
||||||
<Title level={3} key={group} style={{ marginBottom: 16 }}>
|
<div key={group}>
|
||||||
{group}
|
<Title level={3} key={group} style={{ marginBottom: 16 }}>
|
||||||
</Title>
|
{group}
|
||||||
<Row gutter={16}>
|
</Title>
|
||||||
{assistantGroups[group].map((assistant, index) => {
|
<Row gutter={16}>
|
||||||
const added = find(assistants, { id: assistant.id })
|
{assistantGroups[group].map((assistant, index) => {
|
||||||
return (
|
return (
|
||||||
<Col span={8} key={group + index}>
|
<Col span={8} key={group + index}>
|
||||||
<AssistantCard>
|
<AssistantCard onClick={() => onAddAssistantConfirm(assistant)}>
|
||||||
<EmojiHeader>{assistant.emoji}</EmojiHeader>
|
<EmojiHeader>{assistant.emoji}</EmojiHeader>
|
||||||
<Col>
|
<Col>
|
||||||
<AssistantHeader>
|
<AssistantHeader>
|
||||||
<AssistantName level={5} style={{ marginBottom: 0, color: colorPrimary }}>
|
<AssistantName level={5} style={{ marginBottom: 0 }}>
|
||||||
{assistant.name.replace(assistant.emoji + ' ', '')}
|
{assistant.name.replace(assistant.emoji + ' ', '')}
|
||||||
</AssistantName>
|
</AssistantName>
|
||||||
</AssistantHeader>
|
</AssistantHeader>
|
||||||
<AssistantCardPrompt>{assistant.prompt}</AssistantCardPrompt>
|
<AssistantCardPrompt>{assistant.prompt}</AssistantCardPrompt>
|
||||||
<Row>
|
</Col>
|
||||||
{added && (
|
</AssistantCard>
|
||||||
<Button type="default" size="small" disabled>
|
</Col>
|
||||||
{t('button.added')}
|
)
|
||||||
</Button>
|
})}
|
||||||
)}
|
</Row>
|
||||||
{!added && (
|
</div>
|
||||||
<Tooltip placement="top" title=" Add to assistant list " arrow>
|
))}
|
||||||
<Button type="default" size="small" onClick={() => onAddAssistant(assistant as any)}>
|
<div style={{ minHeight: 20 }} />
|
||||||
{t('button.add')}
|
</AssistantsContainer>
|
||||||
</Button>
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
</Row>
|
|
||||||
</Col>
|
|
||||||
</AssistantCard>
|
|
||||||
</Col>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</Row>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</ContentContainer>
|
</ContentContainer>
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
@ -92,41 +94,44 @@ const Container = styled.div`
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
`
|
`
|
||||||
|
|
||||||
const EmojiHeader = styled.div`
|
const ContentContainer = styled.div`
|
||||||
width: 36px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-right: 5px;
|
height: 100%;
|
||||||
font-size: 36px;
|
overflow-y: scroll;
|
||||||
line-height: 36px;
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const ContentContainer = styled.div`
|
const AssistantsContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: calc(100vh - var(--navbar-height));
|
height: calc(100vh - var(--navbar-height));
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
overflow-y: scroll;
|
max-width: 1000px;
|
||||||
`
|
`
|
||||||
|
|
||||||
const AssistantCard = styled.div`
|
const AssistantCard = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
background-color: #2b2b2b;
|
background-color: #111;
|
||||||
|
border: 0.5px solid #151515;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
`
|
`
|
||||||
|
const EmojiHeader = styled.div`
|
||||||
const AssistantName = styled(Title)`
|
width: 25px;
|
||||||
line-height: 1.5;
|
display: flex;
|
||||||
display: -webkit-box;
|
flex-direction: row;
|
||||||
-webkit-line-clamp: 1;
|
justify-content: center;
|
||||||
-webkit-box-orient: vertical;
|
align-items: center;
|
||||||
overflow: hidden;
|
margin-right: 5px;
|
||||||
|
font-size: 25px;
|
||||||
|
line-height: 25px;
|
||||||
`
|
`
|
||||||
|
|
||||||
const AssistantHeader = styled.div`
|
const AssistantHeader = styled.div`
|
||||||
@ -136,13 +141,22 @@ const AssistantHeader = styled.div`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
`
|
`
|
||||||
|
|
||||||
const AssistantCardPrompt = styled.div`
|
const AssistantName = styled(Title)`
|
||||||
color: #eee;
|
font-size: 18px;
|
||||||
margin-top: 10px;
|
line-height: 1.2;
|
||||||
margin-bottom: 10px;
|
|
||||||
line-height: 1.5;
|
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 4;
|
-webkit-line-clamp: 1;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 900;
|
||||||
|
`
|
||||||
|
|
||||||
|
const AssistantCardPrompt = styled.div`
|
||||||
|
color: #666;
|
||||||
|
margin-top: 6px;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 1;
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
`
|
`
|
||||||
|
|||||||
@ -55,6 +55,8 @@ export type Model = {
|
|||||||
export type SystemAssistant = {
|
export type SystemAssistant = {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
|
emoji: string
|
||||||
|
description?: string
|
||||||
prompt: string
|
prompt: string
|
||||||
group: string
|
group: string
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user