fix: agents sort
This commit is contained in:
parent
2143a6614e
commit
057efbf98c
@ -4,7 +4,7 @@ import Scrollbar from '@renderer/components/Scrollbar'
|
|||||||
import SystemAgents from '@renderer/config/agents.json'
|
import SystemAgents from '@renderer/config/agents.json'
|
||||||
import { createAssistantFromAgent } from '@renderer/services/assistant'
|
import { createAssistantFromAgent } from '@renderer/services/assistant'
|
||||||
import { Agent } from '@renderer/types'
|
import { Agent } from '@renderer/types'
|
||||||
import { sortByEnglishFirst, uuid } from '@renderer/utils'
|
import { uuid } from '@renderer/utils'
|
||||||
import { Col, Empty, Input, Row, Tabs as TabsAntd, Typography } from 'antd'
|
import { Col, Empty, Input, Row, Tabs as TabsAntd, Typography } from 'antd'
|
||||||
import { groupBy, omit } from 'lodash'
|
import { groupBy, omit } from 'lodash'
|
||||||
import { FC, useCallback, useMemo, useState } from 'react'
|
import { FC, useCallback, useMemo, useState } from 'react'
|
||||||
@ -96,34 +96,32 @@ const AgentsPage: FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tabItems = useMemo(() => {
|
const tabItems = useMemo(() => {
|
||||||
return Object.keys(filteredAgentGroups)
|
let groups = Object.keys(filteredAgentGroups)
|
||||||
.sort(sortByEnglishFirst)
|
groups = groups.filter((g) => g !== '办公')
|
||||||
.map((group, i) => {
|
groups = ['办公', ...groups]
|
||||||
const id = String(i + 1)
|
return groups.map((group, i) => {
|
||||||
return {
|
const id = String(i + 1)
|
||||||
label: group,
|
return {
|
||||||
key: id,
|
label: group,
|
||||||
children: (
|
key: id,
|
||||||
<TabContent key={group}>
|
children: (
|
||||||
<Title level={5} key={group} style={{ marginBottom: 16 }}>
|
<TabContent key={group}>
|
||||||
{group}
|
<Title level={5} key={group} style={{ marginBottom: 16 }}>
|
||||||
</Title>
|
{group}
|
||||||
<Row gutter={16}>
|
</Title>
|
||||||
{filteredAgentGroups[group].map((agent, index) => {
|
<Row gutter={16}>
|
||||||
return (
|
{filteredAgentGroups[group].map((agent, index) => {
|
||||||
<Col span={8} key={group + index}>
|
return (
|
||||||
<AgentCard
|
<Col span={8} key={group + index}>
|
||||||
onClick={() => onAddAgentConfirm(getAgentFromSystemAgent(agent))}
|
<AgentCard onClick={() => onAddAgentConfirm(getAgentFromSystemAgent(agent))} agent={agent as any} />
|
||||||
agent={agent as any}
|
</Col>
|
||||||
/>
|
)
|
||||||
</Col>
|
})}
|
||||||
)
|
</Row>
|
||||||
})}
|
</TabContent>
|
||||||
</Row>
|
)
|
||||||
</TabContent>
|
}
|
||||||
)
|
})
|
||||||
}
|
|
||||||
})
|
|
||||||
}, [filteredAgentGroups, onAddAgentConfirm])
|
}, [filteredAgentGroups, onAddAgentConfirm])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -15,7 +15,9 @@ const AgentCard: React.FC<Props> = ({ agent, onClick }) => {
|
|||||||
<AgentHeader>
|
<AgentHeader>
|
||||||
<AgentName style={{ marginBottom: 0 }}>{agent.name}</AgentName>
|
<AgentName style={{ marginBottom: 0 }}>{agent.name}</AgentName>
|
||||||
</AgentHeader>
|
</AgentHeader>
|
||||||
<AgentCardPrompt className="text-nowrap">{agent.description || agent.prompt}</AgentCardPrompt>
|
<AgentCardPrompt className="text-nowrap">
|
||||||
|
{(agent.description || agent.prompt).substring(0, 20)}
|
||||||
|
</AgentCardPrompt>
|
||||||
</Col>
|
</Col>
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user