fix(web): tool's api response change
This commit is contained in:
@@ -72,7 +72,7 @@ export const en = {
|
||||
modelManagement: 'Model Management',
|
||||
memoryStore: 'Memory Store',
|
||||
apiParameters: 'API Parameters',
|
||||
userMemory: 'User Memory',
|
||||
userMemory: 'Memory Store',
|
||||
memberManagement: 'Member Management',
|
||||
memorySummary: 'Memory Summary',
|
||||
memoryConversation: 'Memory Validation',
|
||||
@@ -1211,6 +1211,8 @@ export const en = {
|
||||
hire_date: 'Hire Date',
|
||||
memoryContent: 'Memory Content',
|
||||
created_at: 'Created At',
|
||||
updated_at: 'Updated At',
|
||||
fullScreen: 'Full Screen',
|
||||
|
||||
memoryWindow: "{{name}}'s Window of Memory",
|
||||
memory_insight: 'Overall Overview',
|
||||
@@ -1237,7 +1239,7 @@ export const en = {
|
||||
unix: 'items',
|
||||
completeMemory: 'Complete Memory',
|
||||
relationshipEvolution: 'Relationship Evolution',
|
||||
timelineMemories: 'Shared Memory Timeline',
|
||||
timelineMemories: 'Long-term Memory',
|
||||
emotionLine: 'Emotion Changes Over Time',
|
||||
interaction: 'Interaction Frequency & Relationship Stages',
|
||||
timelines_memory: 'All',
|
||||
@@ -1600,11 +1602,9 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
|
||||
enterJson: 'Enter JSON',
|
||||
jsonPlaceholder: 'Enter JSON data, e.g.: {"name": "test", "value": 123}',
|
||||
clear: 'Clear',
|
||||
parse: 'Paste',
|
||||
format: 'Format',
|
||||
minify: 'Minify',
|
||||
validate: 'Validate',
|
||||
convert: 'Escape',
|
||||
paste: 'Paste',
|
||||
parse: 'Parse',
|
||||
json_path: 'JSON Path Parameters',
|
||||
outputResult: 'Output Result',
|
||||
validJosn: 'JSON format is correct, validation passed!',
|
||||
|
||||
@@ -1923,7 +1923,8 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
|
||||
variableConfig: 'Variable Configuration',
|
||||
variableRequired: 'Required',
|
||||
addMessage: 'Add Message',
|
||||
answerDesc: 'Reply'
|
||||
answerDesc: 'Reply',
|
||||
addNode: 'Add Node',
|
||||
},
|
||||
emotionEngine: {
|
||||
emotionEngineConfig: 'Emotion Engine Configuration',
|
||||
|
||||
@@ -72,7 +72,7 @@ export const zh = {
|
||||
modelManagement: '模型管理',
|
||||
memoryStore: '记忆存储',
|
||||
apiParameters: 'API参数',
|
||||
userMemory: '用户记忆',
|
||||
userMemory: '记忆库',
|
||||
memberManagement: '成员管理',
|
||||
memorySummary: '记忆摘要',
|
||||
memoryConversation: '记忆验证',
|
||||
@@ -87,7 +87,7 @@ export const zh = {
|
||||
knowledgeShare: '详情',
|
||||
knowledgeCreateDataset: '新建数据集',
|
||||
knowledgeDocumentDetails: '详情',
|
||||
userMemoryDetail: '用户记忆详情',
|
||||
userMemoryDetail: '记忆库详情',
|
||||
toolManagement: '工具管理',
|
||||
emotionEngine: '情感引擎',
|
||||
statementDetail: '情绪记忆',
|
||||
@@ -1292,7 +1292,7 @@ export const zh = {
|
||||
updated_at: '最后更新时间',
|
||||
fullScreen: '全屏',
|
||||
|
||||
memoryWindow: "{{name}}的记忆之窗",
|
||||
memoryWindow: "{{name}} 的记忆之窗",
|
||||
memory_insight: '总体概述',
|
||||
key_findings: '关键发现',
|
||||
behavior_pattern: '行为模式',
|
||||
@@ -1317,7 +1317,7 @@ export const zh = {
|
||||
unix: '个',
|
||||
completeMemory: '完整记忆',
|
||||
relationshipEvolution: '关系演化',
|
||||
timelineMemories: '共同记忆时间线',
|
||||
timelineMemories: '长期记忆',
|
||||
emotionLine: '情绪随时间变化',
|
||||
interaction: '互动频率 & 关系阶段',
|
||||
timelines_memory: '全部',
|
||||
@@ -1698,11 +1698,9 @@ export const zh = {
|
||||
enterJson: '输入JSON',
|
||||
jsonPlaceholder: '输入JSON数据,例如:{"name": "测试", "value": 123}',
|
||||
clear: '清空',
|
||||
parse: '粘贴',
|
||||
format: '格式化',
|
||||
minify: '压缩',
|
||||
validate: '验证',
|
||||
convert: '转义',
|
||||
paste: '粘贴',
|
||||
parse: '解析',
|
||||
json_path: 'JSON 路径参数',
|
||||
outputResult: '输出结果',
|
||||
validJosn: 'JSON格式正确,验证通过!',
|
||||
|
||||
@@ -2022,7 +2020,8 @@ export const zh = {
|
||||
variableConfig: '变量配置',
|
||||
variableRequired: '必填',
|
||||
addMessage: '添加消息',
|
||||
answerDesc: '回复'
|
||||
answerDesc: '回复',
|
||||
addNode: '添加节点',
|
||||
},
|
||||
emotionEngine: {
|
||||
emotionEngineConfig: '情感引擎配置',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||
import { Form, Input, Button, Space, Tree } from 'antd';
|
||||
import { Form, Input, Button, Space } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { TreeDataNode } from 'antd';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { execute } from '@/api/tools';
|
||||
const JsonToolModal = forwardRef<JsonToolModalRef>((_props, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [form] = Form.useForm<{ json: string; }>();
|
||||
const [form] = Form.useForm<{ json: string; json_path: string; }>();
|
||||
const [data, setData] = useState<ToolItem>({} as ToolItem)
|
||||
const [formatValue, setFormatValue] = useState<string | Record<string, any> | null>(null)
|
||||
|
||||
@@ -60,44 +60,29 @@ const JsonToolModal = forwardRef<JsonToolModalRef>((_props, ref) => {
|
||||
}
|
||||
const handleOperate = (type: string) => {
|
||||
const json = form.getFieldValue('json')
|
||||
const json_path = form.getFieldValue('json_path')
|
||||
if (!json || !data.id) return
|
||||
let params: ExecuteData = {
|
||||
tool_id: data.id,
|
||||
parameters: {
|
||||
operation: type,
|
||||
input_data: json
|
||||
input_data: json,
|
||||
json_path
|
||||
}
|
||||
}
|
||||
if (type === 'format') {
|
||||
if (type === 'parse') {
|
||||
params = {
|
||||
...params,
|
||||
parameters: {
|
||||
...params.parameters,
|
||||
indent: 2,
|
||||
ensure_ascii: false,
|
||||
sort_keys: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execute(params)
|
||||
.then(res => {
|
||||
const { data } = res as {data: {
|
||||
formatted_json: string;
|
||||
minified_json: string;
|
||||
is_valid: boolean;
|
||||
converted_json: string;
|
||||
error: string;
|
||||
structure: Record<string, string | number>
|
||||
}}
|
||||
switch (type) {
|
||||
case 'format':
|
||||
setFormatValue(data.formatted_json);
|
||||
break
|
||||
case 'minify':
|
||||
setFormatValue(data.minified_json)
|
||||
break
|
||||
}
|
||||
const { data } = res as { data: string; }
|
||||
setFormatValue(data);
|
||||
})
|
||||
}
|
||||
const clear = () => {
|
||||
@@ -126,15 +111,20 @@ const JsonToolModal = forwardRef<JsonToolModalRef>((_props, ref) => {
|
||||
label={<Space size={8}>
|
||||
{t('tool.enterJson')}
|
||||
<Button onClick={clear}>{t('tool.clear')}</Button>
|
||||
<Button onClick={handleParse}>{t('tool.parse')}</Button>
|
||||
<Button onClick={handleParse}>{t('tool.paste')}</Button>
|
||||
</Space>}
|
||||
>
|
||||
<Input.TextArea rows={10} placeholder={t('tool.jsonPlaceholder')} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
name="json_path"
|
||||
label={t('tool.json_path')}
|
||||
>
|
||||
<Input placeholder={t('common.pleaseEnter')} />
|
||||
</FormItem>
|
||||
|
||||
<Space size={8} className="rb:mb-3">
|
||||
<Button onClick={() => handleOperate('format')}>{t('tool.format')}</Button>
|
||||
<Button onClick={() => handleOperate('minify')}>{t('tool.minify')}</Button>
|
||||
<Button onClick={() => handleOperate('parse')}>{t('tool.parse')}</Button>
|
||||
</Space>
|
||||
<FormItem
|
||||
label={t('tool.outputResult')}
|
||||
|
||||
@@ -23,6 +23,7 @@ interface CurrentTimeObj {
|
||||
iso_format: string;
|
||||
timestamp: string;
|
||||
timestamp_ms: string;
|
||||
utc_datetime: string;
|
||||
}
|
||||
const TimeToolModal = forwardRef<TimeToolModalRef>((_props, ref) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -88,8 +89,8 @@ const TimeToolModal = forwardRef<TimeToolModalRef>((_props, ref) => {
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
const response = res as { data: CurrentTimeObj }
|
||||
setTimestampFormat(response.data.datetime)
|
||||
const response = res as { data: string }
|
||||
setTimestampFormat(response.data)
|
||||
})
|
||||
}
|
||||
const handleChangeFormatType = () => {
|
||||
@@ -149,7 +150,7 @@ const TimeToolModal = forwardRef<TimeToolModalRef>((_props, ref) => {
|
||||
<Input disabled value={currentTime?.datetime} />
|
||||
</FormItem>
|
||||
<FormItem label={t('tool.utcTime')} >
|
||||
<Input disabled value={currentTime?.iso_format} />
|
||||
<Input disabled value={currentTime?.utc_datetime} />
|
||||
</FormItem>
|
||||
<FormItem label={t('tool.secondsTimestamp')} >
|
||||
<Input disabled value={currentTime?.timestamp} />
|
||||
|
||||
@@ -130,6 +130,7 @@ export interface ExecuteData {
|
||||
ensure_ascii?: boolean;
|
||||
sort_keys?: boolean;
|
||||
input_data?: string;
|
||||
json_path?: string;
|
||||
}
|
||||
}
|
||||
export interface CustomToolModalRef {
|
||||
|
||||
Reference in New Issue
Block a user