mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 13:19:33 +08:00
feat: add the "Export Agent" feature (#5789)
This commit is contained in:
parent
fcc52867c4
commit
759fa78a30
@ -25,6 +25,9 @@
|
|||||||
"invalid_format": "Invalid agent format: missing required fields"
|
"invalid_format": "Invalid agent format: missing required fields"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"export": {
|
||||||
|
"agent": "Export Agent"
|
||||||
|
},
|
||||||
"delete.popup.content": "Are you sure you want to delete this agent?",
|
"delete.popup.content": "Are you sure you want to delete this agent?",
|
||||||
"edit.message.add.title": "Add",
|
"edit.message.add.title": "Add",
|
||||||
"edit.message.assistant.placeholder": "Enter assistant message",
|
"edit.message.assistant.placeholder": "Enter assistant message",
|
||||||
@ -1634,4 +1637,4 @@
|
|||||||
"visualization": "Visualization"
|
"visualization": "Visualization"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,9 @@
|
|||||||
"invalid_format": "無効なエージェント形式:必須フィールドが不足しています"
|
"invalid_format": "無効なエージェント形式:必須フィールドが不足しています"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"export": {
|
||||||
|
"agent": "エージェントをエクスポート"
|
||||||
|
},
|
||||||
"delete.popup.content": "このエージェントを削除してもよろしいですか?",
|
"delete.popup.content": "このエージェントを削除してもよろしいですか?",
|
||||||
"edit.message.add.title": "追加",
|
"edit.message.add.title": "追加",
|
||||||
"edit.message.assistant.placeholder": "アシスタントのメッセージを入力",
|
"edit.message.assistant.placeholder": "アシスタントのメッセージを入力",
|
||||||
|
|||||||
@ -45,6 +45,9 @@
|
|||||||
"fetch_failed": "Не удалось получить данные по URL",
|
"fetch_failed": "Не удалось получить данные по URL",
|
||||||
"invalid_format": "Неверный формат агента: отсутствуют обязательные поля"
|
"invalid_format": "Неверный формат агента: отсутствуют обязательные поля"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"export": {
|
||||||
|
"agent": "Экспорт агента"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"assistants": {
|
"assistants": {
|
||||||
|
|||||||
@ -25,6 +25,9 @@
|
|||||||
"invalid_format": "无效的代理格式:缺少必填字段"
|
"invalid_format": "无效的代理格式:缺少必填字段"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"export": {
|
||||||
|
"agent": "导出智能体"
|
||||||
|
},
|
||||||
"delete.popup.content": "确定要删除此智能体吗?",
|
"delete.popup.content": "确定要删除此智能体吗?",
|
||||||
"edit.message.add.title": "添加",
|
"edit.message.add.title": "添加",
|
||||||
"edit.message.assistant.placeholder": "输入助手消息",
|
"edit.message.assistant.placeholder": "输入助手消息",
|
||||||
|
|||||||
@ -25,6 +25,9 @@
|
|||||||
"invalid_format": "無效的代理人格式:缺少必填欄位"
|
"invalid_format": "無效的代理人格式:缺少必填欄位"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"export": {
|
||||||
|
"agent": "匯出智慧代理人"
|
||||||
|
},
|
||||||
"delete.popup.content": "確定要刪除此智慧代理人嗎?",
|
"delete.popup.content": "確定要刪除此智慧代理人嗎?",
|
||||||
"edit.message.add.title": "新增",
|
"edit.message.add.title": "新增",
|
||||||
"edit.message.assistant.placeholder": "輸入助手訊息",
|
"edit.message.assistant.placeholder": "輸入助手訊息",
|
||||||
|
|||||||
@ -1,4 +1,11 @@
|
|||||||
import { DeleteOutlined, EditOutlined, EllipsisOutlined, PlusOutlined, SortAscendingOutlined } from '@ant-design/icons'
|
import {
|
||||||
|
DeleteOutlined,
|
||||||
|
EditOutlined,
|
||||||
|
EllipsisOutlined,
|
||||||
|
ExportOutlined,
|
||||||
|
PlusOutlined,
|
||||||
|
SortAscendingOutlined
|
||||||
|
} from '@ant-design/icons'
|
||||||
import CustomTag from '@renderer/components/CustomTag'
|
import CustomTag from '@renderer/components/CustomTag'
|
||||||
import { useAgents } from '@renderer/hooks/useAgents'
|
import { useAgents } from '@renderer/hooks/useAgents'
|
||||||
import AssistantSettingsPopup from '@renderer/pages/settings/AssistantSettings'
|
import AssistantSettingsPopup from '@renderer/pages/settings/AssistantSettings'
|
||||||
@ -35,6 +42,23 @@ const AgentCard: FC<Props> = ({ agent, onClick, activegroup, getLocalizedGroupNa
|
|||||||
[removeAgent]
|
[removeAgent]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const exportAgent = useCallback(async () => {
|
||||||
|
const result = {
|
||||||
|
name: agent.name,
|
||||||
|
emoji: agent.emoji,
|
||||||
|
group: agent.group,
|
||||||
|
prompt: agent.prompt,
|
||||||
|
description: agent.description,
|
||||||
|
type: 'agent'
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultStr = JSON.stringify(result, null, 2)
|
||||||
|
|
||||||
|
await window.api.file.save(`${agent.name}.json`, new TextEncoder().encode(resultStr), {
|
||||||
|
filters: [{ name: t('agents.import.file_filter'), extensions: ['json'] }]
|
||||||
|
})
|
||||||
|
}, [agent])
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{
|
{
|
||||||
key: 'edit',
|
key: 'edit',
|
||||||
@ -63,6 +87,15 @@ const AgentCard: FC<Props> = ({ agent, onClick, activegroup, getLocalizedGroupNa
|
|||||||
ManageAgentsPopup.show()
|
ManageAgentsPopup.show()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'export',
|
||||||
|
label: t('agents.export.agent'),
|
||||||
|
icon: <ExportOutlined />,
|
||||||
|
onClick: (e: any) => {
|
||||||
|
e.domEvent.stopPropagation()
|
||||||
|
exportAgent()
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
label: t('common.delete'),
|
label: t('common.delete'),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user