V4.14.1 feature (#5880)
Some checks are pending
Document deploy / sync-images (push) Waiting to run
Document deploy / generate-timestamp (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.cn suffix:cn]) (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.io suffix:io]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.cn kube_config:KUBE_CONFIG_CN suffix:cn]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.io kube_config:KUBE_CONFIG_IO suffix:io]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / get-vars (push) Waiting to run
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:amd64 runs-on:ubuntu-24.04]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / release-fastgpt-images (push) Blocked by required conditions
* feat: app split (#5858) * feat: app split script * fix: app split * chore: app split script try-catch * adjust dashborad page (#5872) * create page * create page * create button * router name * bot * template * create page * mobile * toolfolder * fix * fix * fix build * split tool select * img * doc * rename enum * fix page adjust (#5883) * fix page adjust * fix ad store * fix: initv4141 (#5886) * fix: create app * doc * hide api * doc * feat: payment pause interactive (#5892) * fix: copy clbs (#5889) * fix: copy clbs * fix: copy clbs * fix: http protocol handling in baseURL (#5890) * fix: http protocol handling in baseURL * ui fix * auto saved version * fix * auto save * fix: model permission modal (#5895) * folder * fix: del app * navbar * fix: plugin file selector (#5893) * fix: plugin file selector * fix: plugin file selector * workflow tool inputform * pick --------- Co-authored-by: archer <545436317@qq.com> * fix: workflow tool time * doc * fix workorder button (#5896) * add inform track (#5897) * remove invalid track * comment * feat: marketplace refresh api (#5884) * marketplace refresh * fix: helper bot menu button (#5898) --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: 伍闲犬 <whoeverimf5@gmail.com>
|
|
@ -133,7 +133,7 @@ export default i18n;
|
|||
export const pageNamespaces: Record<string, string[]> = {
|
||||
// 应用相关
|
||||
'/app/detail': ['app', 'chat', 'workflow', 'publish', 'file'],
|
||||
'/dashboard/apps': ['app'],
|
||||
'/dashboard/agent': ['app'],
|
||||
|
||||
// 数据集相关
|
||||
'/dataset/list': ['dataset'],
|
||||
|
|
@ -583,7 +583,7 @@ P0 - 高频访问页面 (优先迁移):
|
|||
- /app/detail (应用编辑页)
|
||||
- /dataset/list (数据集列表)
|
||||
- /dataset/detail (数据集详情)
|
||||
- /dashboard/apps (应用列表)
|
||||
- /dashboard/agent (应用列表)
|
||||
|
||||
P1 - 中频访问页面:
|
||||
- /account/setting (账户设置)
|
||||
|
|
@ -810,7 +810,7 @@ import { test, expect } from '@playwright/test';
|
|||
|
||||
test.describe('i18n Performance', () => {
|
||||
test('should load translations within 200ms', async ({ page }) => {
|
||||
await page.goto('http://localhost:3000/dashboard/apps');
|
||||
await page.goto('http://localhost:3000/dashboard/agent');
|
||||
|
||||
const startTime = Date.now();
|
||||
|
||||
|
|
@ -826,7 +826,7 @@ test.describe('i18n Performance', () => {
|
|||
});
|
||||
|
||||
test('should switch routes without translation flash', async ({ page }) => {
|
||||
await page.goto('http://localhost:3000/dashboard/apps');
|
||||
await page.goto('http://localhost:3000/dashboard/agent');
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// 点击链接切换路由
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ export async function getServerSideProps(content: any) {
|
|||
};
|
||||
}
|
||||
|
||||
// projects/app/src/pages/dashboard/apps/index.tsx:344
|
||||
// projects/app/src/pages/dashboard/agent/index.tsx:344
|
||||
export async function getServerSideProps(content: any) {
|
||||
return {
|
||||
props: {
|
||||
|
|
@ -317,7 +317,7 @@ const { loading: loadingApp, runAsync: reloadApp } = useRequest2(
|
|||
refreshDeps: [appId],
|
||||
errorToast: t('common:core.app.error.Get app failed'),
|
||||
onError(err: any) {
|
||||
router.replace('/dashboard/apps');
|
||||
router.replace('/dashboard/agent');
|
||||
},
|
||||
onSuccess(res) {
|
||||
setAppDetail(res);
|
||||
|
|
@ -585,7 +585,7 @@ import i18n from './client';
|
|||
const pageNamespaces = {
|
||||
'/app/detail': ['app', 'chat', 'workflow'],
|
||||
'/dataset/list': ['dataset'],
|
||||
'/dashboard/apps': ['app'],
|
||||
'/dashboard/agent': ['app'],
|
||||
// ... 更多映射
|
||||
};
|
||||
|
||||
|
|
@ -1321,7 +1321,7 @@ import { test, expect } from '@playwright/test';
|
|||
|
||||
test.describe('Route Switching Performance', () => {
|
||||
test('should switch routes within 500ms', async ({ page }) => {
|
||||
await page.goto('http://localhost:3000/dashboard/apps');
|
||||
await page.goto('http://localhost:3000/dashboard/agent');
|
||||
|
||||
// 等待页面完全加载
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,534 @@
|
|||
---
|
||||
name: workflow-interactive-dev
|
||||
description: 用于开发 FastGPT 工作流中的交互响应。详细说明了交互节点的架构、开发流程和需要修改的文件。
|
||||
---
|
||||
|
||||
# 交互节点开发指南
|
||||
|
||||
## 概述
|
||||
|
||||
FastGPT 工作流支持多种交互节点类型,允许在工作流执行过程中暂停并等待用户输入。本指南详细说明了如何开发新的交互节点。
|
||||
|
||||
## 现有交互节点类型
|
||||
|
||||
当前系统支持以下交互节点类型:
|
||||
|
||||
1. **userSelect** - 用户选择节点(单选)
|
||||
2. **formInput** - 表单输入节点(多字段表单)
|
||||
3. **childrenInteractive** - 子工作流交互
|
||||
4. **loopInteractive** - 循环交互
|
||||
5. **paymentPause** - 欠费暂停交互
|
||||
|
||||
## 交互节点架构
|
||||
|
||||
### 核心类型定义
|
||||
|
||||
交互节点的类型定义位于 `packages/global/core/workflow/template/system/interactive/type.d.ts`
|
||||
|
||||
```typescript
|
||||
// 基础交互结构
|
||||
type InteractiveBasicType = {
|
||||
entryNodeIds: string[]; // 入口节点ID列表
|
||||
memoryEdges: RuntimeEdgeItemType[]; // 需要记忆的边
|
||||
nodeOutputs: NodeOutputItemType[]; // 节点输出
|
||||
skipNodeQueue?: Array; // 跳过的节点队列
|
||||
usageId?: string; // 用量记录ID
|
||||
};
|
||||
|
||||
// 具体交互节点类型
|
||||
type YourInteractiveNode = InteractiveNodeType & {
|
||||
type: 'yourNodeType';
|
||||
params: {
|
||||
// 节点特定参数
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### 工作流执行机制
|
||||
|
||||
交互节点在工作流执行中的特殊处理(位于 `packages/service/core/workflow/dispatch/index.ts:1012-1019`):
|
||||
|
||||
```typescript
|
||||
// 部分交互节点不会自动重置 isEntry 标志(因为需要根据 isEntry 字段来判断是首次进入还是流程进入)
|
||||
runtimeNodes.forEach((item) => {
|
||||
if (
|
||||
item.flowNodeType !== FlowNodeTypeEnum.userSelect &&
|
||||
item.flowNodeType !== FlowNodeTypeEnum.formInput &&
|
||||
item.flowNodeType !== FlowNodeTypeEnum.agent
|
||||
) {
|
||||
item.isEntry = false;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## 开发新交互响应的步骤
|
||||
|
||||
### 步骤 1: 定义节点类型
|
||||
|
||||
**文件**: `packages/global/core/workflow/template/system/interactive/type.d.ts`
|
||||
|
||||
```typescript
|
||||
export type YourInputItemType = {
|
||||
// 定义输入项的结构
|
||||
key: string;
|
||||
label: string;
|
||||
value: any;
|
||||
// ... 其他字段
|
||||
};
|
||||
|
||||
type YourInteractiveNode = InteractiveNodeType & {
|
||||
type: 'yourNodeType';
|
||||
params: {
|
||||
description: string;
|
||||
yourInputField: YourInputItemType[];
|
||||
submitted?: boolean; // 可选:是否已提交
|
||||
};
|
||||
};
|
||||
|
||||
// 添加到联合类型
|
||||
export type InteractiveNodeResponseType =
|
||||
| UserSelectInteractive
|
||||
| UserInputInteractive
|
||||
| YourInteractiveNode // 新增
|
||||
| ChildrenInteractive
|
||||
| LoopInteractive
|
||||
| PaymentPauseInteractive;
|
||||
```
|
||||
|
||||
### 步骤 2: 定义节点枚举(可选)
|
||||
|
||||
**文件**: `packages/global/core/workflow/node/constant.ts`
|
||||
|
||||
如果不需要添加新的节点类型,则不需要修改这个文件。
|
||||
|
||||
```typescript
|
||||
export enum FlowNodeTypeEnum {
|
||||
// ... 现有类型
|
||||
yourNodeType = 'yourNodeType', // 新增节点类型
|
||||
}
|
||||
```
|
||||
|
||||
### 步骤 3: 创建节点模板(可选)
|
||||
|
||||
**文件**: `packages/global/core/workflow/template/system/interactive/yourNode.ts`
|
||||
|
||||
```typescript
|
||||
import { i18nT } from '../../../../../../web/i18n/utils';
|
||||
import {
|
||||
FlowNodeTemplateTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
NodeOutputKeyEnum,
|
||||
WorkflowIOValueTypeEnum
|
||||
} from '../../../constants';
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../../type/node';
|
||||
|
||||
export const YourNode: FlowNodeTemplateType = {
|
||||
id: FlowNodeTypeEnum.yourNodeType,
|
||||
templateType: FlowNodeTemplateTypeEnum.interactive,
|
||||
flowNodeType: FlowNodeTypeEnum.yourNodeType,
|
||||
showSourceHandle: true, // 是否显示源连接点
|
||||
showTargetHandle: true, // 是否显示目标连接点
|
||||
avatar: 'core/workflow/template/yourNode',
|
||||
name: i18nT('app:workflow.your_node'),
|
||||
intro: i18nT('app:workflow.your_node_tip'),
|
||||
isTool: true, // 标记为工具节点
|
||||
inputs: [
|
||||
{
|
||||
key: NodeInputKeyEnum.description,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.textarea],
|
||||
valueType: WorkflowIOValueTypeEnum.string,
|
||||
label: i18nT('app:workflow.node_description'),
|
||||
placeholder: i18nT('app:workflow.your_node_placeholder')
|
||||
},
|
||||
{
|
||||
key: NodeInputKeyEnum.yourInputField,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.custom],
|
||||
valueType: WorkflowIOValueTypeEnum.any,
|
||||
label: '',
|
||||
value: [] // 默认值
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
id: NodeOutputKeyEnum.yourResult,
|
||||
key: NodeOutputKeyEnum.yourResult,
|
||||
required: true,
|
||||
label: i18nT('workflow:your_result'),
|
||||
valueType: WorkflowIOValueTypeEnum.object,
|
||||
type: FlowNodeOutputTypeEnum.static
|
||||
}
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
### 步骤 4: 创建节点执行逻辑或在需要处理交互逻辑的节点上增加新逻辑
|
||||
|
||||
**文件**: `packages/service/core/workflow/dispatch/interactive/yourNode.ts`
|
||||
|
||||
```typescript
|
||||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import type {
|
||||
DispatchNodeResultType,
|
||||
ModuleDispatchProps
|
||||
} from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import type { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import type { YourInputItemType } from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
|
||||
|
||||
type Props = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.description]: string;
|
||||
[NodeInputKeyEnum.yourInputField]: YourInputItemType[];
|
||||
}>;
|
||||
|
||||
type YourNodeResponse = DispatchNodeResultType<{
|
||||
[NodeOutputKeyEnum.yourResult]?: Record<string, any>;
|
||||
}>;
|
||||
|
||||
export const dispatchYourNode = async (props: Props): Promise<YourNodeResponse> => {
|
||||
const {
|
||||
histories,
|
||||
node,
|
||||
params: { description, yourInputField },
|
||||
query,
|
||||
lastInteractive
|
||||
} = props;
|
||||
const { isEntry } = node;
|
||||
|
||||
// 第一阶段:非入口节点或不是对应的交互类型,返回交互请求
|
||||
if (!isEntry || lastInteractive?.type !== 'yourNodeType') {
|
||||
return {
|
||||
[DispatchNodeResponseKeyEnum.interactive]: {
|
||||
type: 'yourNodeType',
|
||||
params: {
|
||||
description,
|
||||
yourInputField
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 第二阶段:处理用户提交的数据
|
||||
node.isEntry = false; // 重要:重置入口标志
|
||||
|
||||
const { text } = chatValue2RuntimePrompt(query);
|
||||
const userInputVal = (() => {
|
||||
try {
|
||||
return JSON.parse(text); // 根据实际格式解析
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
data: {
|
||||
[NodeOutputKeyEnum.yourResult]: userInputVal
|
||||
},
|
||||
// 移除当前交互的历史记录(最后2条)
|
||||
[DispatchNodeResponseKeyEnum.rewriteHistories]: histories.slice(0, -2),
|
||||
[DispatchNodeResponseKeyEnum.toolResponses]: userInputVal,
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
yourResult: userInputVal
|
||||
}
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### 步骤 5: 注册节点回调
|
||||
|
||||
**文件**: `packages/service/core/workflow/dispatch/constants.ts`
|
||||
|
||||
```typescript
|
||||
import { dispatchYourNode } from './interactive/yourNode';
|
||||
|
||||
export const callbackMap: Record<FlowNodeTypeEnum, any> = {
|
||||
// ... 现有节点
|
||||
[FlowNodeTypeEnum.yourNodeType]: dispatchYourNode,
|
||||
};
|
||||
```
|
||||
|
||||
### 步骤 6: 创建前端渲染组件
|
||||
|
||||
#### 6.1 聊天界面交互组件
|
||||
|
||||
**文件**: `projects/app/src/components/core/chat/components/Interactive/InteractiveComponents.tsx`
|
||||
|
||||
```typescript
|
||||
export const YourNodeComponent = React.memo(function YourNodeComponent({
|
||||
interactiveParams: { description, yourInputField, submitted },
|
||||
defaultValues = {},
|
||||
SubmitButton
|
||||
}: {
|
||||
interactiveParams: YourInteractiveNode['params'];
|
||||
defaultValues?: Record<string, any>;
|
||||
SubmitButton: (e: { onSubmit: UseFormHandleSubmit<Record<string, any>> }) => React.JSX.Element;
|
||||
}) {
|
||||
const { handleSubmit, control } = useForm({
|
||||
defaultValues
|
||||
});
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<DescriptionBox description={description} />
|
||||
<Flex flexDirection={'column'} gap={3}>
|
||||
{yourInputField.map((input) => (
|
||||
<Box key={input.key}>
|
||||
{/* 渲染你的输入组件 */}
|
||||
<Controller
|
||||
control={control}
|
||||
name={input.key}
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<YourInputComponent
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
isDisabled={submitted}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Box>
|
||||
))}
|
||||
</Flex>
|
||||
|
||||
{!submitted && (
|
||||
<Flex justifyContent={'flex-end'} mt={4}>
|
||||
<SubmitButton onSubmit={handleSubmit} />
|
||||
</Flex>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
#### 6.2 工作流编辑器节点组件
|
||||
|
||||
**文件**: `projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeYourNode.tsx`
|
||||
|
||||
```typescript
|
||||
import React, { useMemo } from 'react';
|
||||
import { type NodeProps } from 'reactflow';
|
||||
import { Box, Button } from '@chakra-ui/react';
|
||||
import NodeCard from './render/NodeCard';
|
||||
import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d';
|
||||
import Container from '../components/Container';
|
||||
import RenderInput from './render/RenderInput';
|
||||
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import IOTitle from '../components/IOTitle';
|
||||
import RenderOutput from './render/RenderOutput';
|
||||
import { WorkflowActionsContext } from '../../context/workflowActionsContext';
|
||||
|
||||
const NodeYourNode = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
||||
const { t } = useTranslation();
|
||||
const { nodeId, inputs, outputs } = data;
|
||||
const onChangeNode = useContextSelector(WorkflowActionsContext, (v) => v.onChangeNode);
|
||||
|
||||
const CustomComponent = useMemo(
|
||||
() => ({
|
||||
[NodeInputKeyEnum.yourInputField]: (v: FlowNodeInputItemType) => {
|
||||
// 自定义渲染逻辑
|
||||
return (
|
||||
<Box>
|
||||
{/* 你的自定义UI */}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
}),
|
||||
[nodeId, onChangeNode, t]
|
||||
);
|
||||
|
||||
return (
|
||||
<NodeCard minW={'400px'} selected={selected} {...data}>
|
||||
<Container>
|
||||
<RenderInput nodeId={nodeId} flowInputList={inputs} CustomComponent={CustomComponent} />
|
||||
</Container>
|
||||
<Container>
|
||||
<IOTitle text={t('common:Output')} />
|
||||
<RenderOutput nodeId={nodeId} flowOutputList={outputs} />
|
||||
</Container>
|
||||
</NodeCard>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(NodeYourNode);
|
||||
```
|
||||
|
||||
### 步骤 7: 注册节点组件
|
||||
|
||||
需要在节点注册表中添加你的节点组件(具体位置根据项目配置而定)。
|
||||
|
||||
### 步骤 8: 添加国际化
|
||||
|
||||
**文件**: `packages/web/i18n/zh-CN/app.json` 和其他语言文件
|
||||
|
||||
```json
|
||||
{
|
||||
"workflow": {
|
||||
"your_node": "你的节点名称",
|
||||
"your_node_tip": "节点功能说明",
|
||||
"your_node_placeholder": "提示文本"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 步骤9 调整保存对话记录逻辑
|
||||
|
||||
**文件**: `FastGPT/packages/service/core/chat/saveChat.ts`
|
||||
|
||||
修改 `updateInteractiveChat` 方法,支持新的交互
|
||||
|
||||
### 步骤10 根据历史记录获取/设置交互状态
|
||||
|
||||
**文件**: `FastGPT/projects/app/src/components/core/chat/ChatContainer/ChatBox/utils.ts`
|
||||
**文件**: `FastGPT/packages/global/core/workflow/runtime/utils.ts`
|
||||
|
||||
调整`setInteractiveResultToHistories`, `getInteractiveByHistories` 和 `getLastInteractiveValue`方法。
|
||||
|
||||
## 关键注意事项
|
||||
|
||||
### 1. isEntry 标志管理
|
||||
|
||||
交互节点需要保持 `isEntry` 标志在工作流恢复时有效:
|
||||
|
||||
```typescript
|
||||
// 在 packages/service/core/workflow/dispatch/index.ts 中
|
||||
// 确保你的节点类型被添加到白名单
|
||||
if (
|
||||
item.flowNodeType !== FlowNodeTypeEnum.userSelect &&
|
||||
item.flowNodeType !== FlowNodeTypeEnum.formInput &&
|
||||
item.flowNodeType !== FlowNodeTypeEnum.yourNodeType // 新增
|
||||
) {
|
||||
item.isEntry = false;
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 交互响应流程
|
||||
|
||||
交互节点有两个执行阶段:
|
||||
|
||||
1. **第一次执行**: 返回 `interactive` 响应,暂停工作流
|
||||
2. **第二次执行**: 接收用户输入,继续工作流
|
||||
|
||||
```typescript
|
||||
// 第一阶段
|
||||
if (!isEntry || lastInteractive?.type !== 'yourNodeType') {
|
||||
return {
|
||||
[DispatchNodeResponseKeyEnum.interactive]: {
|
||||
type: 'yourNodeType',
|
||||
params: { /* ... */ }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 第二阶段
|
||||
node.isEntry = false; // 重要!重置标志
|
||||
// 处理用户输入...
|
||||
```
|
||||
|
||||
### 3. 历史记录管理
|
||||
|
||||
交互节点需要正确处理历史记录:
|
||||
|
||||
```typescript
|
||||
return {
|
||||
// 移除交互对话的历史记录(用户问题 + 系统响应)
|
||||
[DispatchNodeResponseKeyEnum.rewriteHistories]: histories.slice(0, -2),
|
||||
// ... 其他返回值
|
||||
};
|
||||
```
|
||||
|
||||
### 4. Skip 节点队列
|
||||
|
||||
交互节点触发时,系统会保存 `skipNodeQueue` 以便恢复时跳过已处理的节点。
|
||||
|
||||
### 5. 工具调用支持
|
||||
|
||||
如果节点需要在工具调用中使用,设置 `isTool: true`。
|
||||
|
||||
## 测试清单
|
||||
|
||||
开发完成后,请测试以下场景:
|
||||
|
||||
- [ ] 节点在工作流编辑器中正常显示
|
||||
- [ ] 节点配置保存和加载正确
|
||||
- [ ] 交互请求正确发送到前端
|
||||
- [ ] 前端组件正确渲染交互界面
|
||||
- [ ] 用户输入正确传回后端
|
||||
- [ ] 工作流正确恢复并继续执行
|
||||
- [ ] 历史记录正确更新
|
||||
- [ ] 节点输出正确连接到后续节点
|
||||
- [ ] 错误情况处理正确
|
||||
- [ ] 多语言支持完整
|
||||
|
||||
## 参考实现
|
||||
|
||||
可以参考以下现有实现:
|
||||
|
||||
1. **简单单选**: `userSelect` 节点
|
||||
- 类型定义: `packages/global/core/workflow/template/system/interactive/type.d.ts:48-55`
|
||||
- 执行逻辑: `packages/service/core/workflow/dispatch/interactive/userSelect.ts`
|
||||
- 前端组件: `projects/app/src/components/core/chat/components/Interactive/InteractiveComponents.tsx:29-63`
|
||||
|
||||
2. **复杂表单**: `formInput` 节点
|
||||
- 类型定义: `packages/global/core/workflow/template/system/interactive/type.d.ts:57-82`
|
||||
- 执行逻辑: `packages/service/core/workflow/dispatch/interactive/formInput.ts`
|
||||
- 前端组件: `projects/app/src/components/core/chat/components/Interactive/InteractiveComponents.tsx:65-126`
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Q: 交互节点执行了两次?
|
||||
A: 这是正常的。第一次返回交互请求,第二次处理用户输入。确保在第二次执行时设置 `node.isEntry = false`。
|
||||
|
||||
### Q: 工作流恢复后没有继续执行?
|
||||
A: 检查你的节点类型是否在 `isEntry` 白名单中(dispatch/index.ts:1013-1018)。
|
||||
|
||||
### Q: 用户输入格式不对?
|
||||
A: 检查 `chatValue2RuntimePrompt` 的返回值,根据你的数据格式进行解析。
|
||||
|
||||
### Q: 如何支持多个交互节点串联?
|
||||
A: 每个交互节点都会暂停工作流,用户完成后会自动继续到下一个节点。
|
||||
|
||||
## 文件清单总结
|
||||
|
||||
开发新交互节点需要修改/创建以下文件:
|
||||
|
||||
### 后端核心文件
|
||||
1. `packages/global/core/workflow/template/system/interactive/type.d.ts` - 类型定义
|
||||
2. `packages/global/core/workflow/node/constant.ts` - 节点枚举
|
||||
3. `packages/global/core/workflow/template/system/interactive/yourNode.ts` - 节点模板
|
||||
4. `packages/service/core/workflow/dispatch/interactive/yourNode.ts` - 执行逻辑
|
||||
5. `packages/service/core/workflow/dispatch/constants.ts` - 回调注册
|
||||
6. `packages/service/core/workflow/dispatch/index.ts` - isEntry 白名单
|
||||
|
||||
### 前端组件文件
|
||||
7. `projects/app/src/components/core/chat/components/Interactive/InteractiveComponents.tsx` - 聊天交互组件
|
||||
8. `projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodeYourNode.tsx` - 工作流编辑器组件
|
||||
|
||||
### 国际化文件
|
||||
9. `packages/web/i18n/zh-CN/app.json` - 中文翻译
|
||||
10. `packages/web/i18n/en/app.json` - 英文翻译
|
||||
11. `packages/web/i18n/zh-Hant/app.json` - 繁体中文翻译
|
||||
|
||||
## 附录:关键输入输出键定义
|
||||
|
||||
如果需要新的输入输出键,在以下文件中定义:
|
||||
|
||||
**文件**: `packages/global/core/workflow/constants.ts`
|
||||
|
||||
```typescript
|
||||
export enum NodeInputKeyEnum {
|
||||
// ... 现有键
|
||||
yourInputKey = 'yourInputKey',
|
||||
}
|
||||
|
||||
export enum NodeOutputKeyEnum {
|
||||
// ... 现有键
|
||||
yourOutputKey = 'yourOutputKey',
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,475 @@
|
|||
---
|
||||
name: create-skill-file
|
||||
description: Guides Claude in creating well-structured SKILL.md files following best practices. Provides clear guidelines for naming, structure, and content organization to make skills easy to discover and execute.
|
||||
---
|
||||
|
||||
# Claude Agent Skill 编写规范
|
||||
|
||||
> 如何创建高质量的 SKILL.md 文件
|
||||
|
||||
## 目录
|
||||
|
||||
- [快速开始](#快速开始)
|
||||
- [核心原则](#核心原则)
|
||||
- [文件结构规范](#文件结构规范)
|
||||
- [命名和描述规范](#命名和描述规范)
|
||||
- [内容编写指南](#内容编写指南)
|
||||
- [质量检查清单](#质量检查清单)
|
||||
|
||||
---
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 3步创建 Skill
|
||||
|
||||
**第1步: 创建目录**
|
||||
|
||||
```bash
|
||||
mkdir -p .claude/skill/your-skill-name
|
||||
cd .claude/skill/your-skill-name
|
||||
```
|
||||
|
||||
**第2步: 创建 SKILL.md**
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: your-skill-name
|
||||
description: Brief description with trigger keywords and scenarios
|
||||
---
|
||||
|
||||
# Your Skill Title
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to [specific scenario]
|
||||
- User mentions "[keyword]"
|
||||
|
||||
## How It Works
|
||||
|
||||
1. Step 1: [Action]
|
||||
2. Step 2: [Action]
|
||||
|
||||
## Examples
|
||||
|
||||
**Input**: User request
|
||||
**Output**: Expected result
|
||||
```
|
||||
|
||||
**第3步: 测试**
|
||||
- 在对话中使用 description 中的关键词触发
|
||||
- 观察 Claude 是否正确执行
|
||||
- 根据效果调整
|
||||
|
||||
---
|
||||
|
||||
## 核心原则
|
||||
|
||||
### 1. 保持简洁
|
||||
|
||||
只添加 Claude **不知道**的新知识:
|
||||
- ✅ 项目特定的工作流程
|
||||
- ✅ 特殊的命名规范或格式要求
|
||||
- ✅ 自定义工具和脚本的使用方法
|
||||
- ❌ 通用编程知识
|
||||
- ❌ 显而易见的步骤
|
||||
|
||||
**示例对比**:
|
||||
|
||||
```markdown
|
||||
# ❌ 过度详细
|
||||
1. 创建 Python 文件
|
||||
2. 导入必要的库
|
||||
3. 定义函数
|
||||
4. 编写主程序逻辑
|
||||
|
||||
# ✅ 简洁有效
|
||||
使用 `scripts/api_client.py` 调用内部 API。
|
||||
请求头必须包含 `X-Internal-Token`(从环境变量 `INTERNAL_API_KEY` 获取)。
|
||||
```
|
||||
|
||||
### 2. 设定合适的自由度
|
||||
|
||||
| 自由度 | 适用场景 | 编写方式 |
|
||||
|--------|---------|---------|
|
||||
| **高** | 需要创造性、多种解决方案 | 提供指导原则,不限定具体步骤 |
|
||||
| **中** | 有推荐模式但允许变化 | 提供参数化示例和默认流程 |
|
||||
| **低** | 容易出错、需严格执行 | 提供详细的分步指令或脚本 |
|
||||
|
||||
**判断标准**:
|
||||
- 任务是否有明确的"正确答案"? → 低自由度
|
||||
- 是否需要适应不同场景? → 高自由度
|
||||
- 错误的代价有多大? → 代价高则用低自由度
|
||||
|
||||
### 3. 渐进式披露
|
||||
|
||||
将复杂内容分层组织:
|
||||
|
||||
```
|
||||
SKILL.md (主文档, 200-500行)
|
||||
├── reference.md (详细文档)
|
||||
├── examples.md (完整示例)
|
||||
└── scripts/ (可执行脚本)
|
||||
```
|
||||
|
||||
**规则**:
|
||||
- SKILL.md 超过 500行 → 拆分子文件
|
||||
- 子文件超过 100行 → 添加目录
|
||||
- 引用深度 ≤ 1层
|
||||
|
||||
---
|
||||
|
||||
## 文件结构规范
|
||||
|
||||
### YAML Frontmatter
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: skill-name-here
|
||||
description: Clear description of what this skill does and when to activate it
|
||||
---
|
||||
```
|
||||
|
||||
**字段规范**:
|
||||
|
||||
| 字段 | 要求 | 说明 |
|
||||
|------|------|------|
|
||||
| `name` | 小写字母、数字、短横线,≤64字符 | 必须与目录名一致 |
|
||||
| `description` | 纯文本,≤1024字符 | 用于检索和激活 |
|
||||
|
||||
**命名禁忌**:
|
||||
- ❌ XML 标签、保留字(`anthropic`, `claude`)
|
||||
- ❌ 模糊词汇(`helper`, `utility`, `manager`)
|
||||
- ❌ 空格或下划线(用短横线 `-`)
|
||||
|
||||
**Description 技巧**:
|
||||
|
||||
```yaml
|
||||
# ❌ 过于泛化
|
||||
description: Helps with code tasks
|
||||
|
||||
# ✅ 具体且包含关键词
|
||||
description: Processes CSV files and generates Excel reports with charts. Use when user asks to convert data formats or create visual reports.
|
||||
|
||||
# ✅ 说明触发场景
|
||||
description: Analyzes Python code for security vulnerabilities using bandit. Activates when user mentions "security audit" or "vulnerability scan".
|
||||
```
|
||||
|
||||
### 目录组织
|
||||
|
||||
**基础结构**(简单 Skill):
|
||||
```
|
||||
skill-name/
|
||||
└── SKILL.md
|
||||
```
|
||||
|
||||
**标准结构**(推荐):
|
||||
```
|
||||
skill-name/
|
||||
├── SKILL.md
|
||||
├── templates/
|
||||
│ └── template.md
|
||||
└── scripts/
|
||||
└── script.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 命名和描述规范
|
||||
|
||||
### Skill 命名
|
||||
|
||||
**推荐格式**: 动名词形式 (verb-ing + noun)
|
||||
|
||||
```
|
||||
✅ 好的命名:
|
||||
- processing-csv-files
|
||||
- generating-api-docs
|
||||
- managing-database-migrations
|
||||
|
||||
❌ 不好的命名:
|
||||
- csv (过于简短)
|
||||
- data_processor (使用下划线)
|
||||
- helper (过于模糊)
|
||||
```
|
||||
|
||||
### Description 编写
|
||||
|
||||
**必须使用第三人称**:
|
||||
|
||||
```yaml
|
||||
# ❌ 错误
|
||||
description: I help you process PDFs
|
||||
|
||||
# ✅ 正确
|
||||
description: Processes PDF documents and extracts structured data
|
||||
```
|
||||
|
||||
**4C 原则**:
|
||||
- **Clear** (清晰): 避免术语和模糊词汇
|
||||
- **Concise** (简洁): 1-2句话说明核心功能
|
||||
- **Contextual** (上下文): 说明适用场景
|
||||
- **Complete** (完整): 功能 + 触发条件
|
||||
|
||||
---
|
||||
|
||||
## 内容编写指南
|
||||
|
||||
### "When to Use" 章节
|
||||
|
||||
明确说明触发场景:
|
||||
|
||||
```markdown
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to analyze Python code for type errors
|
||||
- User mentions "mypy" or "type checking"
|
||||
- User is working in a Python project with type hints
|
||||
- User needs to add type annotations
|
||||
```
|
||||
|
||||
**模式**:
|
||||
- 直接请求: "User asks to X"
|
||||
- 关键词: "User mentions 'keyword'"
|
||||
- 上下文: "User is working with X"
|
||||
- 任务类型: "User needs to X"
|
||||
|
||||
### 工作流设计
|
||||
|
||||
**简单线性流程**:
|
||||
|
||||
```markdown
|
||||
## How It Works
|
||||
|
||||
1. Scan the project for all `.py` files
|
||||
2. Run `mypy --strict` on each file
|
||||
3. Parse error output and categorize by severity
|
||||
4. Generate summary report with fix suggestions
|
||||
```
|
||||
|
||||
**条件分支流程**:
|
||||
|
||||
```markdown
|
||||
## Workflow
|
||||
|
||||
1. **Check project type**
|
||||
- If Django → Use `django-stubs` config
|
||||
- If Flask → Use `flask-stubs` config
|
||||
- Otherwise → Use default mypy config
|
||||
|
||||
2. **Run type checking**
|
||||
- If errors found → Proceed to step 3
|
||||
- If no errors → Report success and exit
|
||||
```
|
||||
|
||||
**Checklist 模式**(验证型任务):
|
||||
|
||||
```markdown
|
||||
## Pre-deployment Checklist
|
||||
|
||||
Execute in order. Stop if any step fails.
|
||||
|
||||
- [ ] Run tests: `npm test` (must pass)
|
||||
- [ ] Build: `npm run build` (no errors)
|
||||
- [ ] Check deps: `npm audit` (no critical vulnerabilities)
|
||||
```
|
||||
|
||||
### 示例和模板
|
||||
|
||||
**输入-输出示例**:
|
||||
|
||||
```markdown
|
||||
## Examples
|
||||
|
||||
### Example 1: Basic Check
|
||||
|
||||
**User Request**: "Check my code for type errors"
|
||||
|
||||
**Action**:
|
||||
1. Scan for `.py` files
|
||||
2. Run `mypy` on all files
|
||||
|
||||
**Output**:
|
||||
|
||||
Found 3 type errors in 2 files:
|
||||
src/main.py:15: error: Missing return type
|
||||
src/utils.py:42: error: Incompatible types
|
||||
|
||||
```
|
||||
|
||||
### 脚本集成
|
||||
|
||||
**何时使用脚本**:
|
||||
- 简单命令 → 直接在 SKILL.md 中说明
|
||||
- 复杂流程 → 提供独立脚本
|
||||
|
||||
**脚本编写规范**:
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Brief description of what this script does.
|
||||
|
||||
Usage:
|
||||
python script.py <arg> [--option value]
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
||||
DEFAULT_VALUE = 80 # Use constants, not magic numbers
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("directory", help="Directory to process")
|
||||
parser.add_argument("--threshold", type=int, default=DEFAULT_VALUE)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Validate inputs
|
||||
if not Path(args.directory).is_dir():
|
||||
print(f"Error: {args.directory} not found")
|
||||
return 1
|
||||
|
||||
# Execute
|
||||
result = process(args.directory, args.threshold)
|
||||
|
||||
# Report
|
||||
print(f"Processed {result['count']} files")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
```
|
||||
|
||||
**关键规范**:
|
||||
- ✅ Shebang 行和 docstring
|
||||
- ✅ 类型注解和常量
|
||||
- ✅ 参数验证和错误处理
|
||||
- ✅ 清晰的返回值(0=成功, 1=失败)
|
||||
|
||||
### 最佳实践
|
||||
|
||||
**Do**:
|
||||
- ✅ 提供可执行的命令和脚本
|
||||
- ✅ 包含输入-输出示例
|
||||
- ✅ 说明验证标准和成功条件
|
||||
- ✅ 包含 Do/Don't 清单
|
||||
|
||||
**Don't**:
|
||||
- ❌ 包含 Claude 已知的通用知识
|
||||
- ❌ 使用抽象描述而非具体步骤
|
||||
- ❌ 遗漏错误处理指导
|
||||
- ❌ 示例使用伪代码而非真实代码
|
||||
|
||||
---
|
||||
|
||||
## 质量检查清单
|
||||
|
||||
### 核心质量
|
||||
|
||||
- [ ] `name` 符合命名规范(小写、短横线、≤64字符)
|
||||
- [ ] `description` 包含触发关键词和场景(≤1024字符)
|
||||
- [ ] 名称与目录名一致
|
||||
- [ ] 只包含 Claude 不知道的信息
|
||||
- [ ] 没有冗余或重复内容
|
||||
|
||||
### 功能完整性
|
||||
|
||||
- [ ] 有"When to Use"章节,列出 3-5 个触发场景
|
||||
- [ ] 有清晰的执行流程或步骤
|
||||
- [ ] 至少 2-3 个完整示例
|
||||
- [ ] 包含输入和预期输出
|
||||
- [ ] 错误处理有指导
|
||||
|
||||
### 结构规范
|
||||
|
||||
- [ ] 章节组织清晰
|
||||
- [ ] 超过 200行有目录导航
|
||||
- [ ] 引用层级 ≤ 1层
|
||||
- [ ] 所有路径使用正斜杠 `/`
|
||||
- [ ] 术语使用一致
|
||||
|
||||
### 脚本和模板
|
||||
|
||||
- [ ] 脚本包含使用说明和参数文档
|
||||
- [ ] 脚本有错误处理
|
||||
- [ ] 避免魔法数字,使用配置
|
||||
- [ ] 模板格式清晰易用
|
||||
|
||||
### 最终检查
|
||||
|
||||
- [ ] 通读全文,确保流畅易读
|
||||
- [ ] 使用实际场景测试触发
|
||||
- [ ] 长度适中(200-500行,或已拆分)
|
||||
|
||||
---
|
||||
|
||||
## 常见问题
|
||||
|
||||
**Q: Skill 多长才合适?**
|
||||
- 最小: 50-100行
|
||||
- 理想: 200-500行
|
||||
- 最大: 500行(超过则拆分)
|
||||
|
||||
**Q: 如何让 Skill 更容易激活?**
|
||||
- 在 `description` 中使用用户会说的关键词
|
||||
- 说明具体场景("when user asks to X")
|
||||
- 提及相关工具名称
|
||||
|
||||
**Q: 多个 Skill 功能重叠怎么办?**
|
||||
- 使用更具体的 `description` 区分
|
||||
- 在"When to Use"中说明关系
|
||||
- 考虑合并为一个 Skill
|
||||
|
||||
**Q: Skill 需要维护吗?**
|
||||
- 每季度审查一次,更新过时信息
|
||||
- 根据使用反馈迭代
|
||||
- 工具或 API 变更时及时更新
|
||||
|
||||
---
|
||||
|
||||
## 快速参考
|
||||
|
||||
### Frontmatter 模板
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: skill-name
|
||||
description: Brief description with trigger keywords
|
||||
---
|
||||
```
|
||||
|
||||
### 基础结构模板
|
||||
|
||||
```markdown
|
||||
# Skill Title
|
||||
|
||||
## When to Use This Skill
|
||||
- Scenario 1
|
||||
- Scenario 2
|
||||
|
||||
## How It Works
|
||||
1. Step 1
|
||||
2. Step 2
|
||||
|
||||
## Examples
|
||||
### Example 1
|
||||
...
|
||||
|
||||
## References
|
||||
- [Link](url)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 相关资源
|
||||
|
||||
- [Claude Agent Skills 官方文档](https://docs.claude.com/en/docs/agents-and-tools/agent-skills)
|
||||
- [Best Practices Checklist](https://docs.claude.com/en/docs/agents-and-tools/agent-skills/best-practices)
|
||||
- [模板文件](templates/) - 开箱即用的模板
|
||||
- [基础 skill 的模板](templates/basic-skill-template.md)
|
||||
- [工作流 skill 的模板](templates/workflow-skill-template.md)
|
||||
- [示例库](examples/) - 完整的 Skill 示例
|
||||
- [优秀示例](examples/good-example.md)
|
||||
- [常见错误示例](examples/bad-example.md)
|
||||
|
||||
---
|
||||
|
|
@ -0,0 +1,867 @@
|
|||
# 不好的 Skill 示例与改进建议
|
||||
|
||||
本文档展示常见的 Skill 编写错误,并提供改进建议。
|
||||
|
||||
---
|
||||
|
||||
## 示例 1: 过于模糊的 Skill
|
||||
|
||||
### ❌ 不好的版本
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: helper
|
||||
description: Helps with code
|
||||
---
|
||||
|
||||
# Code Helper
|
||||
|
||||
This skill helps you with coding tasks.
|
||||
|
||||
## Usage
|
||||
|
||||
Use this when you need help with code.
|
||||
|
||||
## How It Works
|
||||
|
||||
1. Analyzes your code
|
||||
2. Provides suggestions
|
||||
3. Helps improve it
|
||||
```
|
||||
|
||||
### 问题分析
|
||||
|
||||
| 问题 | 说明 | 影响 |
|
||||
|------|------|------|
|
||||
| **模糊的名称** | "helper" 太泛化,没有说明具体做什么 | Claude 不知道何时激活 |
|
||||
| **无关键词** | description 缺少具体触发词 | 用户很难激活这个 Skill |
|
||||
| **无具体场景** | 没说明适用什么类型的代码 | 适用范围不清 |
|
||||
| **抽象的步骤** | "Provides suggestions" 太模糊 | Claude 不知道具体做什么 |
|
||||
| **无示例** | 没有实际例子 | 用户和 Claude 都不清楚预期输出 |
|
||||
|
||||
### ✅ 改进版本
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: python-code-refactoring
|
||||
description: Refactors Python code to improve readability and maintainability using standard patterns. Activates when user asks to clean up code, improve structure, or mentions refactoring. Focuses on function extraction, variable naming, and removing code smells.
|
||||
---
|
||||
|
||||
# Python Code Refactoring Skill
|
||||
|
||||
Improves Python code quality through systematic refactoring.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to "refactor this code", "clean up this function", or "improve readability"
|
||||
- User mentions "code smell", "technical debt", or "maintainability"
|
||||
- User is working with Python code that has:
|
||||
- Long functions (>50 lines)
|
||||
- Nested conditionals (>3 levels)
|
||||
- Repeated code patterns
|
||||
- Unclear variable names
|
||||
|
||||
## How It Works
|
||||
|
||||
### 1. Identify Refactoring Opportunities
|
||||
|
||||
Scan code for common issues:
|
||||
- Functions longer than 50 lines
|
||||
- Repeated code blocks (DRY violations)
|
||||
- Magic numbers without constants
|
||||
- Unclear variable names (x, temp, data)
|
||||
- Deep nesting (>3 levels)
|
||||
|
||||
### 2. Prioritize Changes
|
||||
|
||||
Focus on high-impact refactorings:
|
||||
- **High**: Extract complex nested logic to functions
|
||||
- **Medium**: Rename unclear variables
|
||||
- **Low**: Minor style improvements
|
||||
|
||||
### 3. Apply Refactorings
|
||||
|
||||
**Extract Method**:
|
||||
```python
|
||||
# Before
|
||||
def process_order(order):
|
||||
# 50 lines of validation logic
|
||||
# 30 lines of payment processing
|
||||
# 20 lines of email notification
|
||||
|
||||
# After
|
||||
def process_order(order):
|
||||
validate_order(order)
|
||||
process_payment(order)
|
||||
send_confirmation_email(order)
|
||||
```
|
||||
|
||||
**Replace Magic Numbers**:
|
||||
```python
|
||||
# Before
|
||||
if user.age < 18:
|
||||
return False
|
||||
|
||||
# After
|
||||
MINIMUM_AGE = 18
|
||||
if user.age < MINIMUM_AGE:
|
||||
return False
|
||||
```
|
||||
|
||||
**Simplify Conditionals**:
|
||||
```python
|
||||
# Before
|
||||
if user.role == 'admin':
|
||||
return True
|
||||
elif user.role == 'moderator':
|
||||
return True
|
||||
elif user.role == 'editor':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# After
|
||||
PRIVILEGED_ROLES = {'admin', 'moderator', 'editor'}
|
||||
return user.role in PRIVILEGED_ROLES
|
||||
```
|
||||
|
||||
### 4. Verify Improvements
|
||||
|
||||
After refactoring:
|
||||
- Run existing tests (all must pass)
|
||||
- Check code length reduced
|
||||
- Verify improved readability
|
||||
|
||||
## Example
|
||||
|
||||
**User Request**: "Refactor this function, it's too long"
|
||||
|
||||
```python
|
||||
def process_user_registration(data):
|
||||
if not data.get('email'):
|
||||
return {'error': 'Email required'}
|
||||
if '@' not in data['email']:
|
||||
return {'error': 'Invalid email'}
|
||||
if not data.get('password'):
|
||||
return {'error': 'Password required'}
|
||||
if len(data['password']) < 8:
|
||||
return {'error': 'Password too short'}
|
||||
if not any(c.isupper() for c in data['password']):
|
||||
return {'error': 'Password needs uppercase'}
|
||||
existing = db.query(User).filter_by(email=data['email']).first()
|
||||
if existing:
|
||||
return {'error': 'Email already registered'}
|
||||
salt = bcrypt.gensalt()
|
||||
hashed = bcrypt.hashpw(data['password'].encode(), salt)
|
||||
user = User(email=data['email'], password_hash=hashed)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
token = jwt.encode({'user_id': user.id}, SECRET_KEY)
|
||||
send_email(data['email'], 'Welcome!', 'Thanks for registering')
|
||||
return {'success': True, 'token': token}
|
||||
```
|
||||
|
||||
**Refactored**:
|
||||
|
||||
```python
|
||||
def process_user_registration(data):
|
||||
"""Register new user with validation and email confirmation."""
|
||||
# Validation
|
||||
validation_error = validate_registration_data(data)
|
||||
if validation_error:
|
||||
return {'error': validation_error}
|
||||
|
||||
# Check uniqueness
|
||||
if user_exists(data['email']):
|
||||
return {'error': 'Email already registered'}
|
||||
|
||||
# Create user
|
||||
user = create_user(data['email'], data['password'])
|
||||
|
||||
# Generate token
|
||||
token = generate_auth_token(user.id)
|
||||
|
||||
# Send welcome email
|
||||
send_welcome_email(user.email)
|
||||
|
||||
return {'success': True, 'token': token}
|
||||
|
||||
|
||||
def validate_registration_data(data):
|
||||
"""Validate registration data, return error message or None."""
|
||||
if not data.get('email'):
|
||||
return 'Email required'
|
||||
if '@' not in data['email']:
|
||||
return 'Invalid email'
|
||||
if not data.get('password'):
|
||||
return 'Password required'
|
||||
return validate_password_strength(data['password'])
|
||||
|
||||
|
||||
def validate_password_strength(password):
|
||||
"""Check password meets security requirements."""
|
||||
MIN_PASSWORD_LENGTH = 8
|
||||
if len(password) < MIN_PASSWORD_LENGTH:
|
||||
return f'Password must be at least {MIN_PASSWORD_LENGTH} characters'
|
||||
if not any(c.isupper() for c in password):
|
||||
return 'Password must contain uppercase letter'
|
||||
return None
|
||||
|
||||
|
||||
def user_exists(email):
|
||||
"""Check if user with given email already exists."""
|
||||
return db.query(User).filter_by(email=email).first() is not None
|
||||
|
||||
|
||||
def create_user(email, password):
|
||||
"""Create and save new user with hashed password."""
|
||||
salt = bcrypt.gensalt()
|
||||
hashed = bcrypt.hashpw(password.encode(), salt)
|
||||
user = User(email=email, password_hash=hashed)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
return user
|
||||
|
||||
|
||||
def generate_auth_token(user_id):
|
||||
"""Generate JWT authentication token."""
|
||||
return jwt.encode({'user_id': user_id}, SECRET_KEY)
|
||||
|
||||
|
||||
def send_welcome_email(email):
|
||||
"""Send welcome email to new user."""
|
||||
send_email(email, 'Welcome!', 'Thanks for registering')
|
||||
```
|
||||
|
||||
**Improvements**:
|
||||
- ✅ Main function reduced from 20 lines to 15 lines
|
||||
- ✅ Each function has single responsibility
|
||||
- ✅ Magic number (8) extracted to constant
|
||||
- ✅ All functions documented with docstrings
|
||||
- ✅ Easier to test individual functions
|
||||
- ✅ Easier to modify validation rules
|
||||
|
||||
## Best Practices
|
||||
|
||||
- ✅ Extract functions with clear names
|
||||
- ✅ Use constants instead of magic numbers
|
||||
- ✅ Keep functions under 30 lines
|
||||
- ✅ Maximum nesting depth of 2-3 levels
|
||||
- ✅ Write docstrings for extracted functions
|
||||
```
|
||||
|
||||
### 改进要点
|
||||
|
||||
1. ✅ 具体的名称: `python-code-refactoring` 而非 `helper`
|
||||
2. ✅ 详细的 description: 包含触发词和适用场景
|
||||
3. ✅ 明确的触发条件: 列出具体的使用场景
|
||||
4. ✅ 可执行的步骤: 每个步骤都有具体操作
|
||||
5. ✅ 实际代码示例: 展示完整的重构过程
|
||||
6. ✅ 具体的改进指标: 列出可验证的改进效果
|
||||
|
||||
---
|
||||
|
||||
## 示例 2: 过度冗长的 Skill
|
||||
|
||||
### ❌ 不好的版本
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: python-basics
|
||||
description: Teaches Python programming basics
|
||||
---
|
||||
|
||||
# Python Basics
|
||||
|
||||
This skill helps you learn Python programming.
|
||||
|
||||
## Variables
|
||||
|
||||
In Python, you can create variables like this:
|
||||
|
||||
```python
|
||||
x = 5
|
||||
y = "hello"
|
||||
z = 3.14
|
||||
```
|
||||
|
||||
Python supports different data types:
|
||||
- Integers (int): whole numbers like 1, 2, 3
|
||||
- Floats (float): decimal numbers like 3.14, 2.5
|
||||
- Strings (str): text like "hello", 'world'
|
||||
- Booleans (bool): True or False
|
||||
|
||||
## Conditional Statements
|
||||
|
||||
You can use if statements to make decisions:
|
||||
|
||||
```python
|
||||
if x > 0:
|
||||
print("Positive")
|
||||
elif x < 0:
|
||||
print("Negative")
|
||||
else:
|
||||
print("Zero")
|
||||
```
|
||||
|
||||
The if statement checks a condition. If True, it runs the indented code.
|
||||
The elif means "else if" and provides an alternative condition.
|
||||
The else runs if none of the above conditions are True.
|
||||
|
||||
## Loops
|
||||
|
||||
Python has two main types of loops:
|
||||
|
||||
### For Loops
|
||||
|
||||
For loops iterate over a sequence:
|
||||
|
||||
```python
|
||||
for i in range(5):
|
||||
print(i)
|
||||
```
|
||||
|
||||
This prints numbers 0 through 4. The range() function generates numbers.
|
||||
|
||||
### While Loops
|
||||
|
||||
While loops continue while a condition is True:
|
||||
|
||||
```python
|
||||
i = 0
|
||||
while i < 5:
|
||||
print(i)
|
||||
i += 1
|
||||
```
|
||||
|
||||
This does the same thing as the for loop above.
|
||||
|
||||
## Functions
|
||||
|
||||
Functions are reusable blocks of code:
|
||||
|
||||
```python
|
||||
def greet(name):
|
||||
return f"Hello, {name}!"
|
||||
```
|
||||
|
||||
The def keyword defines a function. The function name is greet.
|
||||
It takes one parameter called name. The return statement sends back a value.
|
||||
|
||||
## Lists
|
||||
|
||||
Lists store multiple items:
|
||||
|
||||
```python
|
||||
fruits = ["apple", "banana", "orange"]
|
||||
```
|
||||
|
||||
You can access items by index:
|
||||
|
||||
```python
|
||||
first_fruit = fruits[0] # "apple"
|
||||
```
|
||||
|
||||
... [continues for 50 more sections about Python basics]
|
||||
```
|
||||
|
||||
### 问题分析
|
||||
|
||||
| 问题 | 说明 | 影响 |
|
||||
|------|------|------|
|
||||
| **包含通用知识** | Python 基础知识 Claude 已经知道 | 浪费 token,增加检索成本 |
|
||||
| **教程式内容** | 像教程而非工作指南 | Claude 不需要学习,需要的是工作指导 |
|
||||
| **过度详细** | 解释显而易见的概念 | 信息过载,难以找到关键信息 |
|
||||
| **缺少项目特定信息** | 没有项目相关的规范或约定 | 无法提供项目特定价值 |
|
||||
|
||||
### ✅ 改进版本
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: project-python-conventions
|
||||
description: Enforces Python coding conventions specific to this project. Activates when user writes Python code or asks about code style. Covers naming, imports, error handling, and project-specific patterns.
|
||||
---
|
||||
|
||||
# Project Python Conventions
|
||||
|
||||
Project-specific Python coding standards and patterns.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User is writing or reviewing Python code
|
||||
- User asks about code style or conventions
|
||||
- User needs guidance on project patterns
|
||||
|
||||
## Import Organization
|
||||
|
||||
Follow this order:
|
||||
|
||||
```python
|
||||
# 1. Standard library
|
||||
import os
|
||||
import sys
|
||||
from typing import Optional, List
|
||||
|
||||
# 2. Third-party packages
|
||||
import numpy as np
|
||||
from fastapi import FastAPI
|
||||
|
||||
# 3. Local application imports
|
||||
from core.models import User
|
||||
from utils.helpers import format_date
|
||||
```
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
### Project-Specific Rules
|
||||
|
||||
| Type | Pattern | Example |
|
||||
|------|---------|---------|
|
||||
| API endpoints | `/api/v1/{resource}` | `/api/v1/users` |
|
||||
| Database tables | `{resource}_table` | `users_table` |
|
||||
| Environment variables | `APP_{NAME}` | `APP_DATABASE_URL` |
|
||||
| Config files | `{env}.config.py` | `prod.config.py` |
|
||||
|
||||
### Forbidden Patterns
|
||||
|
||||
```python
|
||||
# ❌ Don't use single-letter variables (except i, j, k in loops)
|
||||
d = get_data()
|
||||
|
||||
# ✅ Do use descriptive names
|
||||
user_data = get_data()
|
||||
|
||||
# ❌ Don't use abbreviations
|
||||
usr_mgr = UserManager()
|
||||
|
||||
# ✅ Do use full words
|
||||
user_manager = UserManager()
|
||||
```
|
||||
|
||||
## Error Handling Pattern
|
||||
|
||||
Use project's custom exceptions:
|
||||
|
||||
```python
|
||||
from core.exceptions import UserNotFoundError, ValidationError
|
||||
|
||||
def get_user(user_id: int) -> User:
|
||||
"""
|
||||
Retrieve user by ID.
|
||||
|
||||
Raises:
|
||||
UserNotFoundError: If user doesn't exist
|
||||
ValidationError: If user_id is invalid
|
||||
"""
|
||||
if not isinstance(user_id, int) or user_id <= 0:
|
||||
raise ValidationError(f"Invalid user_id: {user_id}")
|
||||
|
||||
user = db.query(User).get(user_id)
|
||||
if user is None:
|
||||
raise UserNotFoundError(f"User {user_id} not found")
|
||||
|
||||
return user
|
||||
```
|
||||
|
||||
**Never** use bare `except:` - always catch specific exceptions.
|
||||
|
||||
## Database Queries
|
||||
|
||||
Always use the project's query helper:
|
||||
|
||||
```python
|
||||
# ❌ Don't use raw SQLAlchemy queries
|
||||
users = db.query(User).filter(User.age > 18).all()
|
||||
|
||||
# ✅ Do use query helper
|
||||
from core.database import QueryBuilder
|
||||
|
||||
users = QueryBuilder(User).where('age', '>', 18).get()
|
||||
```
|
||||
|
||||
## API Response Format
|
||||
|
||||
All API endpoints must return this format:
|
||||
|
||||
```python
|
||||
{
|
||||
"success": True,
|
||||
"data": {
|
||||
# ... response data
|
||||
},
|
||||
"error": None,
|
||||
"meta": {
|
||||
"timestamp": "2025-01-31T12:00:00Z",
|
||||
"version": "1.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Use the response helper:
|
||||
|
||||
```python
|
||||
from core.responses import success_response, error_response
|
||||
|
||||
@app.get("/users/{id}")
|
||||
async def get_user(id: int):
|
||||
try:
|
||||
user = get_user_data(id)
|
||||
return success_response(user)
|
||||
except UserNotFoundError as e:
|
||||
return error_response(str(e), status_code=404)
|
||||
```
|
||||
|
||||
## Testing Patterns
|
||||
|
||||
### Test File Location
|
||||
|
||||
```
|
||||
project/
|
||||
├── src/
|
||||
│ └── services/
|
||||
│ └── user_service.py
|
||||
└── tests/
|
||||
└── services/
|
||||
└── test_user_service.py
|
||||
```
|
||||
|
||||
### Test Naming
|
||||
|
||||
```python
|
||||
# Format: test_{function_name}_{scenario}_{expected_result}
|
||||
|
||||
def test_get_user_valid_id_returns_user():
|
||||
"""Test getting user with valid ID returns User object."""
|
||||
pass
|
||||
|
||||
def test_get_user_invalid_id_raises_validation_error():
|
||||
"""Test getting user with invalid ID raises ValidationError."""
|
||||
pass
|
||||
|
||||
def test_get_user_nonexistent_id_raises_not_found_error():
|
||||
"""Test getting non-existent user raises UserNotFoundError."""
|
||||
pass
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [Full Style Guide](docs/STYLE_GUIDE.md)
|
||||
- [API Standards](docs/API_STANDARDS.md)
|
||||
- [Database Conventions](docs/DATABASE.md)
|
||||
```
|
||||
|
||||
### 改进要点
|
||||
|
||||
1. ✅ 只包含项目特定信息: 不教 Python 基础
|
||||
2. ✅ 简洁明了: 200 行 vs 原来的 500+ 行
|
||||
3. ✅ 实用的规则: 直接可应用的约定
|
||||
4. ✅ 清晰的示例: Do/Don't 对比
|
||||
5. ✅ 引用详细文档: 用链接而非全部内容
|
||||
|
||||
---
|
||||
|
||||
## 示例 3: 缺少上下文的 Skill
|
||||
|
||||
### ❌ 不好的版本
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: deployment
|
||||
description: Deploys code
|
||||
---
|
||||
|
||||
# Deployment
|
||||
|
||||
## Steps
|
||||
|
||||
1. Build the code
|
||||
2. Run tests
|
||||
3. Deploy to server
|
||||
4. Verify deployment
|
||||
```
|
||||
|
||||
### 问题分析
|
||||
|
||||
| 问题 | 说明 | 影响 |
|
||||
|------|------|------|
|
||||
| **无具体命令** | 没说明如何 build, test, deploy | Claude 无法执行 |
|
||||
| **无环境区分** | 开发、测试、生产部署可能不同 | 可能部署到错误环境 |
|
||||
| **无错误处理** | 没说明出错时怎么办 | 失败时不知如何恢复 |
|
||||
| **无验证标准** | "Verify" 太模糊 | 不知道检查什么 |
|
||||
|
||||
### ✅ 改进版本
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: deploy-to-production
|
||||
description: Deploys application to production environment on AWS. Activates when user asks to deploy to prod or mentions production deployment. Includes pre-flight checks, blue-green deployment, and rollback procedures.
|
||||
---
|
||||
|
||||
# Production Deployment
|
||||
|
||||
Safely deploy application to production with zero downtime.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to "deploy to production" or "push to prod"
|
||||
- User mentions "production deployment", "go live"
|
||||
- User needs to rollback a deployment
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before deployment, verify:
|
||||
|
||||
```bash
|
||||
# 1. On main branch
|
||||
git branch --show-current # Must be "main"
|
||||
|
||||
# 2. All tests pass
|
||||
npm test # Exit code must be 0
|
||||
|
||||
# 3. Build succeeds
|
||||
npm run build # Must complete without errors
|
||||
|
||||
# 4. No uncommitted changes
|
||||
git status # Must show "nothing to commit"
|
||||
|
||||
# 5. Latest code pulled
|
||||
git pull origin main # Must be up to date
|
||||
```
|
||||
|
||||
If any prerequisite fails, **stop** and fix the issue.
|
||||
|
||||
## Deployment Process
|
||||
|
||||
### Step 1: Pre-flight Checks
|
||||
|
||||
```bash
|
||||
# Run deployment readiness script
|
||||
./scripts/preflight-check.sh
|
||||
|
||||
# Expected output:
|
||||
# ✓ Tests passed
|
||||
# ✓ Build succeeded
|
||||
# ✓ Environment variables configured
|
||||
# ✓ Database migrations ready
|
||||
# ✓ Ready to deploy
|
||||
```
|
||||
|
||||
### Step 2: Database Migrations (if needed)
|
||||
|
||||
```bash
|
||||
# Connect to production database
|
||||
aws rds describe-db-instances --db-instance-identifier prod-db
|
||||
|
||||
# Backup before migration
|
||||
./scripts/backup-database.sh prod
|
||||
|
||||
# Run migrations
|
||||
NODE_ENV=production npm run migrate
|
||||
|
||||
# Verify migration succeeded
|
||||
npm run migrate:status
|
||||
```
|
||||
|
||||
### Step 3: Blue-Green Deployment
|
||||
|
||||
```bash
|
||||
# Deploy to green environment (inactive)
|
||||
aws elasticbeanstalk create-environment \
|
||||
--application-name myapp \
|
||||
--environment-name myapp-prod-green \
|
||||
--solution-stack-name "64bit Amazon Linux 2 v5.x.x running Node.js 18"
|
||||
|
||||
# Wait for green environment to be healthy
|
||||
aws elasticbeanstalk wait environment-updated \
|
||||
--environment-name myapp-prod-green
|
||||
|
||||
# Check green environment health
|
||||
curl https://myapp-prod-green.aws.com/health
|
||||
# Expected: {"status": "healthy"}
|
||||
```
|
||||
|
||||
### Step 4: Smoke Tests
|
||||
|
||||
```bash
|
||||
# Run smoke tests against green environment
|
||||
BASE_URL=https://myapp-prod-green.aws.com npm run test:smoke
|
||||
|
||||
# Tests must include:
|
||||
# - Health check endpoint
|
||||
# - Authentication flow
|
||||
# - Critical API endpoints
|
||||
# - Database connectivity
|
||||
```
|
||||
|
||||
### Step 5: Switch Traffic
|
||||
|
||||
```bash
|
||||
# Swap URLs (blue becomes green, green becomes blue)
|
||||
aws elasticbeanstalk swap-environment-cnames \
|
||||
--source-environment-name myapp-prod-blue \
|
||||
--destination-environment-name myapp-prod-green
|
||||
|
||||
# Wait 5 minutes for DNS propagation
|
||||
echo "Waiting for DNS propagation..."
|
||||
sleep 300
|
||||
|
||||
# Verify production URL serves new version
|
||||
curl https://myapp.com/version
|
||||
# Expected: {"version": "1.2.3"} (new version)
|
||||
```
|
||||
|
||||
### Step 6: Monitor
|
||||
|
||||
```bash
|
||||
# Monitor error rates for 15 minutes
|
||||
aws cloudwatch get-metric-statistics \
|
||||
--namespace AWS/ELB \
|
||||
--metric-name HTTPCode_Backend_5XX \
|
||||
--start-time $(date -u -d '15 minutes ago' +%Y-%m-%dT%H:%M:%S) \
|
||||
--end-time $(date -u +%Y-%m-%dT%H:%M:%S) \
|
||||
--period 300 \
|
||||
--statistics Sum
|
||||
|
||||
# Error rate must be < 1%
|
||||
```
|
||||
|
||||
If error rate exceeds 1%:
|
||||
- **Rollback immediately** (see Rollback section)
|
||||
- Investigate issue
|
||||
- Fix and redeploy
|
||||
|
||||
### Step 7: Cleanup
|
||||
|
||||
```bash
|
||||
# After 24 hours, if no issues:
|
||||
# Terminate old blue environment
|
||||
aws elasticbeanstalk terminate-environment \
|
||||
--environment-name myapp-prod-blue
|
||||
```
|
||||
|
||||
## Rollback Procedure
|
||||
|
||||
If deployment fails:
|
||||
|
||||
```bash
|
||||
# 1. Swap back to previous version
|
||||
aws elasticbeanstalk swap-environment-cnames \
|
||||
--source-environment-name myapp-prod-green \
|
||||
--destination-environment-name myapp-prod-blue
|
||||
|
||||
# 2. Verify old version is serving
|
||||
curl https://myapp.com/version
|
||||
# Expected: {"version": "1.2.2"} (old version)
|
||||
|
||||
# 3. Rollback database migrations (if ran)
|
||||
NODE_ENV=production npm run migrate:rollback
|
||||
|
||||
# 4. Notify team
|
||||
./scripts/notify-rollback.sh "Deployment rolled back due to [reason]"
|
||||
```
|
||||
|
||||
## Example Deployment
|
||||
|
||||
**User Request**: "Deploy v1.2.3 to production"
|
||||
|
||||
**Execution Log**:
|
||||
|
||||
```
|
||||
[14:00:00] Starting deployment of v1.2.3 to production
|
||||
[14:00:05] ✓ Pre-flight checks passed
|
||||
[14:00:10] ✓ Database backup completed
|
||||
[14:00:30] ✓ Database migrations applied (3 migrations)
|
||||
[14:01:00] → Creating green environment
|
||||
[14:05:00] ✓ Green environment healthy
|
||||
[14:05:30] ✓ Smoke tests passed (12/12)
|
||||
[14:06:00] → Switching traffic to green environment
|
||||
[14:11:00] ✓ DNS propagated
|
||||
[14:11:05] ✓ Production serving v1.2.3
|
||||
[14:11:10] → Monitoring for 15 minutes
|
||||
[14:26:10] ✓ Error rate: 0.05% (within threshold)
|
||||
[14:26:15] ✓ Deployment successful
|
||||
[14:26:20] → Old environment will be terminated in 24h
|
||||
|
||||
Deployment completed successfully in 26 minutes
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [AWS Deployment Guide](docs/AWS_DEPLOYMENT.md)
|
||||
- [Runbook](docs/RUNBOOK.md)
|
||||
- [On-Call Procedures](docs/ONCALL.md)
|
||||
```
|
||||
|
||||
### 改进要点
|
||||
|
||||
1. ✅ 具体命令: 每个步骤都有可执行的命令
|
||||
2. ✅ 环境明确: 专注于生产环境部署
|
||||
3. ✅ 验证标准: 说明检查什么和预期结果
|
||||
4. ✅ 错误处理: 包含完整的回滚流程
|
||||
5. ✅ 实际输出: 展示命令的预期输出
|
||||
6. ✅ 监控指标: 定义具体的成功标准
|
||||
|
||||
---
|
||||
|
||||
## 常见错误总结
|
||||
|
||||
### 1. 命名和描述问题
|
||||
|
||||
| 错误 | 示例 | 改进 |
|
||||
|------|------|------|
|
||||
| 过于泛化 | `name: helper` | `name: python-type-hints` |
|
||||
| 缺少关键词 | `description: Helps with code` | `description: Adds type hints to Python using mypy` |
|
||||
| 使用第一人称 | `description: I help you...` | `description: Adds type hints...` |
|
||||
|
||||
### 2. 内容问题
|
||||
|
||||
| 错误 | 说明 | 改进 |
|
||||
|------|------|------|
|
||||
| 包含通用知识 | 教 Python 基础语法 | 只包含项目特定规范 |
|
||||
| 过于抽象 | "分析代码并提供建议" | "检查函数长度、变量命名、重复代码" |
|
||||
| 缺少示例 | 只有文字描述 | 包含输入-输出示例 |
|
||||
|
||||
### 3. 结构问题
|
||||
|
||||
| 错误 | 说明 | 改进 |
|
||||
|------|------|------|
|
||||
| 无层次结构 | 所有内容混在一起 | 使用标题、列表、代码块组织 |
|
||||
| 缺少"When to Use" | 不知道何时激活 | 列出 3-5 个触发场景 |
|
||||
| 无验证步骤 | 不知道如何确认成功 | 说明检查项和预期结果 |
|
||||
|
||||
### 4. 自由度问题
|
||||
|
||||
| 错误 | 说明 | 改进 |
|
||||
|------|------|------|
|
||||
| 创意任务低自由度 | 为架构设计提供分步指令 | 提供指导原则和考虑因素 |
|
||||
| 危险任务高自由度 | 生产部署没有具体步骤 | 提供详细的检查清单 |
|
||||
| 不匹配任务类型 | 代码生成用教程式内容 | 提供模板和实际示例 |
|
||||
|
||||
---
|
||||
|
||||
## 快速检查清单
|
||||
|
||||
在发布 Skill 之前,问自己:
|
||||
|
||||
### 基础检查
|
||||
|
||||
- [ ] Name 是否具体且描述性强?
|
||||
- [ ] Description 包含触发关键词和场景?
|
||||
- [ ] 有明确的"When to Use"章节?
|
||||
- [ ] 内容只包含 Claude 不知道的信息?
|
||||
|
||||
### 内容检查
|
||||
|
||||
- [ ] 是否有实际的代码示例?
|
||||
- [ ] 步骤是否具体可执行?
|
||||
- [ ] 是否说明了如何验证成功?
|
||||
- [ ] 是否包含错误处理指导?
|
||||
|
||||
### 结构检查
|
||||
|
||||
- [ ] 内容组织清晰(使用标题、列表)?
|
||||
- [ ] 自由度设定合适(匹配任务类型)?
|
||||
- [ ] 长度合适(200-500行,或拆分子文件)?
|
||||
- [ ] 包含 Do/Don't 最佳实践?
|
||||
|
||||
如果有任何一项答"否",参考本文档的改进建议进行修改。
|
||||
|
|
@ -0,0 +1,908 @@
|
|||
# 好的 Skill 示例
|
||||
|
||||
本文档展示几个编写良好的 SKILL.md 示例,说明最佳实践的实际应用。
|
||||
|
||||
---
|
||||
|
||||
## 示例 1: 数据库迁移 Skill (高质量基础 Skill)
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: database-migration
|
||||
description: Manages database schema migrations using Alembic for SQLAlchemy projects. Activates when user asks to create migrations, upgrade/downgrade database, or mentions Alembic. Handles both development and production scenarios with safety checks.
|
||||
---
|
||||
|
||||
# Database Migration Skill
|
||||
|
||||
Automates database schema migration management using Alembic.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to "create migration", "update database schema", or "rollback migration"
|
||||
- User mentions "Alembic", "database migration", or "schema change"
|
||||
- User is working in a Python project with SQLAlchemy models
|
||||
- User needs to apply or revert database changes
|
||||
|
||||
## Quick Start
|
||||
|
||||
Create a new migration:
|
||||
```bash
|
||||
alembic revision --autogenerate -m "Description of changes"
|
||||
```
|
||||
|
||||
Apply migrations:
|
||||
```bash
|
||||
alembic upgrade head
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
### Creating Migrations
|
||||
|
||||
1. **Detect model changes**
|
||||
- Scan SQLAlchemy models in `models/` directory
|
||||
- Compare with current database schema
|
||||
- Identify additions, modifications, deletions
|
||||
|
||||
2. **Generate migration script**
|
||||
- Run `alembic revision --autogenerate`
|
||||
- Review generated script for accuracy
|
||||
- Edit if necessary (Alembic can't auto-detect everything)
|
||||
|
||||
3. **Verify migration**
|
||||
- Check upgrade() function is correct
|
||||
- Ensure downgrade() function reverses changes
|
||||
- Test on development database first
|
||||
|
||||
### Applying Migrations
|
||||
|
||||
1. **Safety checks**
|
||||
- Backup database (production only)
|
||||
- Verify no pending migrations
|
||||
- Check database connectivity
|
||||
|
||||
2. **Execute migration**
|
||||
- Run `alembic upgrade head`
|
||||
- Monitor for errors
|
||||
- Verify schema matches expected state
|
||||
|
||||
3. **Post-migration validation**
|
||||
- Run application tests
|
||||
- Check data integrity
|
||||
- Confirm application starts successfully
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Add New Column
|
||||
|
||||
**User Request**: "Add an email column to the users table"
|
||||
|
||||
**Step 1**: Update the model
|
||||
```python
|
||||
# models/user.py
|
||||
class User(Base):
|
||||
__tablename__ = 'users'
|
||||
id = Column(Integer, primary_key=True)
|
||||
username = Column(String(50), nullable=False)
|
||||
email = Column(String(120), nullable=True) # ← New field
|
||||
```
|
||||
|
||||
**Step 2**: Generate migration
|
||||
```bash
|
||||
alembic revision --autogenerate -m "Add email column to users table"
|
||||
```
|
||||
|
||||
**Generated migration** (alembic/versions/abc123_add_email.py):
|
||||
```python
|
||||
def upgrade():
|
||||
op.add_column('users', sa.Column('email', sa.String(120), nullable=True))
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('users', 'email')
|
||||
```
|
||||
|
||||
**Step 3**: Review and apply
|
||||
```bash
|
||||
# Review the migration file
|
||||
cat alembic/versions/abc123_add_email.py
|
||||
|
||||
# Apply migration
|
||||
alembic upgrade head
|
||||
```
|
||||
|
||||
**Output**:
|
||||
```
|
||||
INFO [alembic.runtime.migration] Running upgrade xyz789 -> abc123, Add email column to users table
|
||||
```
|
||||
|
||||
### Example 2: Complex Migration with Data Changes
|
||||
|
||||
**User Request**: "Split the 'name' column into 'first_name' and 'last_name'"
|
||||
|
||||
**Step 1**: Create empty migration (can't auto-generate data changes)
|
||||
```bash
|
||||
alembic revision -m "Split name into first_name and last_name"
|
||||
```
|
||||
|
||||
**Step 2**: Write custom migration
|
||||
```python
|
||||
def upgrade():
|
||||
# Add new columns
|
||||
op.add_column('users', sa.Column('first_name', sa.String(50)))
|
||||
op.add_column('users', sa.Column('last_name', sa.String(50)))
|
||||
|
||||
# Migrate existing data
|
||||
connection = op.get_bind()
|
||||
users = connection.execute("SELECT id, name FROM users")
|
||||
for user_id, name in users:
|
||||
parts = name.split(' ', 1)
|
||||
first = parts[0]
|
||||
last = parts[1] if len(parts) > 1 else ''
|
||||
connection.execute(
|
||||
"UPDATE users SET first_name = %s, last_name = %s WHERE id = %s",
|
||||
(first, last, user_id)
|
||||
)
|
||||
|
||||
# Make new columns non-nullable and drop old column
|
||||
op.alter_column('users', 'first_name', nullable=False)
|
||||
op.alter_column('users', 'last_name', nullable=False)
|
||||
op.drop_column('users', 'name')
|
||||
|
||||
def downgrade():
|
||||
# Add back name column
|
||||
op.add_column('users', sa.Column('name', sa.String(100)))
|
||||
|
||||
# Restore data
|
||||
connection = op.get_bind()
|
||||
users = connection.execute("SELECT id, first_name, last_name FROM users")
|
||||
for user_id, first, last in users:
|
||||
full_name = f"{first} {last}".strip()
|
||||
connection.execute(
|
||||
"UPDATE users SET name = %s WHERE id = %s",
|
||||
(full_name, user_id)
|
||||
)
|
||||
|
||||
op.alter_column('users', 'name', nullable=False)
|
||||
op.drop_column('users', 'first_name')
|
||||
op.drop_column('users', 'last_name')
|
||||
```
|
||||
|
||||
**Step 3**: Test thoroughly
|
||||
```bash
|
||||
# Apply migration
|
||||
alembic upgrade head
|
||||
|
||||
# Verify data
|
||||
python -c "from models import User; print(User.query.first().first_name)"
|
||||
|
||||
# Test rollback
|
||||
alembic downgrade -1
|
||||
python -c "from models import User; print(User.query.first().name)"
|
||||
|
||||
# Reapply
|
||||
alembic upgrade head
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Do
|
||||
|
||||
- ✅ Always review auto-generated migrations before applying
|
||||
- ✅ Test migrations on development database first
|
||||
- ✅ Write reversible downgrade() functions
|
||||
- ✅ Backup production databases before major migrations
|
||||
- ✅ Use meaningful migration messages
|
||||
|
||||
### Don't
|
||||
|
||||
- ❌ Trust auto-generated migrations blindly
|
||||
- ❌ Skip downgrade() implementation
|
||||
- ❌ Apply untested migrations to production
|
||||
- ❌ Modify existing migration files after they're committed
|
||||
- ❌ Use raw SQL without bind parameters
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Target database is not up to date"
|
||||
|
||||
**Problem**: Someone else applied migrations you don't have locally
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
git pull # Get latest migrations
|
||||
alembic upgrade head # Apply them locally
|
||||
```
|
||||
|
||||
### "Can't locate revision identified by 'xyz'"
|
||||
|
||||
**Problem**: Migration file deleted or branch conflict
|
||||
|
||||
**Solution**:
|
||||
1. Check if migration file exists in `alembic/versions/`
|
||||
2. If missing, restore from git history
|
||||
3. If branch conflict, merge migration branches:
|
||||
```bash
|
||||
alembic merge -m "Merge migration branches" head1 head2
|
||||
```
|
||||
|
||||
### Migration fails mid-execution
|
||||
|
||||
**Problem**: Error occurred during migration
|
||||
|
||||
**Solution**:
|
||||
1. Check error message for specifics
|
||||
2. Manually fix database to consistent state if needed
|
||||
3. Update migration script to fix the issue
|
||||
4. Mark migration as completed or retry:
|
||||
```bash
|
||||
# Mark as done without running
|
||||
alembic stamp head
|
||||
|
||||
# Or fix and retry
|
||||
alembic upgrade head
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Project Structure
|
||||
```
|
||||
project/
|
||||
├── alembic/
|
||||
│ ├── versions/ # Migration scripts
|
||||
│ ├── env.py # Alembic environment
|
||||
│ └── script.py.mako # Migration template
|
||||
├── alembic.ini # Alembic configuration
|
||||
└── models/ # SQLAlchemy models
|
||||
├── __init__.py
|
||||
├── user.py
|
||||
└── post.py
|
||||
```
|
||||
|
||||
### alembic.ini Configuration
|
||||
```ini
|
||||
[alembic]
|
||||
script_location = alembic
|
||||
sqlalchemy.url = driver://user:pass@localhost/dbname
|
||||
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers = console
|
||||
qualname = alembic
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [Alembic Documentation](https://alembic.sqlalchemy.org/)
|
||||
- [SQLAlchemy Documentation](https://docs.sqlalchemy.org/)
|
||||
- [Project Migration Guidelines](docs/database-migrations.md)
|
||||
```
|
||||
|
||||
### 为什么这是好的 Skill?
|
||||
|
||||
1. ✅ **清晰的 description**: 包含触发关键词 ("Alembic", "create migrations") 和场景 ("SQLAlchemy projects")
|
||||
2. ✅ **具体的触发条件**: "When to Use" 列出 4 个明确场景
|
||||
3. ✅ **分步工作流**: 每个操作都有清晰的 1-2-3 步骤
|
||||
4. ✅ **实际示例**: 包含简单和复杂两个示例,有完整代码
|
||||
5. ✅ **最佳实践**: Do/Don't 清单易于遵循
|
||||
6. ✅ **故障排除**: 覆盖 3 个常见问题及解决方案
|
||||
7. ✅ **项目特定信息**: 包含配置和目录结构
|
||||
|
||||
---
|
||||
|
||||
## 示例 2: API 文档生成 Skill (优秀的工作流 Skill)
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: api-documentation-generation
|
||||
description: Generates OpenAPI/Swagger documentation from FastAPI or Flask applications. Activates when user asks to create API docs, generate OpenAPI spec, or needs to document REST endpoints. Supports automatic extraction and custom annotations.
|
||||
---
|
||||
|
||||
# API Documentation Generation Skill
|
||||
|
||||
Automates creation of comprehensive API documentation from Python web applications.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to "generate API docs" or "create OpenAPI spec"
|
||||
- User mentions "Swagger", "OpenAPI", "API documentation"
|
||||
- User has a FastAPI or Flask application
|
||||
- User needs to document REST API endpoints
|
||||
|
||||
## Workflow
|
||||
|
||||
### Phase 1: Discovery
|
||||
|
||||
1. **Identify framework**
|
||||
- Check for FastAPI: `from fastapi import FastAPI` in codebase
|
||||
- Check for Flask: `from flask import Flask` in codebase
|
||||
- Check for Flask-RESTful: `from flask_restful import Resource`
|
||||
|
||||
2. **Locate API definitions**
|
||||
- Scan for route decorators: `@app.get()`, `@app.post()`, `@app.route()`
|
||||
- Find API routers and blueprints
|
||||
- Identify request/response models
|
||||
|
||||
3. **Extract metadata**
|
||||
- Endpoint paths and HTTP methods
|
||||
- Request parameters (path, query, body)
|
||||
- Response schemas and status codes
|
||||
- Authentication requirements
|
||||
|
||||
### Phase 2: Enhancement
|
||||
|
||||
1. **Review docstrings**
|
||||
- Check if endpoints have docstrings
|
||||
- Verify docstrings follow format (summary, description, params, returns)
|
||||
- Flag missing documentation
|
||||
|
||||
2. **Add missing docs** (if user approves)
|
||||
- Generate docstrings based on type hints
|
||||
- Infer descriptions from parameter names
|
||||
- Add example requests/responses
|
||||
|
||||
3. **Validate schemas**
|
||||
- Ensure Pydantic models are well-documented
|
||||
- Check for missing field descriptions
|
||||
- Verify example values are provided
|
||||
|
||||
### Phase 3: Generation
|
||||
|
||||
1. **Generate OpenAPI spec**
|
||||
```bash
|
||||
# For FastAPI
|
||||
python -c "from main import app; import json; print(json.dumps(app.openapi()))" > openapi.json
|
||||
|
||||
# For Flask with flasgger
|
||||
python scripts/generate_swagger.py > swagger.json
|
||||
```
|
||||
|
||||
2. **Create Swagger UI**
|
||||
- Copy Swagger UI static files to `docs/api/`
|
||||
- Configure to load generated spec
|
||||
- Test in browser: `http://localhost:8000/docs`
|
||||
|
||||
3. **Generate Markdown docs**
|
||||
- Use `openapi-to-md` to create human-readable docs
|
||||
- Organize by tags/resource groups
|
||||
- Add navigation and table of contents
|
||||
|
||||
### Phase 4: Validation
|
||||
|
||||
1. **Check completeness**
|
||||
- All endpoints documented?
|
||||
- All parameters described?
|
||||
- Example requests provided?
|
||||
|
||||
2. **Validate spec**
|
||||
```bash
|
||||
openapi-spec-validator openapi.json
|
||||
```
|
||||
|
||||
3. **Test interactive docs**
|
||||
- Try sample requests in Swagger UI
|
||||
- Verify authentication flows work
|
||||
- Check response schemas match actual responses
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: FastAPI Application
|
||||
|
||||
**User Request**: "Generate API documentation for my FastAPI app"
|
||||
|
||||
**Discovery**:
|
||||
```
|
||||
Found FastAPI application in: main.py
|
||||
Endpoints discovered:
|
||||
- GET /users (List users)
|
||||
- POST /users (Create user)
|
||||
- GET /users/{id} (Get user by ID)
|
||||
- PUT /users/{id} (Update user)
|
||||
- DELETE /users/{id} (Delete user)
|
||||
```
|
||||
|
||||
**Enhancement**:
|
||||
```
|
||||
Checking documentation coverage...
|
||||
✓ GET /users - Well documented
|
||||
✗ POST /users - Missing response examples
|
||||
✗ GET /users/{id} - No description
|
||||
✗ PUT /users/{id} - No description
|
||||
✗ DELETE /users/{id} - No description
|
||||
|
||||
Would you like me to add missing documentation?
|
||||
```
|
||||
|
||||
**User**: Yes
|
||||
|
||||
**Adding docs**:
|
||||
```python
|
||||
@app.get("/users/{id}", summary="Get user by ID")
|
||||
async def get_user(id: int):
|
||||
"""
|
||||
Retrieve a single user by their unique ID.
|
||||
|
||||
Args:
|
||||
id: The unique identifier of the user
|
||||
|
||||
Returns:
|
||||
User object with id, name, email, and created_at fields
|
||||
|
||||
Raises:
|
||||
404: User not found
|
||||
"""
|
||||
# ... implementation
|
||||
```
|
||||
|
||||
**Generation**:
|
||||
```bash
|
||||
Generating OpenAPI specification...
|
||||
✓ openapi.json created (15.2 KB)
|
||||
✓ Swagger UI deployed to docs/api/
|
||||
✓ Markdown docs created in docs/api/endpoints/
|
||||
|
||||
View documentation at: http://localhost:8000/docs
|
||||
```
|
||||
|
||||
### Example 2: Flask Application with Custom Schemas
|
||||
|
||||
**User Request**: "Document my Flask API and include request/response examples"
|
||||
|
||||
**Discovery**:
|
||||
```
|
||||
Found Flask application with Flask-RESTful
|
||||
Endpoints:
|
||||
- GET /api/products
|
||||
- POST /api/products
|
||||
- GET /api/products/<id>
|
||||
- PATCH /api/products/<id>
|
||||
- DELETE /api/products/<id>
|
||||
```
|
||||
|
||||
**Custom Examples Added**:
|
||||
```python
|
||||
class ProductList(Resource):
|
||||
def get(self):
|
||||
"""
|
||||
Get all products
|
||||
|
||||
Example Response:
|
||||
```json
|
||||
{
|
||||
"products": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Widget",
|
||||
"price": 29.99,
|
||||
"stock": 100
|
||||
}
|
||||
],
|
||||
"total": 1
|
||||
}
|
||||
```
|
||||
"""
|
||||
pass
|
||||
|
||||
def post(self):
|
||||
"""
|
||||
Create a new product
|
||||
|
||||
Example Request:
|
||||
```json
|
||||
{
|
||||
"name": "New Widget",
|
||||
"price": 39.99,
|
||||
"stock": 50
|
||||
}
|
||||
```
|
||||
|
||||
Example Response:
|
||||
```json
|
||||
{
|
||||
"id": 2,
|
||||
"name": "New Widget",
|
||||
"price": 39.99,
|
||||
"stock": 50,
|
||||
"created_at": "2025-01-31T12:00:00Z"
|
||||
}
|
||||
```
|
||||
"""
|
||||
pass
|
||||
```
|
||||
|
||||
**Result**:
|
||||
```
|
||||
Generated documentation:
|
||||
- openapi.json (with examples)
|
||||
- Swagger UI at /api/docs
|
||||
- Postman collection at docs/api/postman_collection.json
|
||||
- Markdown API reference at docs/api/README.md
|
||||
|
||||
All endpoints now include:
|
||||
✓ Request examples
|
||||
✓ Response examples
|
||||
✓ Error codes
|
||||
✓ Authentication requirements
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### FastAPI Projects
|
||||
|
||||
No additional configuration needed! FastAPI auto-generates OpenAPI docs.
|
||||
|
||||
Access at:
|
||||
- Swagger UI: `http://localhost:8000/docs`
|
||||
- ReDoc: `http://localhost:8000/redoc`
|
||||
- OpenAPI JSON: `http://localhost:8000/openapi.json`
|
||||
|
||||
### Flask Projects
|
||||
|
||||
Install flasgger:
|
||||
```bash
|
||||
pip install flasgger
|
||||
```
|
||||
|
||||
Configure in app:
|
||||
```python
|
||||
from flasgger import Swagger
|
||||
|
||||
app = Flask(__name__)
|
||||
swagger = Swagger(app, template={
|
||||
"info": {
|
||||
"title": "My API",
|
||||
"description": "API for managing resources",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- ✅ Use type hints - enables automatic schema generation
|
||||
- ✅ Write descriptive docstrings for all endpoints
|
||||
- ✅ Provide example requests and responses
|
||||
- ✅ Document error codes and edge cases
|
||||
- ✅ Keep docs in sync with code (auto-generate when possible)
|
||||
|
||||
## Tools Used
|
||||
|
||||
- **FastAPI**: Built-in OpenAPI support
|
||||
- **flasgger**: Swagger for Flask
|
||||
- **openapi-spec-validator**: Validates OpenAPI specs
|
||||
- **openapi-to-md**: Converts OpenAPI to Markdown
|
||||
|
||||
## References
|
||||
|
||||
- [OpenAPI Specification](https://spec.openapis.org/oas/latest.html)
|
||||
- [FastAPI Documentation](https://fastapi.tiangolo.com/)
|
||||
- [Swagger Documentation](https://swagger.io/docs/)
|
||||
```
|
||||
|
||||
### 为什么这是优秀的工作流 Skill?
|
||||
|
||||
1. ✅ **清晰的工作流阶段**: 4 个阶段 (Discovery, Enhancement, Generation, Validation)
|
||||
2. ✅ **决策点**: Phase 2 询问用户是否添加缺失文档
|
||||
3. ✅ **实际输出示例**: 展示了命令输出和生成的代码
|
||||
4. ✅ **多框架支持**: 处理 FastAPI 和 Flask 两种情况
|
||||
5. ✅ **工具集成**: 列出所需工具及其用途
|
||||
6. ✅ **可执行命令**: 提供完整的命令示例
|
||||
7. ✅ **验证步骤**: Phase 4 确保生成的文档质量
|
||||
|
||||
---
|
||||
|
||||
## 示例 3: 代码审查 Skill (高自由度 Skill)
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: code-review
|
||||
description: Performs comprehensive code reviews focusing on best practices, security, performance, and maintainability. Activates when user asks to review code, check pull request, or mentions code quality. Provides actionable feedback with severity ratings.
|
||||
---
|
||||
|
||||
# Code Review Skill
|
||||
|
||||
Conducts thorough code reviews with focus on quality, security, and best practices.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to "review my code" or "check this PR"
|
||||
- User mentions "code review", "code quality", or "best practices"
|
||||
- User wants feedback on specific code changes
|
||||
- User needs security or performance analysis
|
||||
|
||||
## Review Criteria
|
||||
|
||||
Code is evaluated across 5 dimensions:
|
||||
|
||||
### 1. Correctness
|
||||
- Logic errors and bugs
|
||||
- Edge case handling
|
||||
- Error handling and validation
|
||||
- Type safety
|
||||
|
||||
### 2. Security
|
||||
- SQL injection vulnerabilities
|
||||
- XSS vulnerabilities
|
||||
- Authentication/authorization issues
|
||||
- Sensitive data exposure
|
||||
- Dependency vulnerabilities
|
||||
|
||||
### 3. Performance
|
||||
- Algorithm efficiency
|
||||
- Database query optimization
|
||||
- Memory leaks
|
||||
- Unnecessary computations
|
||||
- Caching opportunities
|
||||
|
||||
### 4. Maintainability
|
||||
- Code clarity and readability
|
||||
- Function/class size
|
||||
- Code duplication
|
||||
- Naming conventions
|
||||
- Documentation
|
||||
|
||||
### 5. Best Practices
|
||||
- Language-specific idioms
|
||||
- Design patterns
|
||||
- SOLID principles
|
||||
- Testing coverage
|
||||
- Error handling patterns
|
||||
|
||||
## Review Process
|
||||
|
||||
1. **Understand context**
|
||||
- What does this code do?
|
||||
- What problem does it solve?
|
||||
- Are there any constraints or requirements?
|
||||
|
||||
2. **Identify issues**
|
||||
- Scan for common anti-patterns
|
||||
- Check against language best practices
|
||||
- Look for security vulnerabilities
|
||||
- Assess performance implications
|
||||
|
||||
3. **Prioritize feedback**
|
||||
- **Critical**: Security issues, data loss risks, crashes
|
||||
- **High**: Bugs, major performance issues
|
||||
- **Medium**: Code smells, maintainability concerns
|
||||
- **Low**: Style preferences, minor optimizations
|
||||
|
||||
4. **Provide suggestions**
|
||||
- Explain the issue clearly
|
||||
- Show better alternative (code example)
|
||||
- Explain why the alternative is better
|
||||
|
||||
## Example Review
|
||||
|
||||
### Code Submitted
|
||||
|
||||
```python
|
||||
def get_user_data(user_id):
|
||||
conn = sqlite3.connect('users.db')
|
||||
cursor = conn.cursor()
|
||||
query = "SELECT * FROM users WHERE id = " + str(user_id)
|
||||
cursor.execute(query)
|
||||
result = cursor.fetchone()
|
||||
return result
|
||||
```
|
||||
|
||||
### Review Feedback
|
||||
|
||||
**❌ CRITICAL: SQL Injection Vulnerability**
|
||||
|
||||
The code concatenates user input directly into SQL query, allowing SQL injection attacks.
|
||||
|
||||
**Bad**:
|
||||
```python
|
||||
query = "SELECT * FROM users WHERE id = " + str(user_id)
|
||||
```
|
||||
|
||||
**Good**:
|
||||
```python
|
||||
query = "SELECT * FROM users WHERE id = ?"
|
||||
cursor.execute(query, (user_id,))
|
||||
```
|
||||
|
||||
**Why**: Parameterized queries prevent SQL injection by properly escaping user input.
|
||||
|
||||
---
|
||||
|
||||
**⚠️ HIGH: Resource Leak**
|
||||
|
||||
Database connection is never closed, leading to resource exhaustion under load.
|
||||
|
||||
**Bad**:
|
||||
```python
|
||||
conn = sqlite3.connect('users.db')
|
||||
# ... use connection
|
||||
# connection never closed
|
||||
```
|
||||
|
||||
**Good**:
|
||||
```python
|
||||
with sqlite3.connect('users.db') as conn:
|
||||
cursor = conn.cursor()
|
||||
# ... use connection
|
||||
# automatically closed when exiting with block
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**ℹ️ MEDIUM: Overly Broad SELECT**
|
||||
|
||||
Using `SELECT *` fetches unnecessary data and is fragile to schema changes.
|
||||
|
||||
**Bad**:
|
||||
```python
|
||||
query = "SELECT * FROM users WHERE id = ?"
|
||||
```
|
||||
|
||||
**Good**:
|
||||
```python
|
||||
query = "SELECT id, name, email FROM users WHERE id = ?"
|
||||
```
|
||||
|
||||
**Why**: Explicit column selection is more efficient and makes intent clear.
|
||||
|
||||
---
|
||||
|
||||
**📝 LOW: Missing Error Handling**
|
||||
|
||||
Function doesn't handle case where user doesn't exist.
|
||||
|
||||
**Suggestion**:
|
||||
```python
|
||||
def get_user_data(user_id: int) -> Optional[dict]:
|
||||
"""
|
||||
Retrieve user data by ID.
|
||||
|
||||
Args:
|
||||
user_id: The unique identifier of the user
|
||||
|
||||
Returns:
|
||||
Dictionary with user data, or None if user not found
|
||||
"""
|
||||
with sqlite3.connect('users.db') as conn:
|
||||
cursor = conn.cursor()
|
||||
query = "SELECT id, name, email FROM users WHERE id = ?"
|
||||
cursor.execute(query, (user_id,))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if result is None:
|
||||
return None
|
||||
|
||||
return {
|
||||
'id': result[0],
|
||||
'name': result[1],
|
||||
'email': result[2]
|
||||
}
|
||||
```
|
||||
|
||||
### Revised Code
|
||||
|
||||
After applying all suggestions:
|
||||
|
||||
```python
|
||||
from typing import Optional
|
||||
import sqlite3
|
||||
|
||||
def get_user_data(user_id: int) -> Optional[dict]:
|
||||
"""
|
||||
Retrieve user data by ID.
|
||||
|
||||
Args:
|
||||
user_id: The unique identifier of the user
|
||||
|
||||
Returns:
|
||||
Dictionary with user data, or None if user not found
|
||||
|
||||
Raises:
|
||||
ValueError: If user_id is not a positive integer
|
||||
"""
|
||||
if not isinstance(user_id, int) or user_id <= 0:
|
||||
raise ValueError(f"Invalid user_id: {user_id}")
|
||||
|
||||
with sqlite3.connect('users.db') as conn:
|
||||
conn.row_factory = sqlite3.Row # Enable dict-like access
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = "SELECT id, name, email, created_at FROM users WHERE id = ?"
|
||||
cursor.execute(query, (user_id,))
|
||||
result = cursor.fetchone()
|
||||
|
||||
if result is None:
|
||||
return None
|
||||
|
||||
return dict(result) # Convert Row to dict
|
||||
```
|
||||
|
||||
### Summary
|
||||
|
||||
**Issues Found**: 4
|
||||
- 1 Critical (SQL Injection)
|
||||
- 1 High (Resource Leak)
|
||||
- 1 Medium (Inefficient Query)
|
||||
- 1 Low (Missing Error Handling)
|
||||
|
||||
**All Issues Addressed**: ✓
|
||||
|
||||
## Best Practices
|
||||
|
||||
### When Reviewing
|
||||
|
||||
- 🎯 Focus on impact - prioritize critical issues
|
||||
- 📝 Be specific - provide code examples
|
||||
- 🎓 Be educational - explain why, not just what
|
||||
- 🤝 Be constructive - suggest improvements, don't just criticize
|
||||
- ⚖️ Be balanced - acknowledge good practices too
|
||||
|
||||
### What to Look For
|
||||
|
||||
**Python-specific**:
|
||||
- Use of `with` for resource management
|
||||
- Type hints on function signatures
|
||||
- Proper exception handling
|
||||
- List comprehensions vs loops
|
||||
- Dictionary vs if-elif chains
|
||||
|
||||
**General**:
|
||||
- DRY principle violations
|
||||
- Magic numbers
|
||||
- Long functions (>50 lines)
|
||||
- Deep nesting (>3 levels)
|
||||
- Missing tests for critical paths
|
||||
|
||||
## Automated Tools
|
||||
|
||||
Complement manual review with automated tools:
|
||||
|
||||
```bash
|
||||
# Linting
|
||||
pylint mycode.py
|
||||
flake8 mycode.py
|
||||
|
||||
# Type checking
|
||||
mypy mycode.py
|
||||
|
||||
# Security scanning
|
||||
bandit -r .
|
||||
safety check
|
||||
|
||||
# Code complexity
|
||||
radon cc mycode.py -a
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [OWASP Top 10](https://owasp.org/www-project-top-ten/)
|
||||
- [Python Best Practices](https://docs.python-guide.org/)
|
||||
- [Clean Code Principles](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)
|
||||
```
|
||||
|
||||
### 为什么这是高自由度 Skill?
|
||||
|
||||
1. ✅ **指导原则而非严格步骤**: 提供评审维度,不限定具体流程
|
||||
2. ✅ **情境适应**: 根据代码类型和问题严重性调整重点
|
||||
3. ✅ **教育性**: 解释"为什么",帮助 Claude 做出判断
|
||||
4. ✅ **优先级框架**: 定义严重性级别,让 Claude 自行判断
|
||||
5. ✅ **完整示例**: 展示从问题识别到解决的完整流程
|
||||
6. ✅ **工具集成**: 提到自动化工具,但不强制使用
|
||||
|
||||
---
|
||||
|
||||
## 总结: 好 Skill 的共同特征
|
||||
|
||||
| 特征 | 说明 | 示例位置 |
|
||||
|------|------|---------|
|
||||
| **清晰触发** | description 包含关键词和场景 | 所有 frontmatter |
|
||||
| **结构化内容** | 使用标题、列表、代码块组织信息 | 所有示例 |
|
||||
| **实际示例** | 真实代码,不是伪代码 | Example sections |
|
||||
| **决策指导** | 告诉 Claude 何时做什么 | 工作流 Skill 的 Phase 2 |
|
||||
| **可执行命令** | 提供完整的命令,不是抽象描述 | 迁移 Skill 的命令 |
|
||||
| **错误处理** | 包含故障排除章节 | 所有 Troubleshooting |
|
||||
| **最佳实践** | Do/Don't 清单 | 所有 Best Practices |
|
||||
| **工具引用** | 说明使用哪些工具及如何使用 | API 文档 Skill |
|
||||
| **验证步骤** | 说明如何确认操作成功 | 迁移 Skill 的验证 |
|
||||
| **合适的自由度** | 根据任务特性选择指导程度 | 代码审查 Skill |
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
name: your-skill-name
|
||||
description: Brief description of what this skill does and when to activate it. Include trigger keywords and scenarios where this skill should be used.
|
||||
---
|
||||
|
||||
# Your Skill Title
|
||||
|
||||
> Brief one-line summary of what this skill accomplishes
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User asks to [specific action or task]
|
||||
- User mentions keywords like "[keyword1]", "[keyword2]", or "[keyword3]"
|
||||
- User is working with [specific technology/framework/tool]
|
||||
- User needs to [specific outcome or goal]
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Basic usage example
|
||||
command-to-run --option value
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Step 1**: Brief description of first step
|
||||
- Detail about what happens
|
||||
- Any prerequisites or conditions
|
||||
|
||||
2. **Step 2**: Brief description of second step
|
||||
- Key actions taken
|
||||
- Expected outputs
|
||||
|
||||
3. **Step 3**: Brief description of final step
|
||||
- Validation or verification
|
||||
- Success criteria
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Basic Usage
|
||||
|
||||
**User Request**: "Example of what user might say"
|
||||
|
||||
**Action**: What Claude does in response
|
||||
|
||||
**Output**:
|
||||
```
|
||||
Expected output or result
|
||||
```
|
||||
|
||||
### Example 2: Advanced Usage
|
||||
|
||||
**User Request**: "More complex user request"
|
||||
|
||||
**Action**:
|
||||
1. First action taken
|
||||
2. Second action taken
|
||||
3. Final action
|
||||
|
||||
**Output**:
|
||||
```
|
||||
Expected output showing more complex results
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- ✅ Do this for best results
|
||||
- ✅ Follow this pattern
|
||||
- ❌ Avoid this common mistake
|
||||
- ❌ Don't do this
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issue 1
|
||||
|
||||
**Problem**: Description of the problem
|
||||
|
||||
**Solution**: How to fix it
|
||||
|
||||
### Common Issue 2
|
||||
|
||||
**Problem**: Description of another problem
|
||||
|
||||
**Solution**: Steps to resolve
|
||||
|
||||
## References
|
||||
|
||||
- [Related Documentation](link-to-docs)
|
||||
- [Official Guide](link-to-guide)
|
||||
- [Additional Resources](link-to-resources)
|
||||
|
||||
---
|
||||
|
||||
**Version**: 1.0
|
||||
**Last Updated**: YYYY-MM-DD
|
||||
|
|
@ -0,0 +1,402 @@
|
|||
---
|
||||
name: your-workflow-skill
|
||||
description: Guides Claude through a multi-step workflow for [specific task]. Activates when user needs to [trigger scenario] or mentions [key terms].
|
||||
---
|
||||
|
||||
# Your Workflow Skill Title
|
||||
|
||||
> Automates a complex multi-step process with decision points and validation
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
- User needs to execute a multi-step workflow
|
||||
- User asks to "[workflow trigger phrase]"
|
||||
- User is working on [specific type of project or task]
|
||||
- Task requires validation and error handling at each step
|
||||
|
||||
## Workflow Overview
|
||||
|
||||
```
|
||||
┌─────────────┐
|
||||
│ Start │
|
||||
└──────┬──────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────┐
|
||||
│ Preparation │
|
||||
│ & Validation │
|
||||
└────────┬────────┘
|
||||
│
|
||||
┌────▼────┐
|
||||
│ Step 1 │
|
||||
└────┬────┘
|
||||
│
|
||||
┌────▼────┐
|
||||
│ Step 2 │──┐
|
||||
└────┬────┘ │ (Loop if needed)
|
||||
│ │
|
||||
└───────┘
|
||||
│
|
||||
┌────▼────┐
|
||||
│ Step 3 │
|
||||
└────┬────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────┐
|
||||
│ Complete │
|
||||
│ & Report │
|
||||
└─────────────┘
|
||||
```
|
||||
|
||||
## Detailed Workflow
|
||||
|
||||
### Preparation Phase
|
||||
|
||||
Before starting the main workflow:
|
||||
|
||||
- [ ] Check prerequisite 1
|
||||
- [ ] Validate prerequisite 2
|
||||
- [ ] Ensure prerequisite 3 is met
|
||||
|
||||
If any prerequisite fails:
|
||||
- Stop execution
|
||||
- Report which prerequisite failed
|
||||
- Provide remediation steps
|
||||
|
||||
### Step 1: [Step Name]
|
||||
|
||||
**Purpose**: What this step accomplishes
|
||||
|
||||
**Actions**:
|
||||
1. Action 1
|
||||
2. Action 2
|
||||
3. Action 3
|
||||
|
||||
**Validation**:
|
||||
- Check condition 1
|
||||
- Verify condition 2
|
||||
|
||||
**On Success**: → Proceed to Step 2
|
||||
**On Failure**: → [Error handling procedure]
|
||||
|
||||
### Step 2: [Step Name]
|
||||
|
||||
**Purpose**: What this step accomplishes
|
||||
|
||||
**Actions**:
|
||||
1. Action 1
|
||||
2. Action 2
|
||||
|
||||
**Decision Point**:
|
||||
- If condition A: → Action X
|
||||
- If condition B: → Action Y
|
||||
- Otherwise: → Default action
|
||||
|
||||
**Validation**:
|
||||
- Verify expected output
|
||||
- Check for errors
|
||||
|
||||
**On Success**: → Proceed to Step 3
|
||||
**On Failure**: → [Error handling procedure]
|
||||
|
||||
### Step 3: [Step Name]
|
||||
|
||||
**Purpose**: Final actions and cleanup
|
||||
|
||||
**Actions**:
|
||||
1. Finalize changes
|
||||
2. Run validation tests
|
||||
3. Generate summary report
|
||||
|
||||
**Success Criteria**:
|
||||
- All tests pass
|
||||
- No errors in logs
|
||||
- Expected artifacts created
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Standard Workflow Execution
|
||||
|
||||
**User Request**: "Run the [workflow name]"
|
||||
|
||||
**Execution**:
|
||||
|
||||
**Preparation Phase** ✓
|
||||
```
|
||||
✓ Prerequisite 1 met
|
||||
✓ Prerequisite 2 validated
|
||||
✓ Ready to begin
|
||||
```
|
||||
|
||||
**Step 1: [Step Name]** ✓
|
||||
```
|
||||
→ Action 1 completed
|
||||
→ Action 2 completed
|
||||
→ Validation passed
|
||||
```
|
||||
|
||||
**Step 2: [Step Name]** ✓
|
||||
```
|
||||
→ Decision: Condition A detected
|
||||
→ Executing Action X
|
||||
→ Validation passed
|
||||
```
|
||||
|
||||
**Step 3: [Step Name]** ✓
|
||||
```
|
||||
→ Finalization complete
|
||||
→ All tests passed
|
||||
→ Summary generated
|
||||
```
|
||||
|
||||
**Result**: Workflow completed successfully
|
||||
|
||||
### Example 2: Workflow with Error Recovery
|
||||
|
||||
**User Request**: "Execute [workflow name]"
|
||||
|
||||
**Execution**:
|
||||
|
||||
**Step 1** ✓
|
||||
```
|
||||
→ Completed successfully
|
||||
```
|
||||
|
||||
**Step 2** ⚠️
|
||||
```
|
||||
→ Action 1 completed
|
||||
→ Action 2 failed: [Error message]
|
||||
```
|
||||
|
||||
**Error Recovery**:
|
||||
1. Identified root cause: [Explanation]
|
||||
2. Applied fix: [Fix description]
|
||||
3. Retrying Step 2...
|
||||
|
||||
**Step 2 (Retry)** ✓
|
||||
```
|
||||
→ Completed after fix
|
||||
```
|
||||
|
||||
**Step 3** ✓
|
||||
```
|
||||
→ Completed successfully
|
||||
```
|
||||
|
||||
**Result**: Workflow completed with 1 retry
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Error Categories
|
||||
|
||||
| Category | Action |
|
||||
|----------|--------|
|
||||
| **Recoverable** | Attempt automatic fix, retry up to 3 times |
|
||||
| **User Input Needed** | Pause workflow, ask user for guidance |
|
||||
| **Critical** | Stop workflow, rollback changes if possible |
|
||||
|
||||
### Common Errors
|
||||
|
||||
**Error 1: [Error Name]**
|
||||
- **Cause**: What causes this error
|
||||
- **Detection**: How to identify it
|
||||
- **Recovery**: Steps to fix
|
||||
1. Recovery action 1
|
||||
2. Recovery action 2
|
||||
3. Retry from failed step
|
||||
|
||||
**Error 2: [Error Name]**
|
||||
- **Cause**: What causes this error
|
||||
- **Detection**: How to identify it
|
||||
- **Recovery**: Manual intervention required
|
||||
- Ask user: "[Question to ask]"
|
||||
- Wait for user input
|
||||
- Apply user's guidance
|
||||
- Resume workflow
|
||||
|
||||
## Rollback Procedure
|
||||
|
||||
If the workflow fails critically:
|
||||
|
||||
1. **Identify last successful step**
|
||||
- Step 1: ✓ Completed
|
||||
- Step 2: ❌ Failed at action 3
|
||||
|
||||
2. **Undo changes from failed step**
|
||||
- Revert action 1
|
||||
- Revert action 2
|
||||
- Clean up partial state
|
||||
|
||||
3. **Verify system state**
|
||||
- Confirm rollback successful
|
||||
- Check for side effects
|
||||
|
||||
4. **Report to user**
|
||||
```
|
||||
Workflow failed at Step 2, action 3
|
||||
Reason: [Error message]
|
||||
All changes have been rolled back
|
||||
System is back to pre-workflow state
|
||||
```
|
||||
|
||||
## Workflow Variations
|
||||
|
||||
### Variation 1: Quick Mode
|
||||
|
||||
**When to use**: User needs faster execution, can accept lower validation
|
||||
|
||||
**Changes**:
|
||||
- Skip optional validations
|
||||
- Use cached data where available
|
||||
- Reduce logging verbosity
|
||||
|
||||
**Trade-offs**:
|
||||
- ⚡ 50% faster
|
||||
- ⚠️ Less detailed error messages
|
||||
|
||||
### Variation 2: Strict Mode
|
||||
|
||||
**When to use**: Production deployments, critical changes
|
||||
|
||||
**Changes**:
|
||||
- Enable all validations
|
||||
- Require explicit user confirmation at each step
|
||||
- Generate detailed audit logs
|
||||
|
||||
**Trade-offs**:
|
||||
- 🛡️ Maximum safety
|
||||
- 🐢 Slower execution
|
||||
|
||||
## Monitoring and Logging
|
||||
|
||||
Throughout the workflow:
|
||||
|
||||
```
|
||||
[TIMESTAMP] [STEP] [STATUS] Message
|
||||
|
||||
[2025-01-31 14:30:01] [PREP] [INFO] Starting preparation phase
|
||||
[2025-01-31 14:30:02] [PREP] [OK] All prerequisites met
|
||||
[2025-01-31 14:30:03] [STEP1] [INFO] Beginning Step 1
|
||||
[2025-01-31 14:30:05] [STEP1] [OK] Step 1 completed successfully
|
||||
[2025-01-31 14:30:06] [STEP2] [INFO] Beginning Step 2
|
||||
[2025-01-31 14:30:08] [STEP2] [WARN] Condition B detected, using fallback
|
||||
[2025-01-31 14:30:10] [STEP2] [OK] Step 2 completed with warnings
|
||||
[2025-01-31 14:30:11] [STEP3] [INFO] Beginning Step 3
|
||||
[2025-01-31 14:30:15] [STEP3] [OK] Step 3 completed successfully
|
||||
[2025-01-31 14:30:16] [COMPLETE] [OK] Workflow finished successfully
|
||||
```
|
||||
|
||||
## Post-Workflow Report
|
||||
|
||||
After completion, generate a summary:
|
||||
|
||||
```markdown
|
||||
# Workflow Execution Report
|
||||
|
||||
**Workflow**: [Workflow Name]
|
||||
**Started**: 2025-01-31 14:30:01
|
||||
**Completed**: 2025-01-31 14:30:16
|
||||
**Duration**: 15 seconds
|
||||
**Status**: ✓ Success
|
||||
|
||||
## Steps Executed
|
||||
|
||||
1. ✓ Preparation Phase (1s)
|
||||
2. ✓ Step 1: [Step Name] (2s)
|
||||
3. ✓ Step 2: [Step Name] (4s) - 1 warning
|
||||
4. ✓ Step 3: [Step Name] (4s)
|
||||
|
||||
## Warnings
|
||||
|
||||
- Step 2: Condition B detected, used fallback action
|
||||
|
||||
## Artifacts Generated
|
||||
|
||||
- `/path/to/output1.txt`
|
||||
- `/path/to/output2.json`
|
||||
- `/path/to/report.html`
|
||||
|
||||
## Next Steps
|
||||
|
||||
- Review generated artifacts
|
||||
- Deploy to production (if applicable)
|
||||
- Archive logs to `/logs/workflow-20250131-143001.log`
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Do
|
||||
|
||||
- ✅ Validate inputs before starting workflow
|
||||
- ✅ Provide clear progress updates at each step
|
||||
- ✅ Log all decisions and actions
|
||||
- ✅ Handle errors gracefully with recovery options
|
||||
- ✅ Generate summary report at completion
|
||||
|
||||
### Don't
|
||||
|
||||
- ❌ Skip validation steps to save time
|
||||
- ❌ Continue after critical errors
|
||||
- ❌ Assume prerequisites are met without checking
|
||||
- ❌ Lose partial progress on failure
|
||||
- ❌ Leave system in inconsistent state
|
||||
|
||||
## Advanced Features
|
||||
|
||||
### Parallel Execution
|
||||
|
||||
Some steps can run in parallel:
|
||||
|
||||
```
|
||||
Step 1 ─┬─→ Step 2A ─┐
|
||||
│ ├─→ Step 3
|
||||
└─→ Step 2B ─┘
|
||||
```
|
||||
|
||||
**Requirements**:
|
||||
- Steps 2A and 2B must be independent
|
||||
- Both must complete before Step 3
|
||||
|
||||
**Implementation**:
|
||||
1. Start Step 2A in background
|
||||
2. Start Step 2B in background
|
||||
3. Wait for both to complete
|
||||
4. Verify both succeeded
|
||||
5. Proceed to Step 3
|
||||
|
||||
### Conditional Branching
|
||||
|
||||
```
|
||||
Step 1 → Decision
|
||||
├─→ [Condition A] → Path A → Step 3
|
||||
├─→ [Condition B] → Path B → Step 3
|
||||
└─→ [Default] → Path C → Step 3
|
||||
```
|
||||
|
||||
## Testing This Workflow
|
||||
|
||||
To test the workflow without side effects:
|
||||
|
||||
1. Use `--dry-run` flag to simulate execution
|
||||
2. Check that all steps are logged correctly
|
||||
3. Verify error handling with intentional failures
|
||||
4. Confirm rollback procedure works
|
||||
|
||||
Example:
|
||||
```bash
|
||||
workflow-runner --dry-run --inject-error step2
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
[DRY RUN] Step 1: Would execute [actions]
|
||||
[DRY RUN] Step 2: Injected error as requested
|
||||
[DRY RUN] Error Recovery: Would attempt fix
|
||||
[DRY RUN] Rollback: Would undo Step 1 changes
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Version**: 1.0
|
||||
**Last Updated**: YYYY-MM-DD
|
||||
**Maintainer**: Team Name
|
||||
|
|
@ -155,7 +155,7 @@ FastGPT 商业版共包含了2个应用(fastgpt, fastgpt-plus)和2个数据
|
|||
SYSTEM_NAME=FastGPT
|
||||
SYSTEM_DESCRIPTION=
|
||||
SYSTEM_FAVICON=/favicon.ico
|
||||
HOME_URL=/dashboard/apps
|
||||
HOME_URL=/dashboard/agent
|
||||
```
|
||||
|
||||
SYSTEM_FAVICON 可以是一个网络地址
|
||||
|
|
|
|||
|
|
@ -3,15 +3,34 @@ title: 'V4.14.1(进行中)'
|
|||
description: 'FastGPT V4.14.1 更新说明'
|
||||
---
|
||||
|
||||
## 更新指南
|
||||
|
||||
### 1. 更新镜像:
|
||||
|
||||
|
||||
### 2. 执行升级脚本
|
||||
|
||||
仅需使用过自定义系统工具的商业版用户操作。
|
||||
从任意终端,发起 1 个 HTTP 请求。其中 `{{rootkey}}` 替换成环境变量里的 `rootkey`;`{{host}}` 替换成**FastGPT 域名**。
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{{host}}/api/admin/initv4141' \
|
||||
--header 'rootkey: {{rootkey}}' \
|
||||
--header 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
复制一份原应用目录给工具使用。
|
||||
|
||||
## 🚀 新增内容
|
||||
|
||||
1. 新工作台交互。
|
||||
2. 工作流运行欠费后提供继续运行按键,无需从头开始。
|
||||
|
||||
## ⚙️ 优化
|
||||
|
||||
1. 在同一轮对话中,MCP Client 会持久化实例,不会销毁。
|
||||
2. 模型重载时候,不会把全局模型配置清空再添加,从而导致重载阶段模型调用错误。
|
||||
3. 自动保存,增加一条团队云端保存记录。
|
||||
|
||||
## 🐛 修复
|
||||
|
||||
|
|
@ -19,3 +38,9 @@ description: 'FastGPT V4.14.1 更新说明'
|
|||
2. 富文本编辑器 tab 空格未对齐。
|
||||
3. 嵌套运行 Agent 时候,跳过节点队列未初始化,导致无法正常运行。
|
||||
4. 判断器右侧是 number 引用时,会出现报错。
|
||||
5. 工作流工具入参为文件选择时,未出现选择框。
|
||||
6. HTTP 插件无法正确处理 http 协议(非 https)接口请求。
|
||||
7. 文本类型的全局变量,默认值编辑框 UI。
|
||||
8. 代码节点行数超过 100 行时显示重叠。
|
||||
9. 删除应用,未把目录内的删除。
|
||||
10. 浏览器未传递实时日期至服务器。
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
"document/content/docs/introduction/development/proxy/http_proxy.mdx": "2025-07-23T21:35:03+08:00",
|
||||
"document/content/docs/introduction/development/proxy/nginx.mdx": "2025-07-23T21:35:03+08:00",
|
||||
"document/content/docs/introduction/development/quick-start.mdx": "2025-10-21T11:58:25+08:00",
|
||||
"document/content/docs/introduction/development/sealos.mdx": "2025-09-29T11:52:39+08:00",
|
||||
"document/content/docs/introduction/development/sealos.mdx": "2025-11-07T12:06:28+08:00",
|
||||
"document/content/docs/introduction/development/signoz.mdx": "2025-09-17T22:29:56+08:00",
|
||||
"document/content/docs/introduction/guide/DialogBoxes/htmlRendering.mdx": "2025-07-23T21:35:03+08:00",
|
||||
"document/content/docs/introduction/guide/DialogBoxes/quoteList.mdx": "2025-07-23T21:35:03+08:00",
|
||||
|
|
@ -115,7 +115,7 @@
|
|||
"document/content/docs/upgrading/4-13/4131.mdx": "2025-09-30T15:47:06+08:00",
|
||||
"document/content/docs/upgrading/4-13/4132.mdx": "2025-10-21T11:46:53+08:00",
|
||||
"document/content/docs/upgrading/4-14/4140.mdx": "2025-11-06T15:43:00+08:00",
|
||||
"document/content/docs/upgrading/4-14/4141.mdx": "2025-11-07T10:56:20+08:00",
|
||||
"document/content/docs/upgrading/4-14/4141.mdx": "2025-11-10T22:52:46+08:00",
|
||||
"document/content/docs/upgrading/4-8/40.mdx": "2025-08-02T19:38:37+08:00",
|
||||
"document/content/docs/upgrading/4-8/41.mdx": "2025-08-02T19:38:37+08:00",
|
||||
"document/content/docs/upgrading/4-8/42.mdx": "2025-08-02T19:38:37+08:00",
|
||||
|
|
|
|||
|
|
@ -59,7 +59,11 @@ export const parseUrlToFileType = (url: string): UserChatItemFileItemType | unde
|
|||
const parseUrl = new URL(url, 'http://localhost:3000');
|
||||
|
||||
// Get filename from URL
|
||||
const filename = parseUrl.searchParams.get('filename') || parseUrl.pathname.split('/').pop();
|
||||
const filename = (() => {
|
||||
// Here is a S3 Object Key
|
||||
if (url.startsWith('chat/')) return url.split('/').pop()?.split('-')[1];
|
||||
return parseUrl.searchParams.get('filename') || parseUrl.pathname.split('/').pop();
|
||||
})();
|
||||
const extension = filename?.split('.').pop()?.toLowerCase() || '';
|
||||
|
||||
// If it's a document type, return as file, otherwise treat as image
|
||||
|
|
|
|||
|
|
@ -6,5 +6,8 @@ export enum TrackEnum {
|
|||
createDataset = 'createDataset',
|
||||
appNodes = 'appNodes',
|
||||
runSystemTool = 'runSystemTool',
|
||||
datasetSearch = 'datasetSearch'
|
||||
datasetSearch = 'datasetSearch',
|
||||
readSystemAnnouncement = 'readSystemAnnouncement',
|
||||
clickOperationalAd = 'clickOperationalAd',
|
||||
closeOperationalAd = 'closeOperationalAd'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ export enum SystemConfigsTypeEnum {
|
|||
fastgpt = 'fastgpt',
|
||||
fastgptPro = 'fastgptPro',
|
||||
systemMsgModal = 'systemMsgModal',
|
||||
license = 'license'
|
||||
license = 'license',
|
||||
operationalAd = 'operationalAd'
|
||||
}
|
||||
|
||||
export const SystemConfigsTypeMap = {
|
||||
|
|
@ -17,5 +18,8 @@ export const SystemConfigsTypeMap = {
|
|||
},
|
||||
[SystemConfigsTypeEnum.license]: {
|
||||
label: 'license'
|
||||
},
|
||||
[SystemConfigsTypeEnum.operationalAd]: {
|
||||
label: 'operationalAd'
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export type FastGPTFeConfigsType = {
|
|||
googleClientVerKey?: string;
|
||||
mcpServerProxyEndpoint?: string;
|
||||
chineseRedirectUrl?: string;
|
||||
botIframeUrl?: string;
|
||||
|
||||
show_emptyChat?: boolean;
|
||||
show_appStore?: boolean;
|
||||
|
|
|
|||
|
|
@ -8,19 +8,32 @@ import {
|
|||
|
||||
export enum AppTypeEnum {
|
||||
folder = 'folder',
|
||||
toolFolder = 'toolFolder',
|
||||
simple = 'simple',
|
||||
agent = 'agent',
|
||||
workflow = 'advanced',
|
||||
plugin = 'plugin',
|
||||
toolSet = 'toolSet', // 'mcp'
|
||||
workflowTool = 'plugin',
|
||||
mcpToolSet = 'toolSet', // 'mcp'
|
||||
httpToolSet = 'httpToolSet',
|
||||
tool = 'tool',
|
||||
hidden = 'hidden',
|
||||
|
||||
// deprecated
|
||||
tool = 'tool',
|
||||
httpPlugin = 'httpPlugin'
|
||||
}
|
||||
|
||||
export const AppFolderTypeList = [AppTypeEnum.folder, AppTypeEnum.httpPlugin];
|
||||
export const AppFolderTypeList = [
|
||||
AppTypeEnum.folder,
|
||||
AppTypeEnum.toolFolder,
|
||||
AppTypeEnum.httpPlugin
|
||||
];
|
||||
|
||||
export const ToolTypeList = [
|
||||
AppTypeEnum.mcpToolSet,
|
||||
AppTypeEnum.httpToolSet,
|
||||
AppTypeEnum.workflowTool
|
||||
];
|
||||
export const AppTypeList = [AppTypeEnum.simple, AppTypeEnum.agent, AppTypeEnum.workflow];
|
||||
|
||||
export const defaultTTSConfig: AppTTSConfigType = { type: 'web' };
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ export const getAppType = (config?: WorkflowTemplateBasicType | AppSimpleEditFor
|
|||
return AppTypeEnum.workflow;
|
||||
}
|
||||
if (config.nodes.some((node) => node.flowNodeType === 'pluginInput')) {
|
||||
return AppTypeEnum.plugin;
|
||||
return AppTypeEnum.workflowTool;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export type AppVersionSchemaType = {
|
|||
edges: AppSchema['edges'];
|
||||
chatConfig: AppSchema['chatConfig'];
|
||||
isPublish?: boolean;
|
||||
isAutoSave?: boolean;
|
||||
versionName: string;
|
||||
tmbId: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -200,6 +200,10 @@ export const getLastInteractiveValue = (
|
|||
if (lastValue.interactive.type === 'userInput' && !lastValue.interactive.params.submitted) {
|
||||
return lastValue.interactive;
|
||||
}
|
||||
|
||||
if (lastValue.interactive.type === 'paymentPause' && !lastValue.interactive.params.continue) {
|
||||
return lastValue.interactive;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ type ChildrenInteractive = InteractiveNodeType & {
|
|||
};
|
||||
};
|
||||
|
||||
// Loop bode
|
||||
type LoopInteractive = InteractiveNodeType & {
|
||||
type: 'loopInteractive';
|
||||
params: {
|
||||
|
|
@ -80,10 +81,20 @@ type UserInputInteractive = InteractiveNodeType & {
|
|||
};
|
||||
};
|
||||
|
||||
// 欠费暂停交互
|
||||
export type PaymentPauseInteractive = InteractiveNodeType & {
|
||||
type: 'paymentPause';
|
||||
params: {
|
||||
description?: string;
|
||||
continue?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
export type InteractiveNodeResponseType =
|
||||
| UserSelectInteractive
|
||||
| UserInputInteractive
|
||||
| ChildrenInteractive
|
||||
| LoopInteractive;
|
||||
| LoopInteractive
|
||||
| PaymentPauseInteractive;
|
||||
|
||||
export type WorkflowInteractiveResponseType = InteractiveBasicType & InteractiveNodeResponseType;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export type WorkflowTemplateType = {
|
|||
// template market
|
||||
export type TemplateMarketItemType = WorkflowTemplateType & {
|
||||
tags: string[];
|
||||
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.plugin;
|
||||
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.workflowTool;
|
||||
};
|
||||
// template market list
|
||||
export type TemplateMarketListItemType = {
|
||||
|
|
@ -59,6 +59,6 @@ export type TemplateMarketListItemType = {
|
|||
intro?: string;
|
||||
author?: string;
|
||||
tags: string[];
|
||||
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.plugin;
|
||||
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.workflowTool;
|
||||
avatar: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ import { addHours } from 'date-fns';
|
|||
import { imageFileType } from '@fastgpt/global/common/file/constants';
|
||||
import { retryFn } from '@fastgpt/global/common/system/utils';
|
||||
import { UserError } from '@fastgpt/global/common/error/utils';
|
||||
import { S3Sources } from '../../s3/type';
|
||||
import { getS3AvatarSource } from '../../s3/sources/avatar';
|
||||
import path from 'path';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
|
||||
export const maxImgSize = 1024 * 1024 * 12;
|
||||
const base64MimeRegex = /data:image\/([^\)]+);base64/;
|
||||
|
|
@ -56,60 +60,67 @@ export async function uploadMongoImg({
|
|||
|
||||
return `${process.env.NEXT_PUBLIC_BASE_URL || ''}${imageBaseUrl}${String(_id)}.${extension}`;
|
||||
}
|
||||
export const copyImage = async ({
|
||||
|
||||
export const copyAvatarImage = async ({
|
||||
teamId,
|
||||
imageUrl,
|
||||
ttl,
|
||||
session
|
||||
}: {
|
||||
teamId: string;
|
||||
imageUrl: string;
|
||||
ttl: boolean;
|
||||
session?: ClientSession;
|
||||
}) => {
|
||||
const imageId = getIdFromPath(imageUrl);
|
||||
if (!imageId) return imageUrl;
|
||||
if (!imageUrl) return;
|
||||
|
||||
const image = await MongoImage.findOne(
|
||||
{
|
||||
_id: imageId,
|
||||
teamId
|
||||
},
|
||||
undefined,
|
||||
{
|
||||
session
|
||||
}
|
||||
);
|
||||
if (!image) return imageUrl;
|
||||
// S3
|
||||
if (imageUrl.startsWith(`${imageBaseUrl}/${S3Sources.avatar}`)) {
|
||||
const extendName = path.extname(imageUrl);
|
||||
const key = await getS3AvatarSource().copyAvatar({
|
||||
sourceKey: imageUrl.slice(imageBaseUrl.length),
|
||||
targetKey: `${S3Sources.avatar}/${teamId}/${getNanoid(6)}${extendName}`,
|
||||
ttl
|
||||
});
|
||||
return key;
|
||||
}
|
||||
|
||||
const [newImage] = await MongoImage.create(
|
||||
[
|
||||
{
|
||||
teamId,
|
||||
binary: image.binary,
|
||||
metadata: image.metadata
|
||||
}
|
||||
],
|
||||
{
|
||||
session,
|
||||
ordered: true
|
||||
}
|
||||
);
|
||||
|
||||
return `${process.env.NEXT_PUBLIC_BASE_URL || ''}${imageBaseUrl}${String(newImage._id)}.${image.metadata?.mime?.split('/')[1]}`;
|
||||
};
|
||||
|
||||
const getIdFromPath = (path?: string) => {
|
||||
if (!path) return;
|
||||
|
||||
const paths = path.split('/');
|
||||
const paths = imageUrl.split('/');
|
||||
const name = paths[paths.length - 1];
|
||||
|
||||
if (!name) return;
|
||||
|
||||
const id = name.split('.')[0];
|
||||
if (!id || !Types.ObjectId.isValid(id)) return;
|
||||
|
||||
return id;
|
||||
// Mongo
|
||||
if (id && Types.ObjectId.isValid(id)) {
|
||||
const image = await MongoImage.findOne(
|
||||
{
|
||||
_id: id,
|
||||
teamId
|
||||
},
|
||||
undefined,
|
||||
{
|
||||
session
|
||||
}
|
||||
);
|
||||
if (!image) return imageUrl;
|
||||
const [newImage] = await MongoImage.create(
|
||||
[
|
||||
{
|
||||
teamId,
|
||||
binary: image.binary,
|
||||
metadata: image.metadata
|
||||
}
|
||||
],
|
||||
{
|
||||
session,
|
||||
ordered: true
|
||||
}
|
||||
);
|
||||
return `${process.env.NEXT_PUBLIC_BASE_URL || ''}${imageBaseUrl}${String(newImage._id)}.${image.metadata?.mime?.split('/')[1]}`;
|
||||
}
|
||||
|
||||
return imageUrl;
|
||||
};
|
||||
|
||||
export const removeImageByPath = (path?: string, session?: ClientSession) => {
|
||||
if (!path) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,24 @@ export class S3BaseBucket {
|
|||
return this.delete(src);
|
||||
}
|
||||
|
||||
copy(src: string, dst: string, options?: CopyConditions): ReturnType<Client['copyObject']> {
|
||||
async copy({
|
||||
src,
|
||||
dst,
|
||||
ttl,
|
||||
options
|
||||
}: {
|
||||
src: string;
|
||||
dst: string;
|
||||
ttl: boolean;
|
||||
options?: CopyConditions;
|
||||
}): ReturnType<Client['copyObject']> {
|
||||
if (ttl) {
|
||||
await MongoS3TTL.create({
|
||||
minioKey: dst,
|
||||
bucketName: this.name,
|
||||
expiredTime: addHours(new Date(), 24)
|
||||
});
|
||||
}
|
||||
return this.client.copyObject(this.name, src, dst, options);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,23 @@ class S3AvatarSource {
|
|||
await this.deleteAvatar(oldAvatar, session);
|
||||
}
|
||||
}
|
||||
|
||||
async copyAvatar({
|
||||
sourceKey,
|
||||
targetKey,
|
||||
ttl
|
||||
}: {
|
||||
sourceKey: string;
|
||||
targetKey: string;
|
||||
ttl: boolean;
|
||||
}) {
|
||||
await this.bucket.copy({
|
||||
src: sourceKey,
|
||||
dst: targetKey,
|
||||
ttl
|
||||
});
|
||||
return targetKey;
|
||||
}
|
||||
}
|
||||
|
||||
export function getS3AvatarSource() {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ class S3ChatSource {
|
|||
return (this.instance ??= new S3ChatSource());
|
||||
}
|
||||
|
||||
static isChatFileKey(key?: string): key is `${typeof S3Sources.chat}/${string}` {
|
||||
return key?.startsWith(`${S3Sources.chat}/`) ?? false;
|
||||
}
|
||||
|
||||
async createGetChatFileURL(params: { key: string; expiredHours?: number; external: boolean }) {
|
||||
const { key, expiredHours = 1, external = false } = params; // 默认一个小时
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {
|
|||
FlowNodeInputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '@fastgpt/global/core/workflow/node/constant';
|
||||
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { AppFolderTypeList } from '@fastgpt/global/core/app/constants';
|
||||
import { MongoApp } from './schema';
|
||||
import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
||||
import { encryptSecretValue, storeSecretValue } from '../../common/secret/utils';
|
||||
|
|
@ -153,7 +153,7 @@ export const onDelOneApp = async ({
|
|||
});
|
||||
|
||||
const deletedAppIds = apps
|
||||
.filter((app) => app.type !== AppTypeEnum.folder)
|
||||
.filter((app) => !AppFolderTypeList.includes(app.type))
|
||||
.map((app) => String(app._id));
|
||||
|
||||
// Remove eval job
|
||||
|
|
@ -217,6 +217,7 @@ export const onDelOneApp = async ({
|
|||
{ session }
|
||||
);
|
||||
|
||||
// Delete avatar
|
||||
await removeImageByPath(app.avatar, session);
|
||||
};
|
||||
|
||||
|
|
@ -239,10 +240,10 @@ export const onDelOneApp = async ({
|
|||
for await (const app of apps) {
|
||||
if (session) {
|
||||
await del(app, session);
|
||||
return deletedAppIds;
|
||||
}
|
||||
|
||||
await mongoSessionRun((session) => del(app, session));
|
||||
return deletedAppIds;
|
||||
}
|
||||
|
||||
return deletedAppIds;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -148,7 +148,10 @@ export const runHTTPTool = async ({
|
|||
|
||||
const { data } = await axios({
|
||||
method: method.toUpperCase(),
|
||||
baseURL: baseUrl.startsWith('https://') ? baseUrl : `https://${baseUrl}`,
|
||||
baseURL:
|
||||
baseUrl.startsWith('http://') || baseUrl.startsWith('https://')
|
||||
? baseUrl
|
||||
: `https://${baseUrl}`,
|
||||
url: toolPath,
|
||||
headers,
|
||||
data: body,
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ export async function getChildAppPreviewNode({
|
|||
})
|
||||
: true;
|
||||
|
||||
if (item.type === AppTypeEnum.toolSet) {
|
||||
if (item.type === AppTypeEnum.mcpToolSet) {
|
||||
const children = await getMCPChildren(item);
|
||||
version.nodes[0].toolConfig = {
|
||||
mcpToolSet: {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,19 @@ export const serverGetWorkflowToolRunUserQuery = ({
|
|||
|
||||
if (input.renderTypeList.includes(FlowNodeInputTypeEnum.password)) {
|
||||
value = encryptSecretValue(value);
|
||||
} else if (
|
||||
input.renderTypeList.includes(FlowNodeInputTypeEnum.fileSelect) &&
|
||||
Array.isArray(value)
|
||||
) {
|
||||
value = value.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
key: item.key,
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
url: item.key ? undefined : item.url
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ const AppVersionSchema = new Schema(
|
|||
type: chatConfigType
|
||||
},
|
||||
isPublish: Boolean,
|
||||
isAutoSave: Boolean,
|
||||
versionName: String
|
||||
},
|
||||
{
|
||||
|
|
@ -41,7 +42,7 @@ const AppVersionSchema = new Schema(
|
|||
}
|
||||
);
|
||||
|
||||
AppVersionSchema.index({ appId: 1, _id: -1 });
|
||||
AppVersionSchema.index({ appId: 1, time: -1 });
|
||||
|
||||
export const MongoAppVersion = getMongoModel<AppVersionSchemaType>(
|
||||
AppVersionCollectionName,
|
||||
|
|
|
|||
|
|
@ -389,6 +389,8 @@ export const updateInteractiveChat = async (props: Props) => {
|
|||
: item;
|
||||
});
|
||||
finalInteractive.params.submitted = true;
|
||||
} else if (finalInteractive.type === 'paymentPause') {
|
||||
chatItem.value.pop();
|
||||
}
|
||||
|
||||
if (aiResponse.customFeedbacks) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import { ChatItemValueTypeEnum } from '@fastgpt/global/core/chat/constants';
|
||||
import { ChatItemValueTypeEnum, ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
||||
import type { ChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { getS3ChatSource } from '../../common/s3/sources/chat';
|
||||
import type { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io';
|
||||
import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
||||
|
||||
export const addPreviewUrlToChatItems = async (histories: ChatItemType[]) => {
|
||||
// Presign file urls
|
||||
const s3ChatSource = getS3ChatSource();
|
||||
for await (const item of histories) {
|
||||
export const addPreviewUrlToChatItems = async (
|
||||
histories: ChatItemType[],
|
||||
type: 'chatFlow' | 'workflowTool'
|
||||
) => {
|
||||
async function addToChatflow(item: ChatItemType) {
|
||||
for await (const value of item.value) {
|
||||
if (value.type === ChatItemValueTypeEnum.file && value.file && value.file.key) {
|
||||
value.file.url = await s3ChatSource.createGetChatFileURL({
|
||||
|
|
@ -15,4 +18,46 @@ export const addPreviewUrlToChatItems = async (histories: ChatItemType[]) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
async function addToWorkflowTool(item: ChatItemType) {
|
||||
if (item.obj !== ChatRoleEnum.Human || !Array.isArray(item.value)) return;
|
||||
|
||||
for (let j = 0; j < item.value.length; j++) {
|
||||
const value = item.value[j];
|
||||
if (value.type !== ChatItemValueTypeEnum.text) continue;
|
||||
const inputValueString = value.text?.content || '';
|
||||
const parsedInputValue = JSON.parse(inputValueString) as FlowNodeInputItemType[];
|
||||
|
||||
for (const input of parsedInputValue) {
|
||||
if (
|
||||
input.renderTypeList[0] !== FlowNodeInputTypeEnum.fileSelect ||
|
||||
!Array.isArray(input.value)
|
||||
)
|
||||
continue;
|
||||
|
||||
for (const file of input.value) {
|
||||
if (!file.key) continue;
|
||||
const url = await getS3ChatSource().createGetChatFileURL({
|
||||
key: file.key,
|
||||
external: true
|
||||
});
|
||||
file.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
item.value[j].text = {
|
||||
...value.text,
|
||||
content: JSON.stringify(parsedInputValue)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Presign file urls
|
||||
const s3ChatSource = getS3ChatSource();
|
||||
for await (const item of histories) {
|
||||
if (type === 'chatFlow') {
|
||||
await addToChatflow(item);
|
||||
} else if (type === 'workflowTool') {
|
||||
await addToWorkflowTool(item);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ import type { RequireOnlyOne } from '@fastgpt/global/common/type/utils';
|
|||
import { getS3ChatSource } from '../../../common/s3/sources/chat';
|
||||
import { addPreviewUrlToChatItems } from '../../chat/utils';
|
||||
import type { MCPClient } from '../../app/mcp';
|
||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
|
||||
type Props = Omit<ChatDispatchProps, 'workflowDispatchDeep' | 'timezone' | 'externalProvider'> & {
|
||||
runtimeNodes: RuntimeNodeItemType[];
|
||||
|
|
@ -132,7 +134,7 @@ export async function dispatchWorkFlow({
|
|||
}
|
||||
|
||||
// Add preview url to chat items
|
||||
await addPreviewUrlToChatItems(histories);
|
||||
await addPreviewUrlToChatItems(histories, 'chatFlow');
|
||||
for (const item of query) {
|
||||
if (item.type !== ChatItemValueTypeEnum.file || !item.file?.key) continue;
|
||||
item.file.url = await getS3ChatSource().createGetChatFileURL({
|
||||
|
|
@ -620,6 +622,23 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
|||
}
|
||||
};
|
||||
}
|
||||
private async checkTeamBlance(): Promise<NodeResponseCompleteType | undefined> {
|
||||
try {
|
||||
await checkTeamAIPoints(data.runningUserInfo.teamId);
|
||||
} catch (error) {
|
||||
// Next time you enter the system, you will still start from the current node(Current check team blance node).
|
||||
if (error === TeamErrEnum.aiPointsNotEnough) {
|
||||
return {
|
||||
[DispatchNodeResponseKeyEnum.interactive]: {
|
||||
type: 'paymentPause',
|
||||
params: {
|
||||
description: i18nT('chat:balance_not_enough_pause')
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Check node run/skip or wait */
|
||||
private async checkNodeCanRun(
|
||||
node: RuntimeNodeItemType,
|
||||
|
|
@ -652,6 +671,7 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
|||
this.chatResponses.push(responseData);
|
||||
}
|
||||
|
||||
// Push usage in real time. Avoid a workflow usage a large number of points
|
||||
if (nodeDispatchUsages) {
|
||||
if (usageId) {
|
||||
pushChatItemUsage({
|
||||
|
|
@ -763,6 +783,7 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
|||
};
|
||||
};
|
||||
|
||||
// Check queue status
|
||||
if (data.maxRunTimes <= 0) {
|
||||
addLog.error('Max run times is 0', {
|
||||
appId: data.runningAppInfo.id
|
||||
|
|
@ -790,8 +811,17 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
|||
runtimeEdges
|
||||
});
|
||||
|
||||
const nodeRunResult = await (() => {
|
||||
const nodeRunResult = await (async () => {
|
||||
if (status === 'run') {
|
||||
const blanceCheckResult = await this.checkTeamBlance();
|
||||
if (blanceCheckResult) {
|
||||
return {
|
||||
node,
|
||||
runStatus: 'pause' as const,
|
||||
result: blanceCheckResult
|
||||
};
|
||||
}
|
||||
|
||||
// All source edges status to waiting
|
||||
runtimeEdges.forEach((item) => {
|
||||
if (item.target === node.nodeId) {
|
||||
|
|
@ -870,10 +900,21 @@ export const runWorkflow = async (data: RunWorkflowProps): Promise<DispatchFlowR
|
|||
this.debugNextStepRunNodes = this.debugNextStepRunNodes.concat([nodeRunResult.node]);
|
||||
}
|
||||
|
||||
this.nodeInteractiveResponse = {
|
||||
entryNodeIds: [nodeRunResult.node.nodeId],
|
||||
interactiveResponse
|
||||
};
|
||||
// For the pause interactive response, there may be multiple nodes triggered at the same time, so multiple entry nodes need to be recorded.
|
||||
// For other interactive nodes, only one will be triggered at the same time.
|
||||
if (interactiveResponse.type === 'paymentPause') {
|
||||
this.nodeInteractiveResponse = {
|
||||
entryNodeIds: this.nodeInteractiveResponse?.entryNodeIds
|
||||
? this.nodeInteractiveResponse.entryNodeIds.concat(nodeRunResult.node.nodeId)
|
||||
: [nodeRunResult.node.nodeId],
|
||||
interactiveResponse
|
||||
};
|
||||
} else {
|
||||
this.nodeInteractiveResponse = {
|
||||
entryNodeIds: [nodeRunResult.node.nodeId],
|
||||
interactiveResponse
|
||||
};
|
||||
}
|
||||
return;
|
||||
} else if (isDebugMode) {
|
||||
// Debug 模式下一步时候,会自己增加 activeNode
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import type {
|
|||
DispatchNodeResultType,
|
||||
ModuleDispatchProps
|
||||
} from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { getS3ChatSource } from '../../../../common/s3/sources/chat';
|
||||
|
||||
export type PluginInputProps = ModuleDispatchProps<{
|
||||
[key: string]: any;
|
||||
|
|
@ -21,12 +22,12 @@ export const dispatchPluginInput = async (
|
|||
const { params, query } = props;
|
||||
const { files } = chatValue2RuntimePrompt(query);
|
||||
|
||||
/*
|
||||
/*
|
||||
对 params 中文件类型数据进行处理
|
||||
* 插件单独运行时,这里会是一个特殊的数组
|
||||
* 插件调用的话,这个参数是一个 string[] 不会进行处理
|
||||
* 硬性要求:API 单独调用插件时,要避免这种特殊类型冲突
|
||||
|
||||
|
||||
TODO: 需要 filter max files
|
||||
*/
|
||||
for (const key in params) {
|
||||
|
|
@ -37,6 +38,17 @@ export const dispatchPluginInput = async (
|
|||
(item) => item.type === ChatFileTypeEnum.file || item.type === ChatFileTypeEnum.image
|
||||
)
|
||||
) {
|
||||
// 为文件对象重新签发 URL(如果有 key 但没有 url)
|
||||
for (let i = 0; i < val.length; i++) {
|
||||
const fileItem = val[i];
|
||||
if (fileItem.key && !fileItem.url) {
|
||||
val[i].url = await getS3ChatSource().createGetChatFileURL({
|
||||
key: fileItem.key,
|
||||
external: true,
|
||||
expiredHours: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
params[key] = val.map((item) => item.url);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ export const checkTeamAppLimit = async (teamId: string, amount = 1) => {
|
|||
$in: [
|
||||
AppTypeEnum.simple,
|
||||
AppTypeEnum.workflow,
|
||||
AppTypeEnum.plugin,
|
||||
AppTypeEnum.toolSet,
|
||||
AppTypeEnum.workflowTool,
|
||||
AppTypeEnum.mcpToolSet,
|
||||
AppTypeEnum.httpToolSet
|
||||
]
|
||||
}
|
||||
|
|
@ -65,7 +65,12 @@ export const checkTeamAppLimit = async (teamId: string, amount = 1) => {
|
|||
if (global?.licenseData?.maxApps && typeof global?.licenseData?.maxApps === 'number') {
|
||||
const totalApps = await MongoApp.countDocuments({
|
||||
type: {
|
||||
$in: [AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.plugin, AppTypeEnum.toolSet]
|
||||
$in: [
|
||||
AppTypeEnum.simple,
|
||||
AppTypeEnum.workflow,
|
||||
AppTypeEnum.workflowTool,
|
||||
AppTypeEnum.mcpToolSet
|
||||
]
|
||||
}
|
||||
});
|
||||
if (totalApps >= global.licenseData.maxApps) {
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ import { retryFn } from '@fastgpt/global/common/system/utils';
|
|||
|
||||
export function getI18nAppType(type: AppTypeEnum): string {
|
||||
if (type === AppTypeEnum.folder) return i18nT('account_team:type.Folder');
|
||||
if (type === AppTypeEnum.simple) return i18nT('account_team:type.Simple bot');
|
||||
if (type === AppTypeEnum.simple) return i18nT('app:type.Chat_Agent');
|
||||
if (type === AppTypeEnum.workflow) return i18nT('account_team:type.Workflow bot');
|
||||
if (type === AppTypeEnum.plugin) return i18nT('account_team:type.Plugin');
|
||||
if (type === AppTypeEnum.workflowTool) return i18nT('app:toolType_workflow');
|
||||
if (type === AppTypeEnum.httpPlugin) return i18nT('account_team:type.Http plugin');
|
||||
if (type === AppTypeEnum.httpToolSet) return i18nT('account_team:type.Http tool set');
|
||||
if (type === AppTypeEnum.toolSet) return i18nT('account_team:type.Tool set');
|
||||
if (type === AppTypeEnum.tool) return i18nT('account_team:type.Tool');
|
||||
if (type === AppTypeEnum.httpToolSet) return i18nT('app:toolType_http');
|
||||
if (type === AppTypeEnum.mcpToolSet) return i18nT('app:toolType_mcp');
|
||||
if (type === AppTypeEnum.tool) return i18nT('app:toolType_mcp');
|
||||
return i18nT('common:UnKnow');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,12 +93,14 @@ export const iconPaths = {
|
|||
'common/playFill': () => import('./icons/common/playFill.svg'),
|
||||
'common/playLight': () => import('./icons/common/playLight.svg'),
|
||||
'common/publishFill': () => import('./icons/common/publishFill.svg'),
|
||||
'common/refresh': () => import('./icons/common/refresh.svg'),
|
||||
'common/refreshLight': () => import('./icons/common/refreshLight.svg'),
|
||||
'common/resultLight': () => import('./icons/common/resultLight.svg'),
|
||||
'common/retryLight': () => import('./icons/common/retryLight.svg'),
|
||||
'common/rightArrow': () => import('./icons/common/rightArrow.svg'),
|
||||
'common/rightArrowFill': () => import('./icons/common/rightArrowFill.svg'),
|
||||
'common/rightArrowLight': () => import('./icons/common/rightArrowLight.svg'),
|
||||
'common/rocket': () => import('./icons/common/rocket.svg'),
|
||||
'common/routePushLight': () => import('./icons/common/routePushLight.svg'),
|
||||
'common/running': () => import('./icons/common/running.svg'),
|
||||
'common/saveFill': () => import('./icons/common/saveFill.svg'),
|
||||
|
|
@ -115,7 +117,7 @@ export const iconPaths = {
|
|||
'common/text/t': () => import('./icons/common/text/t.svg'),
|
||||
'common/thirdParty': () => import('./icons/common/thirdParty.svg'),
|
||||
'common/tickFill': () => import('./icons/common/tickFill.svg'),
|
||||
'common/plugin': () => import('./icons/common/toolkit.svg'),
|
||||
'common/toolkit': () => import('./icons/common/toolkit.svg'),
|
||||
'common/trash': () => import('./icons/common/trash.svg'),
|
||||
'common/upRightArrowLight': () => import('./icons/common/upRightArrowLight.svg'),
|
||||
'common/uploadFileFill': () => import('./icons/common/uploadFileFill.svg'),
|
||||
|
|
@ -131,10 +133,13 @@ export const iconPaths = {
|
|||
'common/wecom': () => import('./icons/common/wecom.svg'),
|
||||
configmap: () => import('./icons/configmap.svg'),
|
||||
copy: () => import('./icons/copy.svg'),
|
||||
'core/app/agent': () => import('./icons/core/app/agent.svg'),
|
||||
'core/app/aiAgent': () => import('./icons/core/app/aiAgent.svg'),
|
||||
'core/app/aiFill': () => import('./icons/core/app/aiFill.svg'),
|
||||
'core/app/aiLight': () => import('./icons/core/app/aiLight.svg'),
|
||||
'core/app/aiLightSmall': () => import('./icons/core/app/aiLightSmall.svg'),
|
||||
'core/app/appApiLight': () => import('./icons/core/app/appApiLight.svg'),
|
||||
'core/app/create': () => import('./icons/core/app/create.svg'),
|
||||
'core/app/customFeedback': () => import('./icons/core/app/customFeedback.svg'),
|
||||
'core/app/headphones': () => import('./icons/core/app/headphones.svg'),
|
||||
'core/app/inputGuides': () => import('./icons/core/app/inputGuides.svg'),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
|
||||
<path d="M6.43516 14.6379C5.14766 14.2761 4.09766 13.5683 3.28516 12.5144C2.47266 11.4605 2.06641 10.2472 2.06641 8.87441C2.06641 8.16334 2.18516 7.48644 2.42266 6.84373C2.66016 6.20101 2.99766 5.61169 3.43516 5.07576C3.57266 4.92606 3.74141 4.84797 3.94141 4.84148C4.14141 4.835 4.32266 4.91309 4.48516 5.07576C4.62266 5.21299 4.69466 5.3814 4.70116 5.581C4.70766 5.7806 4.64191 5.96773 4.50391 6.14238C4.20391 6.52911 3.97266 6.95326 3.81016 7.41483C3.64766 7.87641 3.56641 8.36294 3.56641 8.87441C3.56641 9.88489 3.86341 10.7863 4.45741 11.5788C5.05141 12.3712 5.81691 12.9106 6.75391 13.197C6.91641 13.2469 7.05066 13.3405 7.15666 13.4777C7.26266 13.6149 7.31591 13.7646 7.31641 13.9268C7.31641 14.1763 7.22891 14.3729 7.05391 14.5166C6.87891 14.6603 6.67266 14.7008 6.43516 14.6379ZM9.69766 14.6379C9.46016 14.7003 9.25391 14.6566 9.07891 14.5069C8.90391 14.3572 8.81641 14.1576 8.81641 13.9081C8.81641 13.7584 8.86966 13.6149 8.97616 13.4777C9.08266 13.3405 9.21691 13.2469 9.37891 13.197C10.3164 12.8976 11.0822 12.3549 11.6762 11.569C12.2702 10.7831 12.5669 9.88489 12.5664 8.87441C12.5664 7.62691 12.1289 6.56653 11.2539 5.69328C10.3789 4.82003 9.31641 4.3834 8.06641 4.3834H8.01016L8.31016 4.6828C8.44766 4.82003 8.51641 4.99468 8.51641 5.20675C8.51641 5.41883 8.44766 5.59348 8.31016 5.7307C8.17266 5.86793 7.99766 5.93654 7.78516 5.93654C7.57266 5.93654 7.39766 5.86793 7.26016 5.7307L5.68516 4.15885C5.61016 4.084 5.55716 4.00291 5.52616 3.91559C5.49516 3.82826 5.47941 3.7347 5.47891 3.6349C5.47891 3.5351 5.49466 3.44153 5.52616 3.35421C5.55766 3.26688 5.61066 3.1858 5.68516 3.11095L7.26016 1.53909C7.39766 1.40186 7.57266 1.33325 7.78516 1.33325C7.99766 1.33325 8.17266 1.40186 8.31016 1.53909C8.44766 1.67632 8.51641 1.85097 8.51641 2.06304C8.51641 2.27512 8.44766 2.44977 8.31016 2.58699L8.01016 2.88639H8.06641C9.74141 2.88639 11.1602 3.46648 12.3227 4.62666C13.4852 5.78684 14.0664 7.20276 14.0664 8.87441C14.0664 10.2342 13.6602 11.4443 12.8477 12.5047C12.0352 13.565 10.9852 14.2761 9.69766 14.6379Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<svg viewBox="0 0 12 12" >
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.5601 1.43999C10.2903 1.16967 9.81371 1.10289 9.45364 1.0532L9.3174 1.03611C8.75317 0.975457 8.18333 0.991271 7.62332 1.08312C6.22735 1.30964 4.56158 2.05277 3.27192 3.91941C3.12685 3.93345 2.97873 3.92826 2.83004 3.92304L2.81782 3.92262L2.70028 3.91888C2.50475 3.91353 2.31029 3.91674 2.1233 3.97016C1.7707 4.07167 1.53831 4.43335 1.37163 4.77099L1.29309 4.93661L1.19853 5.1503L1.13976 5.29669C0.995519 5.67493 0.894547 6.12957 1.19372 6.42821C1.31044 6.54518 1.46088 6.63384 1.62632 6.70668C1.80998 6.78755 2.01213 6.84894 2.20718 6.90796L2.35516 6.95337C2.41459 6.97136 2.47362 6.99067 2.53219 7.01126L2.53739 7.01309C2.56921 7.02432 2.60089 7.03594 2.63244 7.04793L2.66663 7.06182L2.62389 7.10296C2.61703 7.10981 2.61026 7.11679 2.60356 7.12389L2.60007 7.1276C2.42841 7.3112 2.30691 7.57232 2.22107 7.78946C2.198 7.84739 2.17563 7.90715 2.154 7.96803C2.08347 8.16652 2.02074 8.37691 1.96677 8.57479L1.91655 8.76712L1.85031 9.03959L1.76803 9.41249L1.72209 9.64274C1.71347 9.68929 1.71105 9.73659 1.71474 9.78343C1.71788 9.82321 1.72543 9.86265 1.73736 9.90104C1.76332 9.98462 1.80922 10.0606 1.87111 10.1225C1.933 10.1844 2.00901 10.2303 2.0926 10.2563C2.13306 10.2688 2.1747 10.2766 2.21666 10.2794C2.26139 10.2824 2.30649 10.2798 2.35089 10.2715L2.52345 10.2379L2.79965 10.1791L3.03045 10.1257L3.28528 10.0621L3.41831 10.0269C3.6447 9.96525 3.88704 9.8922 4.10961 9.80952C4.14176 9.79758 4.17349 9.78544 4.20471 9.7731C4.2313 9.7625 4.25857 9.75137 4.28627 9.73968C4.49458 9.65182 4.728 9.53242 4.89068 9.36975C4.92883 9.33153 4.96502 9.29141 4.99913 9.24954C5.03011 9.32968 5.05896 9.40928 5.08567 9.48728C5.09721 9.52383 5.10823 9.56053 5.11872 9.59738L5.11888 9.59795C5.14732 9.6979 5.17188 9.79892 5.19252 9.90078L5.21763 10.0114C5.24404 10.1264 5.2728 10.2416 5.31005 10.3514C5.3685 10.5237 5.44785 10.6827 5.57183 10.8063C5.91001 11.145 6.44959 10.9709 6.84921 10.801L7.0629 10.707L7.22852 10.6284C7.56669 10.4617 7.92838 10.2293 8.02988 9.87674C8.09504 9.64975 8.08651 9.4167 8.07796 9.1833L8.07262 9.03157C8.07048 8.93007 8.07102 8.82856 8.08117 8.72812C9.94727 7.43846 10.6904 5.7727 10.9169 4.37672C11.0318 3.66938 11.0142 3.03257 10.9468 2.54641L10.9169 2.34019C10.8662 2.01965 10.7812 1.66064 10.5601 1.43999ZM9.90077 2.49469C9.87921 2.35981 9.85706 2.26275 9.83255 2.19292C9.83014 2.18602 9.82785 2.17987 9.82574 2.17442C9.80977 2.16822 9.78749 2.16047 9.75759 2.1519C9.64214 2.11882 9.50597 2.09801 9.31935 2.07222L9.19888 2.0571C8.72948 2.00743 8.25551 2.02097 7.78968 2.09738L7.78795 2.09766C6.62727 2.286 5.22615 2.89904 4.11754 4.50364L3.84615 4.89645L3.37093 4.94244C3.15604 4.96323 2.94629 4.9557 2.80832 4.95074L2.78348 4.94985L2.67004 4.94624C2.56367 4.94339 2.49942 4.94563 2.45939 4.94947C2.41623 5.00139 2.36185 5.08781 2.29659 5.21921L2.22754 5.36482L2.14567 5.54984L2.0972 5.67059C2.0829 5.70845 2.07089 5.74304 2.06103 5.77454C3.63164 6.01918 4.61274 6.63139 5.22691 7.34254L5.22763 7.34165L5.24167 7.35972C5.36992 7.50999 5.48194 7.66456 5.57981 7.82091C6.08637 8.63012 6.19798 9.47007 6.25502 9.89931L6.25885 9.92812C6.3146 9.90925 6.37514 9.88557 6.44149 9.85747L6.63566 9.77204L6.78063 9.7033C6.91298 9.63769 6.99973 9.58304 7.05154 9.53979C7.05669 9.48812 7.05741 9.40016 7.05084 9.2209L7.05079 9.21947L7.04519 9.06047L7.04504 9.0532C7.0426 8.93729 7.04216 8.78712 7.05857 8.62477L7.1063 8.15247L7.49682 7.88259C9.10096 6.77397 9.71406 5.37269 9.90241 4.21198C9.99913 3.61632 9.98339 3.08421 9.92917 2.69043L9.90077 2.49469ZM4.11243 8.63464C4.1202 8.62816 4.12781 8.62157 4.13526 8.61486C4.22678 8.52339 4.28199 8.40181 4.29064 8.2727C4.29928 8.14359 4.26078 8.01573 4.18227 7.91287L4.13846 7.86265L4.12564 7.85036L4.07542 7.80762C3.99134 7.74539 3.89085 7.70918 3.7864 7.70348C3.68194 7.69779 3.57811 7.72285 3.48776 7.77557L3.42899 7.8151L3.37931 7.85944L3.31253 7.94385C3.23476 8.05631 3.17575 8.19288 3.12809 8.33688L3.12664 8.34126C3.08983 8.45313 3.05981 8.56937 3.03312 8.68218L2.97542 8.9322L2.94817 9.046L3.05021 9.02142L3.27353 8.97013C3.42049 8.93581 3.57507 8.89664 3.71943 8.84457L3.7262 8.84212C3.87184 8.78906 4.00674 8.72268 4.11243 8.63464ZM7.1083 6C7.7196 6 8.21515 5.50445 8.21515 4.89315C8.21515 4.28185 7.7196 3.7863 7.1083 3.7863C6.497 3.7863 6.00145 4.28185 6.00145 4.89315C6.00145 5.50445 6.497 6 7.1083 6Z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.3 KiB |
|
|
@ -0,0 +1,39 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 22" fill="none">
|
||||
<path d="M18.5 21C18.5 21.5523 18.0523 22 17.5 22C16.9477 22 16.5 21.5523 16.5 21C16.5 20.4477 16.9477 20 17.5 20C18.0523 20 18.5 20.4477 18.5 21Z" fill="url(#paint0_linear_26760_132520)"/>
|
||||
<path d="M22.5 17C22.5 17.5523 22.0523 18 21.5 18C20.9477 18 20.5 17.5523 20.5 17C20.5 16.4477 20.9477 16 21.5 16C22.0523 16 22.5 16.4477 22.5 17Z" fill="url(#paint1_linear_26760_132520)"/>
|
||||
<path d="M2.5 5C2.5 5.55228 2.05228 6 1.5 6C0.947715 6 0.5 5.55228 0.5 5C0.5 4.44772 0.947715 4 1.5 4C2.05228 4 2.5 4.44772 2.5 5Z" fill="url(#paint2_linear_26760_132520)"/>
|
||||
<path d="M6.5 1C6.5 1.55228 6.05228 2 5.5 2C4.94772 2 4.5 1.55228 4.5 1C4.5 0.447715 4.94772 0 5.5 0C6.05228 0 6.5 0.447715 6.5 1Z" fill="url(#paint3_linear_26760_132520)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.5 5.48292L10.8478 8.17257C10.5871 9.24768 9.74768 10.0871 8.67257 10.3478L5.98292 11L8.67257 11.6522C9.74768 11.9129 10.5871 12.7523 10.8478 13.8274L11.5 16.5171L12.1522 13.8274C12.4129 12.7523 13.2523 11.9129 14.3274 11.6522L17.0171 11L14.3274 10.3478C13.2523 10.0871 12.4129 9.24768 12.1522 8.17257L11.5 5.48292ZM12.8052 4.02656C12.4733 2.65781 10.5267 2.65781 10.1948 4.02656L9.28151 7.79277C9.16301 8.28146 8.78146 8.66301 8.29277 8.78151L4.52656 9.69476C3.15781 10.0267 3.15781 11.9733 4.52656 12.3052L8.29277 13.2185C8.78146 13.337 9.16301 13.7185 9.28151 14.2072L10.1948 17.9734C10.5267 19.3422 12.4733 19.3422 12.8052 17.9734L13.7185 14.2072C13.837 13.7185 14.2185 13.337 14.7072 13.2185L18.4734 12.3052C19.8422 11.9733 19.8422 10.0267 18.4734 9.69476L14.7072 8.78151C14.2185 8.66301 13.837 8.28146 13.7185 7.79277L12.8052 4.02656Z" fill="url(#paint4_linear_26760_132520)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.50462 21.3147C8.33081 21.7804 7.81241 22.017 7.34673 21.8432C4.3303 20.7173 1.90732 18.3801 0.669734 15.4228C0.477847 14.9643 0.694 14.4371 1.15252 14.2452C1.61105 14.0533 2.13831 14.2694 2.3302 14.728C3.3762 17.2274 5.42654 19.2052 7.97615 20.1568C8.44183 20.3306 8.67843 20.849 8.50462 21.3147Z" fill="url(#paint5_linear_26760_132520)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.8153 8.02077C21.3498 8.19493 20.8312 7.95873 20.657 7.49319C19.6979 4.92954 17.6971 2.87072 15.1693 1.83251C14.7095 1.64366 14.4899 1.11784 14.6787 0.658056C14.8676 0.198271 15.3934 -0.0213681 15.8532 0.167478C18.8427 1.39533 21.2076 3.82798 22.3429 6.86246C22.5171 7.32801 22.2809 7.8466 21.8153 8.02077Z" fill="url(#paint6_linear_26760_132520)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_26760_132520" x1="4.21974e-07" y1="-2.5" x2="22" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#659BFF"/>
|
||||
<stop offset="1" stop-color="#5E3EFF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_26760_132520" x1="4.21974e-07" y1="-2.5" x2="22" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#659BFF"/>
|
||||
<stop offset="1" stop-color="#5E3EFF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_26760_132520" x1="4.21974e-07" y1="-2.5" x2="22" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#659BFF"/>
|
||||
<stop offset="1" stop-color="#5E3EFF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_26760_132520" x1="4.21974e-07" y1="-2.5" x2="22" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#659BFF"/>
|
||||
<stop offset="1" stop-color="#5E3EFF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_26760_132520" x1="4.21974e-07" y1="-2.5" x2="22" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#659BFF"/>
|
||||
<stop offset="1" stop-color="#5E3EFF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_26760_132520" x1="4.21974e-07" y1="-2.5" x2="22" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#659BFF"/>
|
||||
<stop offset="1" stop-color="#5E3EFF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint6_linear_26760_132520" x1="4.21974e-07" y1="-2.5" x2="22" y2="24.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#659BFF"/>
|
||||
<stop offset="1" stop-color="#5E3EFF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
|
|
@ -0,0 +1,45 @@
|
|||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_26760_132256)">
|
||||
<g filter="url(#filter0_if_26760_132256)">
|
||||
<circle cx="12.5" cy="12.5" r="16.5" fill="url(#paint0_radial_26760_132256)"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_d_26760_132256)">
|
||||
<path d="M10.2593 6.586C10.7078 5.2735 12.5213 5.23375 13.053 6.46675L13.098 6.58675L13.7033 8.35675C13.842 8.76267 14.0661 9.13413 14.3606 9.44607C14.6551 9.758 15.013 10.0032 15.4103 10.165L15.573 10.2257L17.343 10.8303C18.6555 11.2788 18.6953 13.0922 17.463 13.624L17.343 13.669L15.573 14.2743C15.167 14.4129 14.7954 14.637 14.4833 14.9314C14.1712 15.2259 13.926 15.5839 13.764 15.9813L13.7033 16.1432L13.0988 17.914C12.6503 19.2265 10.8368 19.2662 10.3058 18.034L10.2593 17.914L9.65478 16.144C9.51617 15.7379 9.29206 15.3663 8.99759 15.0543C8.70312 14.7422 8.34513 14.4969 7.94778 14.335L7.78578 14.2743L6.01578 13.6698C4.70253 13.2212 4.66278 11.4077 5.89578 10.8767L6.01578 10.8303L7.78578 10.2257C8.19171 10.087 8.56317 9.8629 8.8751 9.56843C9.18704 9.27396 9.43219 8.91602 9.59403 8.51875L9.65478 8.35675L10.2593 6.586ZM17.679 4C17.8193 4 17.9568 4.03936 18.0759 4.1136C18.195 4.18785 18.2908 4.294 18.3525 4.42L18.3885 4.50775L18.651 5.27725L19.4213 5.53975C19.5619 5.58752 19.6852 5.67596 19.7755 5.79386C19.8658 5.91176 19.919 6.05381 19.9285 6.20202C19.938 6.35022 19.9032 6.4979 19.8287 6.62634C19.7542 6.75478 19.6432 6.8582 19.5098 6.9235L19.4213 6.9595L18.6518 7.222L18.3893 7.99225C18.3414 8.13282 18.2529 8.25602 18.135 8.34624C18.017 8.43647 17.875 8.48964 17.7268 8.49904C17.5786 8.50844 17.4309 8.47363 17.3025 8.39903C17.1741 8.32443 17.0708 8.2134 17.0055 8.08L16.9695 7.99225L16.707 7.22275L15.9368 6.96025C15.7962 6.91248 15.6729 6.82404 15.5826 6.70614C15.4923 6.58824 15.4391 6.44619 15.4296 6.29798C15.4201 6.14978 15.4548 6.0021 15.5294 5.87366C15.6039 5.74522 15.7149 5.6418 15.8483 5.5765L15.9368 5.5405L16.7063 5.278L16.9688 4.50775C17.0194 4.35957 17.115 4.23093 17.2424 4.13987C17.3698 4.04882 17.5225 3.99991 17.679 4Z" fill="white"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_if_26760_132256" x="-7" y="-7" width="39" height="39" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dx="1" dy="1"/>
|
||||
<feGaussianBlur stdDeviation="0.4"/>
|
||||
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
|
||||
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_26760_132256"/>
|
||||
<feGaussianBlur stdDeviation="1.5" result="effect2_foregroundBlur_26760_132256"/>
|
||||
</filter>
|
||||
<filter id="filter1_d_26760_132256" x="-6" y="-7" width="36.9301" height="36.9292" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="5.5"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_26760_132256"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_26760_132256" result="shape"/>
|
||||
</filter>
|
||||
<radialGradient id="paint0_radial_26760_132256" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(23 0.499999) rotate(133.069) scale(31.4841)">
|
||||
<stop stop-color="#FF00F0"/>
|
||||
<stop offset="0.372517" stop-color="#DF8856"/>
|
||||
<stop offset="0.453773" stop-color="#FACB66"/>
|
||||
<stop offset="0.507813" stop-color="white"/>
|
||||
<stop offset="0.61055" stop-color="#6CCF94"/>
|
||||
<stop offset="0.678775" stop-color="#2397E5"/>
|
||||
<stop offset="0.893417" stop-color="#2C009C"/>
|
||||
</radialGradient>
|
||||
<clipPath id="clip0_26760_132256">
|
||||
<rect width="24" height="24" rx="4" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
|
|
@ -0,0 +1,14 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33 33" fill="none">
|
||||
<path d="M13.9446 6.46076C14.2193 5.34828 15.8008 5.34828 16.0754 6.46076C17.2477 11.2094 20.9555 14.9171 25.7041 16.0893C26.8167 16.3639 26.8167 17.9455 25.7041 18.2201C20.9555 19.3924 17.2477 23.1 16.0754 27.8487C15.8008 28.9611 14.2193 28.9611 13.9446 27.8487C12.7723 23.1 9.06455 19.3924 4.31589 18.2201C3.20337 17.9455 3.20337 16.3639 4.31589 16.0893C9.06455 14.9171 12.7723 11.2094 13.9446 6.46076Z" fill="url(#paint0_linear_29084_178923)"/>
|
||||
<path d="M25.654 1.74675C25.7652 1.29646 26.4053 1.29646 26.5165 1.74675C26.991 3.66882 28.4917 5.16953 30.4138 5.64401C30.8641 5.75517 30.8641 6.39533 30.4138 6.50649C28.4917 6.98097 26.991 8.48169 26.5165 10.4038C26.4053 10.854 25.7652 10.854 25.654 10.4038C25.1795 8.48169 23.6787 6.98097 21.7567 6.50649C21.3064 6.39533 21.3064 5.75518 21.7567 5.64401C23.6787 5.16953 25.1795 3.66882 25.654 1.74675Z" fill="url(#paint1_linear_29084_178923)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_29084_178923" x1="15.01" y1="2.14526" x2="15.01" y2="32.1642" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#B38FFF"/>
|
||||
<stop offset="1" stop-color="#6780FE"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_29084_178923" x1="26.0852" y1="0" x2="26.0852" y2="12.1505" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#B38FFF"/>
|
||||
<stop offset="1" stop-color="#6780FE"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
|
@ -1,19 +1,12 @@
|
|||
<svg viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="32" height="32" rx="5.9541" fill="url(#paint0_linear_5533_28322)" />
|
||||
<path
|
||||
d="M15.1466 6.22388C15.593 5.96615 16.3168 5.96615 16.7632 6.22388L23.5846 10.1622C24.4774 10.6776 24.4774 11.5134 23.5846 12.0288L16.853 15.9153C16.4066 16.1731 15.6828 16.1731 15.2364 15.9153L8.41507 11.977C7.52225 11.4616 7.52225 10.6258 8.41506 10.1104L15.1466 6.22388Z"
|
||||
fill="white" />
|
||||
<path
|
||||
d="M7.18506 14.3387C7.18506 13.617 7.6917 13.3245 8.31667 13.6853L14.6222 17.3258C14.9793 17.532 15.2688 18.0335 15.2688 18.4458V25.1119C15.2688 25.8336 14.7622 26.1261 14.1372 25.7653L7.83169 22.1248C7.47457 21.9186 7.18506 21.4172 7.18506 21.0048V14.3387Z"
|
||||
fill="white" />
|
||||
<path
|
||||
d="M16.7302 18.4962C16.7302 18.0838 17.0197 17.5823 17.3768 17.3762L23.6833 13.7351C24.3083 13.3742 24.8149 13.6668 24.8149 14.3884V21.0537C24.8149 21.4661 24.5254 21.9675 24.1683 22.1737L17.8618 25.8148C17.2368 26.1756 16.7302 25.8831 16.7302 25.1614V18.4962Z"
|
||||
fill="white" />
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_5533_28322" x1="16" y1="0" x2="4.88889" y2="29.3333"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF" />
|
||||
<stop offset="1" stop-color="#5BA6FF" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="24" height="24" rx="4" fill="url(#paint0_linear_28962_6379)"/>
|
||||
<path d="M11.3599 4.66817C11.6947 4.47487 12.2375 4.47487 12.5723 4.66817L17.6883 7.62189C18.3579 8.00849 18.3579 8.6353 17.6883 9.0219L12.6396 11.9368C12.3048 12.1301 11.762 12.1301 11.4272 11.9368L6.31118 8.98302C5.64157 8.59643 5.64157 7.96962 6.31118 7.58302L11.3599 4.66817Z" fill="white"/>
|
||||
<path d="M5.38867 10.7543C5.38867 10.213 5.76865 9.99365 6.23738 10.2643L10.9665 12.9946C11.2344 13.1493 11.4515 13.5254 11.4515 13.8346V18.8342C11.4515 19.3755 11.0715 19.5948 10.6028 19.3242L5.87365 16.5938C5.6058 16.4392 5.38867 16.0631 5.38867 15.7538V10.7543Z" fill="white"/>
|
||||
<path d="M12.5475 13.8724C12.5475 13.5631 12.7646 13.187 13.0325 13.0324L17.7624 10.3016C18.2311 10.0309 18.6111 10.2503 18.6111 10.7916V15.7905C18.6111 16.0998 18.3939 16.4759 18.1261 16.6305L13.3962 19.3613C12.9275 19.632 12.5475 19.4126 12.5475 18.8713V13.8724Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_28962_6379" x1="12" y1="0" x2="3.66667" y2="22" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#5BA6FF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
|
@ -38,7 +38,7 @@ const options = {
|
|||
horizontalScrollbarSize: 8,
|
||||
alwaysConsumeMouseWheel: false
|
||||
},
|
||||
lineNumbersMinChars: 0,
|
||||
lineNumbersMinChars: 4,
|
||||
fontSize: 14,
|
||||
scrollBeyondLastLine: false,
|
||||
folding: true,
|
||||
|
|
@ -129,7 +129,6 @@ const MyEditor = ({
|
|||
py={1}
|
||||
height={height}
|
||||
position={'relative'}
|
||||
pl={2}
|
||||
{...props}
|
||||
>
|
||||
<Editor
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ const ToolTagFilterBox = ({
|
|||
>
|
||||
{t('common:All')}
|
||||
</Box>
|
||||
<Box mx={2} h={'20px'} w={'1px'} bg={'myGray.200'} />
|
||||
<Box mx={2} h={'20px'} w={'1px'} bg={'myGray.200'} flexShrink={0} />
|
||||
<Box flex={1}>
|
||||
<Flex gap={2} flexWrap="nowrap">
|
||||
{tags.map((tag) => {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"custom_model": "custom model",
|
||||
"default_model": "Default model",
|
||||
"default_model_config": "Default model configuration",
|
||||
"language": "Language and time zone",
|
||||
"logout": "Sign out",
|
||||
"model.active": "Active",
|
||||
"model.alias": "Alias",
|
||||
|
|
|
|||
|
|
@ -51,18 +51,21 @@
|
|||
"app.version_past": "Previously Published",
|
||||
"app.version_publish_tips": "This version will be saved to the team cloud, synchronized with the entire team, and update the app version on all release channels.",
|
||||
"app_detail": "Application Details",
|
||||
"app_name_placeholder": "Enter app name",
|
||||
"apply_code": "Apply",
|
||||
"apply_code_failed": "Failed to apply code",
|
||||
"auto_execute": "Automatic execution",
|
||||
"auto_execute_default_prompt_placeholder": "Default questions sent when executing automatically",
|
||||
"auto_execute_tip": "After turning it on, the workflow will be automatically triggered when the user enters the conversation interface. \nExecution order: 1. Dialogue starter; 2. Global variables; 3. Automatic execution.",
|
||||
"auto_save": "Auto save",
|
||||
"change_app_type": "Change App Type",
|
||||
"chat_debug": "Chat Preview",
|
||||
"chat_logs": "Logs",
|
||||
"chat_logs_tips": "Logs will record the online, shared, and API (requires chatId) conversation records of this app.",
|
||||
"click_to_config": "Go to configuration",
|
||||
"code_applied_successfully": "Code applied successfully",
|
||||
"code_function_describe": "Describe your code function, enter \"/\" to select the variable",
|
||||
"collapse_tool_create": "close",
|
||||
"config_ai_model_params": "Click to configure AI model related properties",
|
||||
"config_file_upload": "Click to Configure File Upload Rules",
|
||||
"config_question_guide": "Configuration guess you want to ask",
|
||||
|
|
@ -78,16 +81,20 @@
|
|||
"core.module.template.System Tools": "System Tools",
|
||||
"core.workflow.Copilot": "AI Generation",
|
||||
"create_by_curl": "By CURL",
|
||||
"create_by_template": "By template",
|
||||
"create_by_template": "Create by template",
|
||||
"create_copy_success": "Duplicate Created Successfully",
|
||||
"create_empty_app": "Create Default App",
|
||||
"create_empty_plugin": "Create Default Plugin",
|
||||
"create_empty_workflow": "Create Default Workflow",
|
||||
"create_from_template": "Create from template",
|
||||
"create_http_toolset": "Create HTTP Toolset",
|
||||
"create_your_first_agent": "Create your first Agent",
|
||||
"create_your_first_tool": "Create your first tool",
|
||||
"cron.every_day": "Run Daily",
|
||||
"cron.every_month": "Run Monthly",
|
||||
"cron.every_week": "Run Weekly",
|
||||
"cron.interval": "Run at Intervals",
|
||||
"current_package": "Current package: ",
|
||||
"custom_plugin": "Custom Plugin",
|
||||
"custom_plugin_associated_plugin_label": "Associated Plugin",
|
||||
"custom_plugin_associated_plugin_placeholder": "Enter plugin name or appId to search",
|
||||
|
|
@ -130,6 +137,7 @@
|
|||
"edit_info": "Edit",
|
||||
"empty_tool_tips": "Please add tools on the left side",
|
||||
"execute_time": "Execution Time",
|
||||
"expand_tool_create": "Expand MCP/Http create",
|
||||
"export_config_successful": "Configuration copied, some sensitive information automatically filtered. Please check for any remaining sensitive data.",
|
||||
"export_configs": "Export",
|
||||
"fastgpt_marketplace": "FastGPT plug-in market",
|
||||
|
|
@ -142,6 +150,8 @@
|
|||
"find_more_tools": "Explore more",
|
||||
"go_to_chat": "Go to Conversation",
|
||||
"go_to_run": "Go to Execution",
|
||||
"has_no_create_per": "You do not have permission to create in the current directory.",
|
||||
"hide_templates": "Collapse",
|
||||
"http_toolset_add_tips": "Click the \"Add\" button to add tools",
|
||||
"http_toolset_config_tips": "Click \"Start Configuration\" to add tools",
|
||||
"image": "picture",
|
||||
|
|
@ -259,6 +269,7 @@
|
|||
"plugin_cost_by_token": "Charged based on token usage",
|
||||
"plugin_cost_folder_tip": "This tool set contains subordinate tools, and the call points are determined based on the actual calling tool",
|
||||
"plugin_cost_per_times": "{{cost}} points/time",
|
||||
"plugin_db": "Plugins",
|
||||
"plugin_dispatch": "Plugin Invocation",
|
||||
"plugin_dispatch_tip": "Adds extra capabilities to the model. The specific plugins to be invoked will be autonomously decided by the model.\nIf a plugin is selected, the Dataset invocation will automatically be treated as a special plugin.",
|
||||
"plugin_offline_tips": "Your system does not have direct access to plugin market data,\n\nPlease manually copy the URL and go to get more plugins",
|
||||
|
|
@ -274,16 +285,22 @@
|
|||
"publish_success": "Publish Successful",
|
||||
"question_guide_tip": "After the conversation, 3 guiding questions will be generated for you.",
|
||||
"reasoning_response": "Output thinking",
|
||||
"recharge": "Go to recharge",
|
||||
"reference_variable": "Reference variables",
|
||||
"refresh_templates": "Refresh",
|
||||
"remaining_points": "Reaming points: ",
|
||||
"request_headers": "Request header",
|
||||
"response_format": "Response format",
|
||||
"save_team_app_log_keys": "Save as team configuration",
|
||||
"saved_success": "Saved successfully! \nTo use this version externally, click Save and Publish",
|
||||
"search_agent": "Search Agent",
|
||||
"search_app": "Search apps",
|
||||
"search_tool": "Search Tools",
|
||||
"secret_get_course": "Course",
|
||||
"select_app_type": "Select App Type",
|
||||
"setting_app": "Workflow",
|
||||
"setting_plugin": "Workflow",
|
||||
"show_templates": "Expand",
|
||||
"show_top_p_tip": "An alternative method of temperature sampling, called Nucleus sampling, the model considers the results of tokens with TOP_P probability mass quality. \nTherefore, 0.1 means that only tokens containing the highest probability quality are considered. \nThe default is 1.",
|
||||
"simple_tool_tips": "This plugin contains special inputs and is not currently supported for invocation by simple applications.",
|
||||
"source_updateTime": "Update time",
|
||||
|
|
@ -326,6 +343,9 @@
|
|||
"time_type": "Time Type",
|
||||
"time_zone": "Time Zone",
|
||||
"too_to_active": "Active",
|
||||
"toolType_http": "HTTP tools",
|
||||
"toolType_mcp": "MCP tools",
|
||||
"toolType_workflow": "Workflow tools",
|
||||
"tool_active_manual_config_desc": "The temporary key is saved in this application and is only for use by this application.",
|
||||
"tool_active_system_config_desc": "Use the system configured key",
|
||||
"tool_active_system_config_price_desc": "Additional payment for key price ({{price}} points/time)",
|
||||
|
|
@ -339,7 +359,6 @@
|
|||
"tool_soon_offset_tips": "This tool will be offline in the future. For the sake of your business stability, please replace it as soon as possible.",
|
||||
"tool_tip": "When executed as a tool, is this field used as a tool response result?",
|
||||
"tool_type_tools": "tool",
|
||||
"plugin_db": "Plugins",
|
||||
"toolkit_activation_label": "Key Activation",
|
||||
"toolkit_activation_not_required": "No Activation",
|
||||
"toolkit_activation_required": "Activation Required",
|
||||
|
|
@ -411,6 +430,7 @@
|
|||
"tts_browser": "Browser's own (free)",
|
||||
"tts_close": "Close",
|
||||
"type.All": "All",
|
||||
"type.Chat_Agent": "Dialogue Agent",
|
||||
"type.Create http plugin tip": "Batch create plugins through OpenAPI Schema, compatible with GPTs format.",
|
||||
"type.Create mcp tools tip": "Automatically parse and batch create callable MCP tools by entering the MCP address",
|
||||
"type.Create one plugin tip": "Customizable input and output workflows, usually used to encapsulate reusable workflows.",
|
||||
|
|
@ -441,8 +461,17 @@
|
|||
"type.error.Workflow data is empty": "No workflow data was obtained",
|
||||
"type.error.workflowresponseempty": "Response content is empty",
|
||||
"type.hidden": "Hide app",
|
||||
"type_http_tool_set_intro": "Batch import API tool",
|
||||
"type_mcp_intro": "Connect to MCP service",
|
||||
"type_not_recognized": "App type not recognized",
|
||||
"type_plugin_description": "Output the specified results with one click.",
|
||||
"type_plugin_intro": "Commonly used to encapsulate workflow",
|
||||
"type_simple_description": "The most basic conversation application, no complicated configuration is required, and it can be created and used quickly.",
|
||||
"type_simple_intro": "Quickly create conversation agents",
|
||||
"type_workflow_description": "Memory-enabled complex multi-turn conversational workflows.",
|
||||
"type_workflow_intro": "Drag and drop arrangement and multiple rounds of dialogue",
|
||||
"un_auth": "No permission",
|
||||
"unnamed_app": "Unnamed",
|
||||
"upload_file_exists_filtered": "Duplicate files have been automatically filtered.",
|
||||
"upload_file_extension_type_canSelectAudio": "Audio",
|
||||
"upload_file_extension_type_canSelectCustomFileExtension": "Custom file extension type",
|
||||
|
|
@ -455,6 +484,7 @@
|
|||
"upload_file_max_amount_tip": "Maximum number of files uploaded in a single round of conversation",
|
||||
"upload_method": "Upload method",
|
||||
"url_upload": "File link",
|
||||
"used_points": "Used point: ",
|
||||
"variable.internal_type_desc": "Use only inside the workflow and will not appear in the dialog box",
|
||||
"variable.select type_desc": "The input box will be displayed in the site conversation and run preview, and this variable will not be displayed in the sharing link.",
|
||||
"variable.textarea_type_desc": "Allows users to input up to 4000 characters in the dialogue box.",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
"LLM_model_response_empty": "The model flow response is empty, please check whether the model flow output is normal.",
|
||||
"ai_reasoning": "Thinking process",
|
||||
"back_to_text": "Text input",
|
||||
"balance_not_enough_pause": "Workflow paused due to insufficient AI points",
|
||||
"chat.quote.No Data": "The file cannot be found",
|
||||
"chat.quote.deleted": "This data has been deleted ~",
|
||||
"chat.waiting_for_response": "Please wait for the conversation to complete",
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
"chat_input_guide_lexicon_is_empty": "Lexicon not configured yet",
|
||||
"chat_test_app": "Debug-{{name}}",
|
||||
"citations": "{{num}} References",
|
||||
"clear_input_value": "Clear input",
|
||||
"click_contextual_preview": "Click to see contextual preview",
|
||||
"click_to_add_url": "Click to add link",
|
||||
"completion_finish_close": "Disconnection",
|
||||
|
|
@ -24,10 +26,12 @@
|
|||
"config_input_guide": "Set Up Input Guide",
|
||||
"config_input_guide_lexicon": "Set Up Lexicon",
|
||||
"config_input_guide_lexicon_title": "Set Up Lexicon",
|
||||
"confirm_clear_input_value": "Are you sure to clear the form content? \nDefault values will be restored!",
|
||||
"confirm_to_clear_share_chat_history": "Are you sure you want to clear all chat history?",
|
||||
"content_empty": "No Content",
|
||||
"contextual": "{{num}} Contexts",
|
||||
"contextual_preview": "Contextual Preview {{num}} Items",
|
||||
"continue_run": "continue running",
|
||||
"core.chat.moveCancel": "Swipe to Cancel",
|
||||
"core.chat.shortSpeak": "Speaking Time is Too Short",
|
||||
"csv_input_lexicon_tip": "Only CSV batch import is supported, click to download the template",
|
||||
|
|
@ -161,6 +165,7 @@
|
|||
"source_cronJob": "Scheduled execution",
|
||||
"start_chat": "Start",
|
||||
"stream_output": "Stream Output",
|
||||
"task_has_continued": "Task has continued running",
|
||||
"unsupported_file_type": "Unsupported file types",
|
||||
"upload": "Upload",
|
||||
"variable_invisable_in_share": "External variables are not visible in login-free links",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"Confirm": "Confirm",
|
||||
"Continue_Adding": "Continue adding",
|
||||
"Copy": "Copy",
|
||||
"Create": "create",
|
||||
"Creating": "Creating",
|
||||
"Delete": "Delete",
|
||||
"Detail": "Detail",
|
||||
|
|
@ -99,7 +100,9 @@
|
|||
"all_quotes": "All quotes",
|
||||
"all_result": "Full Results",
|
||||
"app_evaluation": "App Evaluation(Beta)",
|
||||
"app_icon_and_name": "icon",
|
||||
"app_not_version": "This application has not been published, please publish it first",
|
||||
"app_type": "Application Type",
|
||||
"auth_config": "Authentication",
|
||||
"auth_type": "Authentication type",
|
||||
"auth_type.Custom": "Customize",
|
||||
|
|
@ -754,6 +757,7 @@
|
|||
"core.workflow.tool.Select Tool": "Select Tool",
|
||||
"core.workflow.variable": "Variable",
|
||||
"create": "Create",
|
||||
"create_app": "Create an application",
|
||||
"create_failed": "Create failed",
|
||||
"create_success": "Created Successfully",
|
||||
"create_time": "Creation Time",
|
||||
|
|
@ -919,8 +923,8 @@
|
|||
"name": "name",
|
||||
"name_is_empty": "Name Cannot Be Empty",
|
||||
"navbar.Account": "Account",
|
||||
"navbar.Chat": "Chat",
|
||||
"navbar.Config": "administrator",
|
||||
"navbar.Chat": "portal",
|
||||
"navbar.Config": "admini",
|
||||
"navbar.Datasets": "Dataset",
|
||||
"navbar.Studio": "Studio",
|
||||
"navbar.Toolkit": "Toolkit",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"bill.valid_time": "Effective Time",
|
||||
"bill.you_can_convert": "You can convert",
|
||||
"bill.yuan": "Yuan",
|
||||
"current_package": "Current package: ",
|
||||
"delete.admin_failed": "Failed to Delete Admin",
|
||||
"delete.admin_success": "Admin Deleted Successfully",
|
||||
"delete.failed": "Delete failed",
|
||||
|
|
@ -87,6 +88,7 @@
|
|||
"team.add_writer": "Add writable members",
|
||||
"team.avatar_and_name": "avatar",
|
||||
"team.belong_to_group": "Member group",
|
||||
"team.collaborator.added": "Added",
|
||||
"team.group.avatar": "Group avatar",
|
||||
"team.group.create": "Create group",
|
||||
"team.group.create_failed": "Failed to create group",
|
||||
|
|
@ -110,6 +112,5 @@
|
|||
"team.manage_collaborators": "Manage Collaborators",
|
||||
"team.no_collaborators": "No Collaborators",
|
||||
"team.org.org": "Organization",
|
||||
"team.write_role_member": "Write Permission",
|
||||
"team.collaborator.added": "Added"
|
||||
"team.write_role_member": "Write Permission"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"custom_model": "自定义模型",
|
||||
"default_model": "预设模型",
|
||||
"default_model_config": "默认模型配置",
|
||||
"language": "语言与时区",
|
||||
"logout": "登出",
|
||||
"model.active": "启用",
|
||||
"model.alias": "别名",
|
||||
|
|
|
|||
|
|
@ -53,18 +53,21 @@
|
|||
"app.version_past": "发布过",
|
||||
"app.version_publish_tips": "该版本将被保存至团队云端,同步给整个团队,同时更新所有发布渠道的应用版本",
|
||||
"app_detail": "应用详情",
|
||||
"app_name_placeholder": "请输入应用名称",
|
||||
"apply_code": "应用",
|
||||
"apply_code_failed": "应用代码失败",
|
||||
"auto_execute": "自动执行",
|
||||
"auto_execute_default_prompt_placeholder": "自动执行时,发送的默认问题",
|
||||
"auto_execute_tip": "开启后,用户进入对话界面将自动触发工作流。执行顺序:1、对话开场白;2、全局变量;3、自动执行。",
|
||||
"auto_save": "自动保存",
|
||||
"change_app_type": "更改应用类型",
|
||||
"chat_debug": "调试预览",
|
||||
"chat_logs": "对话日志",
|
||||
"chat_logs_tips": "日志会记录该应用的在线、分享和 API(需填写 chatId)对话记录",
|
||||
"click_to_config": "去配置",
|
||||
"code_applied_successfully": "代码应用成功",
|
||||
"code_function_describe": "描述你的代码功能,输入“/”可选择变量",
|
||||
"collapse_tool_create": "收起",
|
||||
"config_ai_model_params": "点击配置 AI 模型相关属性",
|
||||
"config_file_upload": "点击配置文件上传规则",
|
||||
"config_question_guide": "配置猜你想问",
|
||||
|
|
@ -80,16 +83,20 @@
|
|||
"core.module.template.System Tools": "系统工具",
|
||||
"core.workflow.Copilot": "AI 生成",
|
||||
"create_by_curl": "从 CURL 创建",
|
||||
"create_by_template": "从模板选择",
|
||||
"create_by_template": "从模板创建",
|
||||
"create_copy_success": "创建副本成功",
|
||||
"create_empty_app": "创建空白应用",
|
||||
"create_empty_plugin": "创建空白插件",
|
||||
"create_empty_workflow": "创建空白工作流",
|
||||
"create_from_template": "从模板新建",
|
||||
"create_http_toolset": "创建 HTTP 工具集",
|
||||
"create_your_first_agent": "创建你的第一个 Agent",
|
||||
"create_your_first_tool": "创建你的第一个工具",
|
||||
"cron.every_day": "每天执行",
|
||||
"cron.every_month": "每月执行",
|
||||
"cron.every_week": "每周执行",
|
||||
"cron.interval": "间隔执行",
|
||||
"current_package": "当前套餐:",
|
||||
"custom_plugin": "自定义插件",
|
||||
"custom_plugin_associated_plugin_label": "关联插件",
|
||||
"custom_plugin_associated_plugin_placeholder": "输入插件名或 appId 查找插件",
|
||||
|
|
@ -134,6 +141,7 @@
|
|||
"edit_param": "编辑参数",
|
||||
"empty_tool_tips": "请在左侧添加工具",
|
||||
"execute_time": "执行时间",
|
||||
"expand_tool_create": "展开MCP、Http创建",
|
||||
"export_config_successful": "已复制配置,自动过滤部分敏感信息,请注意检查是否仍有敏感数据",
|
||||
"export_configs": "导出配置",
|
||||
"fastgpt_marketplace": "FastGPT 插件市场",
|
||||
|
|
@ -146,6 +154,8 @@
|
|||
"find_more_tools": "探索更多",
|
||||
"go_to_chat": "去对话",
|
||||
"go_to_run": "去运行",
|
||||
"has_no_create_per": "当前目录您无新建权限",
|
||||
"hide_templates": "隐藏模板",
|
||||
"http_toolset_add_tips": "点击添加按钮来添加工具",
|
||||
"http_toolset_config_tips": "点击开始配置来添加工具",
|
||||
"image": "图片",
|
||||
|
|
@ -268,6 +278,7 @@
|
|||
"permission.des.write": "可查看和编辑应用",
|
||||
"permission.name.read": "仅对话",
|
||||
"permission.name.readChatLog": "查看对话日志",
|
||||
"plugin": "资源库",
|
||||
"plugin.Instructions": "使用说明",
|
||||
"plugin_cost_by_token": "依据 token 消耗计费",
|
||||
"plugin_cost_folder_tip": "该工具集包含下属工具,调用积分依据实际调用工具决定",
|
||||
|
|
@ -287,16 +298,22 @@
|
|||
"publish_success": "发布成功",
|
||||
"question_guide_tip": "对话结束后,会为你生成 3 个引导性问题。",
|
||||
"reasoning_response": "输出思考",
|
||||
"recharge": "去充值",
|
||||
"reference_variable": "引用变量",
|
||||
"refresh_templates": "换一批",
|
||||
"remaining_points": "剩余积分:",
|
||||
"request_headers": "请求头",
|
||||
"response_format": "回复格式",
|
||||
"save_team_app_log_keys": "保存为团队配置",
|
||||
"saved_success": "保存成功!如需在外部使用该版本,请点击“保存并发布”",
|
||||
"search_agent": "搜索 Agent",
|
||||
"search_app": "搜索应用",
|
||||
"search_tool": "搜索工具",
|
||||
"secret_get_course": "教程",
|
||||
"select_app_type": "选择应用类型",
|
||||
"setting_app": "应用配置",
|
||||
"setting_plugin": "插件配置",
|
||||
"show_templates": "显示模板",
|
||||
"show_top_p_tip": "用温度采样的替代方法,称为Nucleus采样,该模型考虑了具有TOP_P概率质量质量的令牌的结果。因此,0.1表示仅考虑包含最高概率质量的令牌。默认为 1。",
|
||||
"simple_tool_tips": "该插件含有特殊输入,暂不支持被简易应用调用",
|
||||
"source_updateTime": "更新时间",
|
||||
|
|
@ -343,6 +360,9 @@
|
|||
"time_type": "时间类型",
|
||||
"time_zone": "时区",
|
||||
"too_to_active": "去激活",
|
||||
"toolType_http": "HTTP 工具",
|
||||
"toolType_mcp": "MCP 工具",
|
||||
"toolType_workflow": "工作流工具",
|
||||
"tool_active_manual_config_desc": "临时密钥保存在本应用中,仅供该应用使用",
|
||||
"tool_active_system_config_desc": "使用系统已配置好的密钥",
|
||||
"tool_active_system_config_price_desc": "需额外支付密钥价格( {{price}} 积分/次)",
|
||||
|
|
@ -356,7 +376,6 @@
|
|||
"tool_soon_offset_tips": "该工具将在后续下线,为了您的业务稳定,请尽快替换",
|
||||
"tool_tip": "作为工具执行时,该字段是否作为工具响应结果",
|
||||
"tool_type_tools": "工具",
|
||||
"plugin": "资源库",
|
||||
"toolkit_activation_label": "密钥激活",
|
||||
"toolkit_activation_not_required": "免激活",
|
||||
"toolkit_activation_required": "需要激活",
|
||||
|
|
@ -428,6 +447,7 @@
|
|||
"tts_browser": "浏览器自带(免费)",
|
||||
"tts_close": "关闭",
|
||||
"type.All": "全部",
|
||||
"type.Chat_Agent": "对话 Agent",
|
||||
"type.Create http plugin tip": "通过 OpenAPI Schema 批量创建工具(兼容GPTs)、通过curl或手动创建工具",
|
||||
"type.Create http toolset tip": "通过 OpenAPI Schema 批量创建工具(兼容GPTs)",
|
||||
"type.Create mcp tools tip": "通过输入 MCP 地址,自动解析并批量创建可调用的 MCP 工具",
|
||||
|
|
@ -459,8 +479,18 @@
|
|||
"type.error.Workflow data is empty": "没有获取到工作流数据",
|
||||
"type.error.workflowresponseempty": "响应内容为空",
|
||||
"type.hidden": "隐藏应用",
|
||||
"type_http_tool_set_intro": "批量导入 API 工具",
|
||||
"type_mcp_intro": "连接 MCP 服务",
|
||||
"type_not_recognized": "未识别到应用类型",
|
||||
"type_plugin_description": "一键输出指定结果。",
|
||||
"type_plugin_intro": "常用于封装工作流",
|
||||
"type_simple_description": "最基础的对话应用,无需复杂配置,快速创建和使用。",
|
||||
"type_simple_intro": "快速创建对话 Agent",
|
||||
"type_workflow_description": "支持记忆的复杂多轮对话工作流。",
|
||||
"type_workflow_intro": "拖拽编排与多轮对话",
|
||||
"un_auth": "无权限",
|
||||
"unnamed_app": "未命名",
|
||||
"upgrade": "去升级",
|
||||
"upload_file_exists_filtered": "已自动过滤重复文件",
|
||||
"upload_file_extension_type_canSelectAudio": "音频",
|
||||
"upload_file_extension_type_canSelectCustomFileExtension": "自定义文件扩展类型",
|
||||
|
|
@ -473,6 +503,7 @@
|
|||
"upload_file_max_amount_tip": "单轮对话中最大上传文件数量",
|
||||
"upload_method": "上传方式",
|
||||
"url_upload": "文件链接",
|
||||
"used_points": "积分用量:",
|
||||
"variable.internal_type_desc": "仅在工作流内部使用,不会出现在对话框中",
|
||||
"variable.select type_desc": "会在站内对话和运行预览中显示输入框,在分享链接中不会显示此变量",
|
||||
"variable.textarea_type_desc": "允许用户最多输入4000字的对话框。",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
"LLM_model_response_empty": "模型流响应为空,请检查模型流输出是否正常",
|
||||
"ai_reasoning": "思考过程",
|
||||
"back_to_text": "返回输入",
|
||||
"balance_not_enough_pause": "由于 AI 积分不足,暂停运行工作流",
|
||||
"chat.quote.No Data": "找不到该文件",
|
||||
"chat.quote.deleted": "该数据已被删除~",
|
||||
"chat.waiting_for_response": "请等待对话完成",
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
"chat_input_guide_lexicon_is_empty": "还没有配置词库",
|
||||
"chat_test_app": "调试-{{name}}",
|
||||
"citations": "{{num}}条引用",
|
||||
"clear_input_value": "清空输入",
|
||||
"click_contextual_preview": "点击查看上下文预览",
|
||||
"click_to_add_url": "点击添加链接",
|
||||
"completion_finish_close": "连接断开",
|
||||
|
|
@ -24,10 +26,12 @@
|
|||
"config_input_guide": "配置输入引导",
|
||||
"config_input_guide_lexicon": "配置词库",
|
||||
"config_input_guide_lexicon_title": "配置词库",
|
||||
"confirm_clear_input_value": "确认清空表单内容?将会恢复默认值!",
|
||||
"confirm_to_clear_share_chat_history": "确认清空所有聊天记录?",
|
||||
"content_empty": "内容为空",
|
||||
"contextual": "{{num}}条上下文",
|
||||
"contextual_preview": "上下文预览 {{num}} 条",
|
||||
"continue_run": "继续运行",
|
||||
"core.chat.moveCancel": "上滑取消",
|
||||
"core.chat.shortSpeak": "说话时间太短",
|
||||
"csv_input_lexicon_tip": "仅支持 CSV 批量导入,点击下载模板",
|
||||
|
|
@ -164,6 +168,7 @@
|
|||
"source_cronJob": "定时执行",
|
||||
"start_chat": "开始对话",
|
||||
"stream_output": "流输出",
|
||||
"task_has_continued": "任务已继续运行",
|
||||
"unsupported_file_type": "不支持的文件类型",
|
||||
"upload": "上传",
|
||||
"variable_invisable_in_share": "外部变量在免登录链接中不可见",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"Confirm": "确认",
|
||||
"Continue_Adding": "继续添加",
|
||||
"Copy": "复制",
|
||||
"Create": "创建",
|
||||
"Creating": "创建中",
|
||||
"Delete": "删除",
|
||||
"Detail": "详情",
|
||||
|
|
@ -98,8 +99,10 @@
|
|||
"add_success": "添加成功",
|
||||
"all_quotes": "全部引用",
|
||||
"all_result": "完整结果",
|
||||
"app_evaluation": "应用评测(Beta)",
|
||||
"app_evaluation": "Agent 评测(Beta)",
|
||||
"app_icon_and_name": "图标 & 名称",
|
||||
"app_not_version": " 该应用未发布过,请先发布应用",
|
||||
"app_type": "应用类型",
|
||||
"auth_config": "鉴权配置",
|
||||
"auth_type": "鉴权类型",
|
||||
"auth_type.Custom": "自定义",
|
||||
|
|
@ -671,6 +674,7 @@
|
|||
"core.module.template.ai_chat_intro": "AI 大模型对话",
|
||||
"core.module.template.all_team_app": "全部",
|
||||
"core.module.template.config_params": "可以配置应用的系统参数",
|
||||
"core.module.template.empty_agent": "空白 Agent",
|
||||
"core.module.template.empty_plugin": "空白插件",
|
||||
"core.module.template.empty_workflow": "空白工作流",
|
||||
"core.module.template.self_input": "插件输入",
|
||||
|
|
@ -756,6 +760,7 @@
|
|||
"core.workflow.tool.Select Tool": "选择工具",
|
||||
"core.workflow.variable": "变量",
|
||||
"create": "去创建",
|
||||
"create_app": "创建应用",
|
||||
"create_failed": "创建失败",
|
||||
"create_success": "创建成功",
|
||||
"create_time": "创建时间",
|
||||
|
|
@ -921,12 +926,12 @@
|
|||
"name": "名称",
|
||||
"name_is_empty": "名称不能为空",
|
||||
"navbar.Account": "账号",
|
||||
"navbar.Chat": "聊天",
|
||||
"navbar.Chat": "门户",
|
||||
"navbar.Config": "管理员",
|
||||
"navbar.Datasets": "知识库",
|
||||
"navbar.Studio": "工作台",
|
||||
"navbar.Toolkit": "工具箱",
|
||||
"navbar.Tools": "工具",
|
||||
"navbar.Tools": "我的工具",
|
||||
"navbar.plugin": "插件库",
|
||||
"new_create": "新建",
|
||||
"next_step": "下一步",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
"bill.valid_time": "生效时间",
|
||||
"bill.you_can_convert": "您可兑换",
|
||||
"bill.yuan": "元",
|
||||
"common.current_package": "当前套餐",
|
||||
"current_package": "当前套餐:",
|
||||
"delete.admin_failed": "删除管理员失败",
|
||||
"delete.admin_success": "删除管理员成功",
|
||||
"delete.failed": "删除失败",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"custom_model": "自訂模型",
|
||||
"default_model": "預設模型",
|
||||
"default_model_config": "預設模型設定",
|
||||
"language": "語言與時區",
|
||||
"logout": "登出",
|
||||
"model.active": "啟用",
|
||||
"model.alias": "別名",
|
||||
|
|
|
|||
|
|
@ -51,18 +51,21 @@
|
|||
"app.version_past": "已發布過",
|
||||
"app.version_publish_tips": "此版本將儲存至團隊雲端,同步給整個團隊,同時更新所有發布通道的應用程式版本",
|
||||
"app_detail": "應用程式詳細資訊",
|
||||
"app_name_placeholder": "請輸入應用名稱",
|
||||
"apply_code": "應用",
|
||||
"apply_code_failed": "應用代碼失敗",
|
||||
"auto_execute": "自動執行",
|
||||
"auto_execute_default_prompt_placeholder": "自動執行時,傳送的預設問題",
|
||||
"auto_execute_tip": "開啟後,使用者進入對話式介面將自動觸發工作流程。\n執行順序:1、對話開場白;2、全域變數;3、自動執行。",
|
||||
"auto_save": "自動儲存",
|
||||
"change_app_type": "更改應用程式類型",
|
||||
"chat_debug": "聊天預覽",
|
||||
"chat_logs": "對話紀錄",
|
||||
"chat_logs_tips": "紀錄會記錄此應用程式的線上、分享和 API(需填寫 chatId)對話紀錄",
|
||||
"click_to_config": "去配置",
|
||||
"code_applied_successfully": "代碼應用成功",
|
||||
"code_function_describe": "描述你的代碼功能,輸入“/”可選擇變量",
|
||||
"collapse_tool_create": "收起",
|
||||
"config_ai_model_params": "點選設定 AI 模型相關屬性",
|
||||
"config_file_upload": "點選設定檔案上傳規則",
|
||||
"config_question_guide": "設定猜你想問",
|
||||
|
|
@ -83,11 +86,14 @@
|
|||
"create_empty_app": "建立空白應用程式",
|
||||
"create_empty_plugin": "建立空白外掛",
|
||||
"create_empty_workflow": "建立空白工作流程",
|
||||
"create_from_template": "從模板新建",
|
||||
"create_http_toolset": "創建 HTTP 工具集",
|
||||
"create_your_first_agent": "創建你的第一個 Agent",
|
||||
"cron.every_day": "每天執行",
|
||||
"cron.every_month": "每月執行",
|
||||
"cron.every_week": "每週執行",
|
||||
"cron.interval": "間隔執行",
|
||||
"current_package": "當前套餐:",
|
||||
"custom_plugin": "自訂外掛",
|
||||
"custom_plugin_associated_plugin_label": "關聯外掛",
|
||||
"custom_plugin_associated_plugin_placeholder": "輸入外掛名稱或 appId 尋找外掛",
|
||||
|
|
@ -130,6 +136,7 @@
|
|||
"edit_info": "編輯資訊",
|
||||
"empty_tool_tips": "請在左側添加工具",
|
||||
"execute_time": "執行時間",
|
||||
"expand_tool_create": "展開 MCP、Http 創建",
|
||||
"export_config_successful": "已複製設定,自動過濾部分敏感資訊,請注意檢查是否仍有敏感資料",
|
||||
"export_configs": "匯出設定",
|
||||
"fastgpt_marketplace": "FastGPT 插件市場",
|
||||
|
|
@ -142,6 +149,8 @@
|
|||
"find_more_tools": "探索更多",
|
||||
"go_to_chat": "前往對話",
|
||||
"go_to_run": "前往執行",
|
||||
"has_no_create_per": "當前目錄您無新建權限",
|
||||
"hide_templates": "隱藏模板",
|
||||
"http_toolset_add_tips": "點擊添加按鈕來添加工具",
|
||||
"http_toolset_config_tips": "點擊開始配置來添加工具",
|
||||
"image": "圖片",
|
||||
|
|
@ -259,6 +268,7 @@
|
|||
"plugin_cost_by_token": "根據 token 消耗計費",
|
||||
"plugin_cost_folder_tip": "該工具集包含下屬工具,調用積分依據實際調用工具決定",
|
||||
"plugin_cost_per_times": "{{cost}} 積分/次",
|
||||
"plugin_db": "資源庫",
|
||||
"plugin_dispatch": "外掛呼叫",
|
||||
"plugin_dispatch_tip": "賦予模型取得外部資料的能力,具體呼叫哪些外掛,將由模型自主決定,所有外掛都將以非串流模式執行。\n若選擇了外掛,知識庫呼叫將自動作為一個特殊的外掛。",
|
||||
"plugin_offline_tips": "您的系統無法直接訪問插件市場數據,\n請手動複製網址並前往,以獲得更多插件",
|
||||
|
|
@ -274,16 +284,22 @@
|
|||
"publish_success": "發布成功",
|
||||
"question_guide_tip": "對話結束後,會為你產生 3 個引導性問題。",
|
||||
"reasoning_response": "輸出思考",
|
||||
"recharge": "去充值",
|
||||
"reference_variable": "引用變量",
|
||||
"refresh_templates": "換一批",
|
||||
"remaining_points": "剩餘積分:",
|
||||
"request_headers": "請求頭",
|
||||
"response_format": "回覆格式",
|
||||
"save_team_app_log_keys": "保存為團隊配置",
|
||||
"saved_success": "儲存成功!\n如需在外部使用該版本,請點選“儲存並發布”",
|
||||
"search_agent": "搜索 Agent",
|
||||
"search_app": "搜尋應用程式",
|
||||
"search_tool": "搜索工具",
|
||||
"secret_get_course": "教程",
|
||||
"select_app_type": "選擇應用程式類型",
|
||||
"setting_app": "應用程式設定",
|
||||
"setting_plugin": "外掛設定",
|
||||
"show_templates": "顯示模板",
|
||||
"show_top_p_tip": "用溫度取樣的替代方法,稱為 Nucleus 取樣,該模型考慮了具有 TOP_P 機率質量質量的令牌的結果。\n因此,0.1 表示僅考慮包含最高機率質量的令牌。\n預設為 1。",
|
||||
"simple_tool_tips": "該外掛含有特殊輸入,暫不支援被簡易應用呼叫",
|
||||
"source_updateTime": "更新時間",
|
||||
|
|
@ -326,6 +342,9 @@
|
|||
"time_type": "時間類型",
|
||||
"time_zone": "時區",
|
||||
"too_to_active": "去激活",
|
||||
"toolType_http": "HTTP 工具",
|
||||
"toolType_mcp": "MCP 工具",
|
||||
"toolType_workflow": "工作流工具",
|
||||
"tool_active_manual_config_desc": "臨時密鑰保存在本應用中,僅供該應用使用",
|
||||
"tool_active_system_config_desc": "使用系統已配置好的密鑰",
|
||||
"tool_active_system_config_price_desc": "需額外支付密鑰價格( {{price}} 積分/次)",
|
||||
|
|
@ -339,7 +358,6 @@
|
|||
"tool_soon_offset_tips": "該工具將在後續下線,為了您的業務穩定,請盡快替換",
|
||||
"tool_tip": "作為工具執行時,該字段是否作為工具響應結果",
|
||||
"tool_type_tools": "工具",
|
||||
"plugin_db": "資源庫",
|
||||
"toolkit_activation_label": "密鑰激活",
|
||||
"toolkit_activation_not_required": "免激活",
|
||||
"toolkit_activation_required": "需要激活",
|
||||
|
|
@ -440,8 +458,18 @@
|
|||
"type.error.Workflow data is empty": "沒有獲取到工作流數據",
|
||||
"type.error.workflowresponseempty": "響應內容為空",
|
||||
"type.hidden": "隱藏應用",
|
||||
"type_http_tool_set_intro": "批量導入 API 工具",
|
||||
"type_mcp_intro": "連接 MCP 服務",
|
||||
"type_not_recognized": "未識別到應用程式類型",
|
||||
"type_plugin_description": "一鍵輸出指定結果。",
|
||||
"type_plugin_intro": "常用於封裝工作流",
|
||||
"type_simple_description": "最基礎的對話應用,無需複雜配置,快速創建和使用。",
|
||||
"type_simple_intro": "快速創建對話 Agent",
|
||||
"type_workflow_description": "支持記憶的複雜多輪對話工作流。",
|
||||
"type_workflow_intro": "拖拽編排與多輪對話",
|
||||
"un_auth": "無權限",
|
||||
"unnamed_app": "未命名",
|
||||
"upgrade": "去升級",
|
||||
"upload_file_exists_filtered": "已自動過濾重複檔案",
|
||||
"upload_file_extension_type_canSelectAudio": "音頻",
|
||||
"upload_file_extension_type_canSelectCustomFileExtension": "自定義文件擴展類型",
|
||||
|
|
@ -454,6 +482,7 @@
|
|||
"upload_file_max_amount_tip": "單輪對話中最大上傳檔案數量",
|
||||
"upload_method": "上傳方式",
|
||||
"url_upload": "文件鏈接",
|
||||
"used_points": "積分用量:",
|
||||
"variable.internal_type_desc": "僅在工作流內部使用,不會出現在對話框中",
|
||||
"variable.select type_desc": "會在站內對話和運行預覽中顯示輸入框,在分享鏈接中不會顯示此變量",
|
||||
"variable.textarea_type_desc": "允許使用者最多輸入 4000 字的對話框。",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
"LLM_model_response_empty": "模型流程回應為空,請檢查模型流程輸出是否正常",
|
||||
"ai_reasoning": "思考過程",
|
||||
"back_to_text": "返回輸入",
|
||||
"balance_not_enough_pause": "由於 AI 積分不足,暫停運行工作流",
|
||||
"chat.quote.No Data": "找不到該文件",
|
||||
"chat.quote.deleted": "該資料已被刪除~",
|
||||
"chat.waiting_for_response": "請等待對話完成",
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
"chat_input_guide_lexicon_is_empty": "尚未設定詞彙庫",
|
||||
"chat_test_app": "除錯-{{name}}",
|
||||
"citations": "{{num}} 筆引用",
|
||||
"clear_input_value": "清空輸入",
|
||||
"click_contextual_preview": "點選檢視上下文預覽",
|
||||
"click_to_add_url": "點擊添加鏈接",
|
||||
"completion_finish_close": "連接斷開",
|
||||
|
|
@ -24,10 +26,12 @@
|
|||
"config_input_guide": "設定輸入導引",
|
||||
"config_input_guide_lexicon": "設定詞彙庫",
|
||||
"config_input_guide_lexicon_title": "設定詞彙庫",
|
||||
"confirm_clear_input_value": "確認清空表單內容?\n將會恢復默認值!",
|
||||
"confirm_to_clear_share_chat_history": "確認清空所有聊天記錄?",
|
||||
"content_empty": "無內容",
|
||||
"contextual": "{{num}} 筆上下文",
|
||||
"contextual_preview": "上下文預覽 {{num}} 筆",
|
||||
"continue_run": "繼續運行",
|
||||
"core.chat.moveCancel": "上滑取消",
|
||||
"core.chat.shortSpeak": "說話時間太短",
|
||||
"csv_input_lexicon_tip": "僅支援 CSV 批次匯入,點選下載範本",
|
||||
|
|
@ -161,6 +165,7 @@
|
|||
"source_cronJob": "定時執行",
|
||||
"start_chat": "開始對話",
|
||||
"stream_output": "串流輸出",
|
||||
"task_has_continued": "任務已繼續運行",
|
||||
"unsupported_file_type": "不支援的檔案類型",
|
||||
"upload": "上傳",
|
||||
"variable_invisable_in_share": "外部變量在免登錄鏈接中不可見",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"Confirm": "確認",
|
||||
"Continue_Adding": "繼續新增",
|
||||
"Copy": "複製",
|
||||
"Create": "創建",
|
||||
"Creating": "建立中",
|
||||
"Delete": "刪除",
|
||||
"Detail": "詳細資料",
|
||||
|
|
@ -99,7 +100,9 @@
|
|||
"all_quotes": "全部引用",
|
||||
"all_result": "完整結果",
|
||||
"app_evaluation": "應用評測(Beta)",
|
||||
"app_icon_and_name": "圖示",
|
||||
"app_not_version": "該應用未發布過,請先發布應用",
|
||||
"app_type": "應用類型",
|
||||
"auth_config": "鑑權配置",
|
||||
"auth_type": "鑑權類型",
|
||||
"auth_type.Custom": "自定義",
|
||||
|
|
@ -753,6 +756,7 @@
|
|||
"core.workflow.tool.Select Tool": "選擇工具",
|
||||
"core.workflow.variable": "變數",
|
||||
"create": "建立",
|
||||
"create_app": "創建應用",
|
||||
"create_failed": "建立失敗",
|
||||
"create_success": "建立成功",
|
||||
"create_time": "建立時間",
|
||||
|
|
@ -918,11 +922,11 @@
|
|||
"name": "名稱",
|
||||
"name_is_empty": "名稱不能為空",
|
||||
"navbar.Account": "帳戶",
|
||||
"navbar.Chat": "對話",
|
||||
"navbar.Chat": "門戶",
|
||||
"navbar.Datasets": "知識庫",
|
||||
"navbar.Studio": "工作區",
|
||||
"navbar.Toolkit": "工具箱",
|
||||
"navbar.Tools": "工具",
|
||||
"navbar.Tools": "我的工具",
|
||||
"navbar.plugin": "插件庫",
|
||||
"new_create": "建立新項目",
|
||||
"next_step": "下一步",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"bill.valid_time": "生效時間",
|
||||
"bill.you_can_convert": "您可兌換",
|
||||
"bill.yuan": "元",
|
||||
"current_package": "當前套餐:",
|
||||
"delete.admin_failed": "刪除管理員失敗",
|
||||
"delete.admin_success": "刪除管理員成功",
|
||||
"delete.failed": "刪除失敗",
|
||||
|
|
@ -87,6 +88,7 @@
|
|||
"team.add_writer": "新增可寫入成員",
|
||||
"team.avatar_and_name": "頭像與名稱",
|
||||
"team.belong_to_group": "所屬成員群組",
|
||||
"team.collaborator.added": "已新增",
|
||||
"team.group.avatar": "群組頭像",
|
||||
"team.group.create": "建立群組",
|
||||
"team.group.create_failed": "建立群組失敗",
|
||||
|
|
@ -110,6 +112,5 @@
|
|||
"team.manage_collaborators": "管理協作者",
|
||||
"team.no_collaborators": "目前沒有協作者",
|
||||
"team.org.org": "組織",
|
||||
"team.write_role_member": "可寫入權限",
|
||||
"team.collaborator.added": "已新增"
|
||||
"team.write_role_member": "可寫入權限"
|
||||
}
|
||||
|
|
|
|||
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 199 KiB |
|
|
@ -0,0 +1,56 @@
|
|||
<svg width="696" height="680" viewBox="0 0 696 680" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_27480_97775)">
|
||||
<rect width="696" height="680" rx="12" fill="white"/>
|
||||
<g opacity="0.8" filter="url(#filter0_n_27480_97775)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M215.96 371.393C215.96 413.662 248.621 448.303 290.082 451.456V451.599H292.411C293.685 451.659 294.967 451.69 296.257 451.69C297.546 451.69 298.828 451.659 300.103 451.599H405.374C406.573 451.659 407.779 451.69 408.992 451.69C448.242 451.69 480.06 419.871 480.06 380.621C480.06 351.831 462.941 327.04 438.327 315.871C429.701 281.613 399.401 256.31 363.347 256.31C336.709 256.31 313.212 270.122 299.277 291.152C298.275 291.115 297.268 291.096 296.257 291.096C251.91 291.096 215.96 327.046 215.96 371.393ZM254.504 394.43C255.541 395.467 257.01 395.985 258.912 395.985C260.9 395.985 262.391 395.467 263.385 394.43C264.378 393.349 264.875 391.837 264.875 389.892V377.121H283.739V389.892C283.739 391.837 284.236 393.349 285.23 394.43C286.268 395.467 287.759 395.985 289.703 395.985C291.605 395.985 293.053 395.467 294.047 394.43C295.084 393.349 295.602 391.837 295.602 389.892V355.211C295.602 353.223 295.084 351.71 294.047 350.673C293.053 349.636 291.605 349.117 289.703 349.117C287.759 349.117 286.268 349.636 285.23 350.673C284.236 351.71 283.739 353.223 283.739 355.211V367.333H264.875V355.211C264.875 353.223 264.357 351.71 263.32 350.673C262.326 349.636 260.856 349.117 258.912 349.117C257.01 349.117 255.541 349.636 254.504 350.673C253.466 351.71 252.948 353.223 252.948 355.211V389.892C252.948 391.837 253.466 393.349 254.504 394.43ZM321.411 394.43C322.448 395.467 323.918 395.985 325.819 395.985C327.807 395.985 329.298 395.467 330.292 394.43C331.286 393.349 331.783 391.858 331.783 389.957V359.424H341.961C343.56 359.424 344.77 359.014 345.591 358.193C346.455 357.328 346.887 356.118 346.887 354.562C346.887 352.963 346.455 351.753 345.591 350.932C344.77 350.111 343.56 349.701 341.961 349.701H309.678C308.079 349.701 306.847 350.111 305.983 350.932C305.162 351.753 304.751 352.963 304.751 354.562C304.751 356.118 305.162 357.328 305.983 358.193C306.847 359.014 308.079 359.424 309.678 359.424H319.855V389.957C319.855 391.858 320.374 393.349 321.411 394.43ZM373.61 395.985C371.708 395.985 370.239 395.467 369.202 394.43C368.164 393.349 367.646 391.858 367.646 389.957V359.424H357.468C355.869 359.424 354.638 359.014 353.773 358.193C352.952 357.328 352.542 356.118 352.542 354.562C352.542 352.963 352.952 351.753 353.773 350.932C354.638 350.111 355.869 349.701 357.468 349.701H389.751C391.35 349.701 392.56 350.111 393.381 350.932C394.245 351.753 394.678 352.963 394.678 354.562C394.678 356.118 394.245 357.328 393.381 358.193C392.56 359.014 391.35 359.424 389.751 359.424H379.574V389.957C379.574 391.858 379.077 393.349 378.083 394.43C377.089 395.467 375.598 395.985 373.61 395.985ZM405.345 394.43C406.382 395.467 407.851 395.985 409.753 395.985C411.741 395.985 413.232 395.467 414.226 394.43C415.22 393.349 415.717 391.858 415.717 389.957V379.65H425.765C430.951 379.65 434.948 378.331 437.757 375.695C440.609 373.016 442.036 369.342 442.036 364.675C442.036 360.008 440.609 356.356 437.757 353.72C434.948 351.04 430.951 349.701 425.765 349.701H409.818C407.916 349.701 406.425 350.219 405.345 351.256C404.308 352.294 403.789 353.785 403.789 355.729V389.957C403.789 391.858 404.308 393.349 405.345 394.43ZM423.69 370.509H415.717V358.841H423.69C425.937 358.841 427.666 359.316 428.876 360.267C430.086 361.218 430.691 362.687 430.691 364.675C430.691 366.62 430.086 368.089 428.876 369.083C427.666 370.034 425.937 370.509 423.69 370.509Z" fill="url(#paint0_linear_27480_97775)"/>
|
||||
</g>
|
||||
<g opacity="0.04" filter="url(#filter1_n_27480_97775)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M287.985 552.779C287.985 616.642 337.331 668.979 399.974 673.743V673.96H403.492C405.418 674.051 407.355 674.096 409.303 674.096C411.251 674.096 413.188 674.051 415.114 673.96H574.166C575.976 674.051 577.799 674.096 579.632 674.096C638.933 674.096 687.007 626.023 687.007 566.721C687.007 523.224 661.142 485.767 623.953 468.892C610.921 417.133 565.141 378.903 510.667 378.903C470.421 378.903 434.921 399.771 413.866 431.545C412.352 431.489 410.831 431.461 409.303 431.461C342.301 431.461 287.985 485.777 287.985 552.779ZM346.22 587.584C347.787 589.151 350.007 589.935 352.88 589.935C355.883 589.935 358.136 589.151 359.638 587.584C361.139 585.952 361.89 583.666 361.89 580.728V561.434H390.391V580.728C390.391 583.666 391.142 585.952 392.644 587.584C394.211 589.151 396.464 589.935 399.402 589.935C402.275 589.935 404.462 589.151 405.964 587.584C407.531 585.952 408.315 583.666 408.315 580.728V528.329C408.315 525.326 407.531 523.04 405.964 521.473C404.462 519.906 402.275 519.123 399.402 519.123C396.464 519.123 394.211 519.906 392.644 521.473C391.142 523.04 390.391 525.326 390.391 528.329V546.644H361.89V528.329C361.89 525.326 361.107 523.04 359.54 521.473C358.038 519.906 355.818 519.123 352.88 519.123C350.007 519.123 347.787 519.906 346.22 521.473C344.653 523.04 343.869 525.326 343.869 528.329V580.728C343.869 583.666 344.653 585.952 346.22 587.584ZM447.308 587.584C448.875 589.151 451.095 589.935 453.968 589.935C456.972 589.935 459.225 589.151 460.726 587.584C462.228 585.952 462.979 583.699 462.979 580.826V534.695H478.356C480.772 534.695 482.6 534.075 483.841 532.835C485.146 531.529 485.799 529.7 485.799 527.35C485.799 524.934 485.146 523.106 483.841 521.865C482.6 520.625 480.772 520.004 478.356 520.004H429.581C427.165 520.004 425.304 520.625 423.998 521.865C422.758 523.106 422.137 524.934 422.137 527.35C422.137 529.7 422.758 531.529 423.998 532.835C425.304 534.075 427.165 534.695 429.581 534.695H444.958V580.826C444.958 583.699 445.741 585.952 447.308 587.584ZM526.173 589.935C523.301 589.935 521.081 589.151 519.513 587.584C517.946 585.952 517.163 583.699 517.163 580.826V534.695H501.786C499.37 534.695 497.509 534.075 496.203 532.835C494.963 531.529 494.342 529.7 494.342 527.35C494.342 524.934 494.963 523.106 496.203 521.865C497.509 520.625 499.37 520.004 501.786 520.004H550.561C552.977 520.004 554.805 520.625 556.046 521.865C557.352 523.106 558.004 524.934 558.004 527.35C558.004 529.7 557.352 531.529 556.046 532.835C554.805 534.075 552.977 534.695 550.561 534.695H535.184V580.826C535.184 583.699 534.433 585.952 532.931 587.584C531.43 589.151 529.177 589.935 526.173 589.935ZM574.121 587.584C575.688 589.151 577.908 589.935 580.781 589.935C583.785 589.935 586.037 589.151 587.539 587.584C589.041 585.952 589.792 583.699 589.792 580.826V565.253H604.973C612.808 565.253 618.848 563.262 623.092 559.279C627.401 555.231 629.556 549.681 629.556 542.629C629.556 535.577 627.401 530.06 623.092 526.077C618.848 522.028 612.808 520.004 604.973 520.004H580.879C578.006 520.004 575.754 520.788 574.121 522.355C572.554 523.922 571.771 526.175 571.771 529.113V580.826C571.771 583.699 572.554 585.952 574.121 587.584ZM601.839 551.443H589.792V533.814H601.839C605.234 533.814 607.846 534.532 609.674 535.969C611.502 537.405 612.416 539.625 612.416 542.629C612.416 545.567 611.502 547.787 609.674 549.289C607.846 550.725 605.234 551.443 601.839 551.443Z" fill="url(#paint1_linear_27480_97775)"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_n_27480_97775" x="210" y="216" width="276" height="276" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="0.62500005960464478 0.62500005960464478" stitchTiles="stitch" numOctaves="3" result="noise" seed="8299" />
|
||||
<feColorMatrix in="noise" type="luminanceToAlpha" result="alphaNoise" />
|
||||
<feComponentTransfer in="alphaNoise" result="coloredNoise1">
|
||||
<feFuncA type="discrete" tableValues="0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "/>
|
||||
</feComponentTransfer>
|
||||
<feComposite operator="in" in2="shape" in="coloredNoise1" result="noise1Clipped" />
|
||||
<feFlood flood-color="rgba(255, 87, 188, 0.25)" result="color1Flood" />
|
||||
<feComposite operator="in" in2="noise1Clipped" in="color1Flood" result="color1" />
|
||||
<feMerge result="effect1_noise_27480_97775">
|
||||
<feMergeNode in="shape" />
|
||||
<feMergeNode in="color1" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="filter1_n_27480_97775" x="279" y="318" width="417" height="417" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="0.71642696857452393 0.71642696857452393" stitchTiles="stitch" numOctaves="3" result="noise" seed="8299" />
|
||||
<feColorMatrix in="noise" type="luminanceToAlpha" result="alphaNoise" />
|
||||
<feComponentTransfer in="alphaNoise" result="coloredNoise1">
|
||||
<feFuncA type="discrete" tableValues="0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "/>
|
||||
</feComponentTransfer>
|
||||
<feComposite operator="in" in2="shape" in="coloredNoise1" result="noise1Clipped" />
|
||||
<feFlood flood-color="rgba(255, 87, 188, 0.25)" result="color1Flood" />
|
||||
<feComposite operator="in" in2="noise1Clipped" in="color1Flood" result="color1" />
|
||||
<feMerge result="effect1_noise_27480_97775">
|
||||
<feMergeNode in="shape" />
|
||||
<feMergeNode in="color1" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_27480_97775" x1="348.01" y1="256.31" x2="294.8" y2="446.194" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FBA8E9"/>
|
||||
<stop offset="1" stop-color="#FF718A"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_27480_97775" x1="487.496" y1="378.903" x2="407.102" y2="665.794" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FBA8E9"/>
|
||||
<stop offset="1" stop-color="#FF718A"/>
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_27480_97775">
|
||||
<rect width="696" height="680" rx="12" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 9.9 KiB |
|
|
@ -0,0 +1,55 @@
|
|||
<svg width="696" height="680" viewBox="0 0 696 680" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="696" height="680" rx="12" fill="white"/>
|
||||
<g opacity="0.6">
|
||||
<g filter="url(#filter0_n_27471_96779)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M387.655 270.364C376.937 259.925 359.559 259.925 348.841 270.364L245.332 371.171C241.76 374.651 235.967 374.651 232.394 371.171C228.821 367.692 228.821 362.05 232.394 358.57L335.902 257.763C353.766 240.365 382.73 240.365 400.594 257.763C411.175 268.068 415.489 282.165 413.536 295.563C427.292 293.66 441.767 297.861 452.349 308.166L452.354 308.171L452.887 308.692C470.75 326.09 470.751 354.298 452.887 371.696L359.274 462.868C358.084 464.028 358.083 465.908 359.274 467.067L378.496 485.789C382.069 489.269 382.069 494.911 378.496 498.39C374.923 501.87 369.13 501.87 365.557 498.39L346.336 479.669C337.999 471.549 337.999 458.386 346.336 450.267L439.949 359.095C450.667 348.656 450.668 331.732 439.949 321.293L439.944 321.288L439.411 320.768C428.692 310.33 411.313 310.329 400.594 320.768L323.502 395.849L323.455 395.895L322.424 396.898C318.852 400.378 313.058 400.378 309.486 396.898C305.913 393.419 305.913 387.777 309.485 384.297L387.655 308.167C398.374 297.728 398.374 280.803 387.655 270.364ZM374.718 295.566C378.29 292.086 378.29 286.445 374.718 282.965C371.145 279.485 365.352 279.485 361.779 282.965L285.226 357.52C267.362 374.919 267.362 403.126 285.226 420.525C303.09 437.922 332.054 437.922 349.919 420.525L426.471 345.969C430.044 342.49 430.044 336.848 426.471 333.368C422.898 329.889 417.106 329.889 413.533 333.368L336.981 407.924C326.262 418.362 308.883 418.362 298.165 407.925C287.446 397.485 287.446 380.56 298.165 370.121L374.718 295.566Z" fill="url(#paint0_linear_27471_96779)"/>
|
||||
</g>
|
||||
</g>
|
||||
<g opacity="0.02">
|
||||
<g filter="url(#filter1_n_27471_96779)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M531.414 331.539C515.22 315.767 488.964 315.767 472.77 331.539L316.383 483.846C310.984 489.104 302.232 489.104 296.834 483.846C291.436 478.588 291.436 470.065 296.834 464.807L453.221 312.501C480.211 286.214 523.972 286.214 550.962 312.5C566.949 328.07 573.467 349.37 570.516 369.611C591.3 366.736 613.17 373.084 629.157 388.653L629.165 388.661L629.97 389.447C656.959 415.734 656.961 458.353 629.97 484.639L488.534 622.388C486.735 624.14 486.734 626.98 488.533 628.732L517.576 657.018C522.973 662.276 522.973 670.8 517.575 676.057C512.177 681.314 503.425 681.314 498.027 676.057L468.985 647.771C456.39 635.504 456.39 615.616 468.985 603.349L610.423 465.6C626.617 449.829 626.618 424.258 610.423 408.486L610.415 408.479L609.609 407.693C593.414 391.923 567.157 391.921 550.962 407.693L434.487 521.13L434.415 521.2L432.858 522.716C427.46 527.974 418.708 527.974 413.31 522.716C407.912 517.458 407.912 508.935 413.309 503.677L531.414 388.654C547.609 372.883 547.609 347.31 531.414 331.539ZM511.867 369.616C517.264 364.358 517.264 355.835 511.867 350.577C506.469 345.32 497.717 345.32 492.318 350.577L376.657 463.221C349.666 489.507 349.667 532.125 376.656 558.413C403.647 584.698 447.408 584.698 474.398 558.413L590.06 445.769C595.457 440.511 595.457 431.988 590.06 426.73C584.662 421.473 575.91 421.474 570.512 426.73L454.851 539.375C438.656 555.145 412.4 555.145 396.205 539.376C380.01 523.602 380.011 498.031 396.205 482.259L511.867 369.616Z" fill="url(#paint1_linear_27471_96779)"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_n_27471_96779" x="229.714" y="244.714" width="236.57" height="256.286" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="1.1111111640930176 1.1111111640930176" stitchTiles="stitch" numOctaves="3" result="noise" seed="2688" />
|
||||
<feColorMatrix in="noise" type="luminanceToAlpha" result="alphaNoise" />
|
||||
<feComponentTransfer in="alphaNoise" result="coloredNoise1">
|
||||
<feFuncA type="discrete" tableValues="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "/>
|
||||
</feComponentTransfer>
|
||||
<feComposite operator="in" in2="shape" in="coloredNoise1" result="noise1Clipped" />
|
||||
<feFlood flood-color="rgba(0, 0, 0, 0.25)" result="color1Flood" />
|
||||
<feComposite operator="in" in2="noise1Clipped" in="color1Flood" result="color1" />
|
||||
<feMerge result="effect1_noise_27471_96779">
|
||||
<feMergeNode in="shape" />
|
||||
<feMergeNode in="color1" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="filter1_n_27471_96779" x="292.786" y="292.786" width="357.427" height="387.214" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="1.1111111640930176 1.1111111640930176" stitchTiles="stitch" numOctaves="3" result="noise" seed="2688" />
|
||||
<feColorMatrix in="noise" type="luminanceToAlpha" result="alphaNoise" />
|
||||
<feComponentTransfer in="alphaNoise" result="coloredNoise1">
|
||||
<feFuncA type="discrete" tableValues="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "/>
|
||||
</feComponentTransfer>
|
||||
<feComposite operator="in" in2="shape" in="coloredNoise1" result="noise1Clipped" />
|
||||
<feFlood flood-color="rgba(0, 0, 0, 0.25)" result="color1Flood" />
|
||||
<feComposite operator="in" in2="noise1Clipped" in="color1Flood" result="color1" />
|
||||
<feMerge result="effect1_noise_27471_96779">
|
||||
<feMergeNode in="shape" />
|
||||
<feMergeNode in="color1" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_27471_96779" x1="229.714" y1="501" x2="513.72" y2="335.727" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.201923" stop-color="#454D5D"/>
|
||||
<stop offset="1" stop-color="#BAC2CE"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_27471_96779" x1="292.786" y1="680" x2="721.881" y2="430.293" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.201923" stop-color="#454D5D"/>
|
||||
<stop offset="1" stop-color="#BAC2CE"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
|
@ -0,0 +1,78 @@
|
|||
<svg width="696" height="680" viewBox="0 0 696 680" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="696" height="680" rx="12" fill="white"/>
|
||||
<g opacity="0.6" clip-path="url(#clip0_28888_156915)">
|
||||
<g filter="url(#filter0_n_28888_156915)">
|
||||
<path d="M337.49 229.401C342.99 226.225 351.908 226.225 357.408 229.401L441.457 277.926C452.458 284.278 452.458 294.575 441.457 300.926L358.514 348.813C353.014 351.989 344.096 351.989 338.596 348.813L254.547 300.288C243.546 293.937 243.546 283.639 254.547 277.288L337.49 229.401Z" fill="url(#paint0_linear_28888_156915)"/>
|
||||
<path d="M239.392 329.387C239.392 320.495 245.634 316.891 253.335 321.337L331.028 366.193C335.428 368.733 338.995 374.912 338.995 379.993V462.129C338.995 471.021 332.752 474.625 325.052 470.179L247.359 425.323C242.959 422.782 239.392 416.604 239.392 411.523V329.387Z" fill="url(#paint1_linear_28888_156915)"/>
|
||||
<path d="M357.001 380.613C357.001 375.532 360.568 369.353 364.968 366.813L442.674 321.95C450.374 317.504 456.617 321.108 456.617 329.999V412.125C456.617 417.206 453.05 423.385 448.649 425.925L370.944 470.789C363.243 475.235 357.001 471.631 357.001 462.739V380.613Z" fill="url(#paint2_linear_28888_156915)"/>
|
||||
</g>
|
||||
</g>
|
||||
<g opacity="0.04">
|
||||
<g filter="url(#filter1_n_28888_156915)">
|
||||
<path d="M460.991 365.937C466.491 362.761 475.409 362.761 480.909 365.937L564.958 414.462C575.959 420.813 575.959 431.111 564.958 437.462L482.015 485.349C476.515 488.525 467.597 488.525 462.097 485.349L378.048 436.824C367.047 430.472 367.047 420.175 378.048 413.824L460.991 365.937Z" fill="url(#paint3_linear_28888_156915)"/>
|
||||
<path d="M362.893 465.923C362.893 457.031 369.135 453.427 376.836 457.873L454.529 502.729C458.929 505.269 462.496 511.448 462.496 516.529V598.665C462.496 607.556 456.253 611.16 448.553 606.715L370.86 561.858C366.46 559.318 362.893 553.14 362.893 548.058V465.923Z" fill="url(#paint4_linear_28888_156915)"/>
|
||||
<path d="M480.502 517.149C480.502 512.068 484.069 505.889 488.469 503.349L566.175 458.485C573.875 454.039 580.118 457.643 580.118 466.535V548.661C580.118 553.742 576.551 559.921 572.15 562.461L494.445 607.325C486.744 611.77 480.502 608.166 480.502 599.275V517.149Z" fill="url(#paint5_linear_28888_156915)"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_n_28888_156915" x="209.999" y="211.857" width="276" height="276" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="1.1111115217208862 1.1111115217208862" stitchTiles="stitch" numOctaves="3" result="noise" seed="2688" />
|
||||
<feColorMatrix in="noise" type="luminanceToAlpha" result="alphaNoise" />
|
||||
<feComponentTransfer in="alphaNoise" result="coloredNoise1">
|
||||
<feFuncA type="discrete" tableValues="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "/>
|
||||
</feComponentTransfer>
|
||||
<feComposite operator="in" in2="shape" in="coloredNoise1" result="noise1Clipped" />
|
||||
<feFlood flood-color="rgba(206, 188, 255, 0.25)" result="color1Flood" />
|
||||
<feComposite operator="in" in2="noise1Clipped" in="color1Flood" result="color1" />
|
||||
<feMerge result="effect1_noise_28888_156915">
|
||||
<feMergeNode in="shape" />
|
||||
<feMergeNode in="color1" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<filter id="filter1_n_28888_156915" x="333.5" y="348.393" width="276" height="276" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feTurbulence type="fractalNoise" baseFrequency="1.1111115217208862 1.1111115217208862" stitchTiles="stitch" numOctaves="3" result="noise" seed="2688" />
|
||||
<feColorMatrix in="noise" type="luminanceToAlpha" result="alphaNoise" />
|
||||
<feComponentTransfer in="alphaNoise" result="coloredNoise1">
|
||||
<feFuncA type="discrete" tableValues="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "/>
|
||||
</feComponentTransfer>
|
||||
<feComposite operator="in" in2="shape" in="coloredNoise1" result="noise1Clipped" />
|
||||
<feFlood flood-color="rgba(206, 188, 255, 0.25)" result="color1Flood" />
|
||||
<feComposite operator="in" in2="noise1Clipped" in="color1Flood" result="color1" />
|
||||
<feMerge result="effect1_noise_28888_156915">
|
||||
<feMergeNode in="shape" />
|
||||
<feMergeNode in="color1" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
<linearGradient id="paint0_linear_28888_156915" x1="348.004" y1="227.019" x2="254.793" y2="444.601" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#285FC4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_28888_156915" x1="348.004" y1="227.019" x2="254.793" y2="444.601" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#285FC4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_28888_156915" x1="348.004" y1="227.019" x2="254.793" y2="444.601" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#285FC4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_28888_156915" x1="471.505" y1="363.555" x2="378.294" y2="581.137" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#285FC4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_28888_156915" x1="471.505" y1="363.555" x2="378.294" y2="581.137" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#285FC4"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_28888_156915" x1="471.505" y1="363.555" x2="378.294" y2="581.137" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#285FC4"/>
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_28888_156915">
|
||||
<rect width="276" height="276" fill="white" transform="translate(210 202)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
|
@ -0,0 +1,52 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_29251_101416)">
|
||||
<g filter="url(#filter0_d_29251_101416)">
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="white"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint0_radial_29251_101416)" fill-opacity="0.5"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint1_radial_29251_101416)" fill-opacity="0.5"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint2_radial_29251_101416)" fill-opacity="0.5"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint3_radial_29251_101416)" fill-opacity="0.5"/>
|
||||
</g>
|
||||
<ellipse cx="17" cy="26" rx="2" ry="4" fill="url(#paint4_linear_29251_101416)"/>
|
||||
<ellipse cx="31" cy="26" rx="2" ry="4" fill="url(#paint5_linear_29251_101416)"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_29251_101416" x="-6.7" y="0" width="79.4" height="94.7" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset dx="3" dy="25"/>
|
||||
<feGaussianBlur stdDeviation="4.85"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0.243137 0 0 0 0 0.317647 0 0 0 0 0.694118 0 0 0 0.05 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_29251_101416"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_29251_101416" result="shape"/>
|
||||
</filter>
|
||||
<radialGradient id="paint0_radial_29251_101416" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(19.5 20.5) rotate(59.7436) scale(20.8387 48.9822)">
|
||||
<stop stop-color="#653AFF"/>
|
||||
<stop offset="1" stop-color="#653AFF" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint1_radial_29251_101416" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(40 42.5) rotate(-128.66) scale(16.0078 16.5318)">
|
||||
<stop stop-color="#84FFE2" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#84FFE2" stop-opacity="0.33"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint2_radial_29251_101416" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(48.5 24) rotate(126.209) scale(34.7023 20.8951)">
|
||||
<stop stop-color="#FF34FF"/>
|
||||
<stop offset="1" stop-color="#FF34FF" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint3_radial_29251_101416" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(24.5 34.5) rotate(49.0283) scale(25.1645 21.8308)">
|
||||
<stop stop-color="#40FFE2" stop-opacity="0.91"/>
|
||||
<stop offset="1" stop-color="#40FFE2" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<linearGradient id="paint4_linear_29251_101416" x1="17" y1="22" x2="17" y2="30" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1631FF"/>
|
||||
<stop offset="1" stop-color="#596F99"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_29251_101416" x1="31" y1="22" x2="31" y2="30" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1631FF"/>
|
||||
<stop offset="1" stop-color="#596F99"/>
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_29251_101416">
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0C46.5685 0 60 13.4315 60 30C60 46.5685 46.5685 60 30 60C13.4315 60 0 46.5685 0 30Z" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
|
|
@ -0,0 +1,32 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_29251_101629)">
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="white"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint0_radial_29251_101629)" fill-opacity="0.5"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint1_radial_29251_101629)" fill-opacity="0.5"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint2_radial_29251_101629)" fill-opacity="0.5"/>
|
||||
<path d="M0 30C0 13.4315 13.4315 0 30 0V0C46.5685 0 60 13.4315 60 30V30C60 46.5685 46.5685 60 30 60V60C13.4315 60 0 46.5685 0 30V30Z" fill="url(#paint3_radial_29251_101629)" fill-opacity="0.5"/>
|
||||
<path d="M16 25.5C16.6667 26.2546 18.4 27.3111 20 25.5" stroke="#1631FF" stroke-width="2" stroke-linecap="round"/>
|
||||
<path d="M30 25.5C30.6667 26.2546 32.4 27.3111 34 25.5" stroke="#1631FF" stroke-width="2" stroke-linecap="round"/>
|
||||
</g>
|
||||
<defs>
|
||||
<radialGradient id="paint0_radial_29251_101629" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(19.5 20.5) rotate(59.7436) scale(20.8387 48.9822)">
|
||||
<stop stop-color="#653AFF"/>
|
||||
<stop offset="1" stop-color="#653AFF" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint1_radial_29251_101629" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(40 42.5) rotate(-128.66) scale(16.0078 16.5318)">
|
||||
<stop stop-color="#84FFE2" stop-opacity="0"/>
|
||||
<stop offset="1" stop-color="#84FFE2" stop-opacity="0.33"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint2_radial_29251_101629" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(48.5 24) rotate(126.209) scale(34.7023 20.8951)">
|
||||
<stop stop-color="#FF34FF"/>
|
||||
<stop offset="1" stop-color="#FF34FF" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="paint3_radial_29251_101629" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(24.5 34.5) rotate(49.0283) scale(25.1645 21.8308)">
|
||||
<stop stop-color="#40FFE2" stop-opacity="0.91"/>
|
||||
<stop offset="1" stop-color="#40FFE2" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<clipPath id="clip0_29251_101629">
|
||||
<rect width="60" height="60" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -0,0 +1,205 @@
|
|||
import { Box, Flex, Spinner, Center } from '@chakra-ui/react';
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useToggle } from 'ahooks';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { StandardSubLevelEnum } from '@fastgpt/global/support/wallet/sub/constants';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { getWorkorderURL } from '@/web/common/workorder/api';
|
||||
|
||||
const BotShowRouter: { [key: string]: boolean } = {
|
||||
'/dashboard/agent': true,
|
||||
'/dashboard/tool': true,
|
||||
'/dashboard/systemTool': true,
|
||||
'/dashboard/templateMarket': true,
|
||||
'/dashboard/mcpServer': true,
|
||||
'/dashboard/evaluation': true,
|
||||
'/dataset/list': true,
|
||||
'/account/info': true
|
||||
};
|
||||
|
||||
const HelperBot = () => {
|
||||
const router = useRouter();
|
||||
const { i18n } = useTranslation();
|
||||
const [open, setOpen] = useToggle(true);
|
||||
const [showChat, setShowChat] = useToggle(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
const { feConfigs, subPlans } = useSystemStore();
|
||||
const { teamPlanStatus } = useUserStore();
|
||||
const isPlanUser = useMemo(() => {
|
||||
if (!teamPlanStatus) return false;
|
||||
if (teamPlanStatus.standard?.currentSubLevel !== StandardSubLevelEnum.free) return true;
|
||||
if (teamPlanStatus.datasetMaxSize !== subPlans?.standard?.free?.maxDatasetSize) return true;
|
||||
if (teamPlanStatus.totalPoints !== subPlans?.standard?.free?.totalPoints) return true;
|
||||
return false;
|
||||
}, [
|
||||
subPlans?.standard?.free?.maxDatasetSize,
|
||||
subPlans?.standard?.free?.totalPoints,
|
||||
teamPlanStatus
|
||||
]);
|
||||
|
||||
const showWorkorder = feConfigs?.show_workorder && isPlanUser;
|
||||
const botIframeUrl = feConfigs?.botIframeUrl;
|
||||
|
||||
useEffect(() => {
|
||||
if (showChat) {
|
||||
setIsLoading(true);
|
||||
}
|
||||
}, [showChat]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleMessage = async (event: MessageEvent) => {
|
||||
if (event.data?.type === 'workorderRequest') {
|
||||
try {
|
||||
const data = await getWorkorderURL();
|
||||
if (data?.redirectUrl) {
|
||||
window.open(data.redirectUrl);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to create workorder:', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('message', handleMessage);
|
||||
return () => window.removeEventListener('message', handleMessage);
|
||||
}, []);
|
||||
|
||||
if (!botIframeUrl || !BotShowRouter[router.pathname]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{showChat && open && (
|
||||
<Box
|
||||
position={'fixed'}
|
||||
right={3}
|
||||
bottom={'calc(10% + 80px)'}
|
||||
top={'50px'}
|
||||
w={'400px'}
|
||||
maxH={'790px'}
|
||||
bg={'white'}
|
||||
borderRadius={'lg'}
|
||||
boxShadow={'0px 4px 20px rgba(0, 0, 0, 0.15)'}
|
||||
zIndex={99}
|
||||
overflow={'hidden'}
|
||||
>
|
||||
{isLoading && (
|
||||
<Center
|
||||
position={'absolute'}
|
||||
top={0}
|
||||
left={0}
|
||||
right={0}
|
||||
bottom={0}
|
||||
bg={'white'}
|
||||
zIndex={2}
|
||||
>
|
||||
<Flex direction={'column'} alignItems={'center'} gap={3}>
|
||||
<Spinner size={'lg'} color={'primary.500'} thickness="3px" speed="0.8s" />
|
||||
</Flex>
|
||||
</Center>
|
||||
)}
|
||||
<Box
|
||||
position={'absolute'}
|
||||
right={2}
|
||||
top={2}
|
||||
p={1}
|
||||
rounded={'md'}
|
||||
zIndex={1}
|
||||
_hover={{
|
||||
cursor: 'pointer',
|
||||
bgColor: 'myGray.200'
|
||||
}}
|
||||
onClick={() => setShowChat.set(false)}
|
||||
>
|
||||
<MyIcon name="close" w={6} />
|
||||
</Box>
|
||||
{/* iframe */}
|
||||
<Box
|
||||
as="iframe"
|
||||
src={`${botIframeUrl}&showWorkorder=${showWorkorder ? '1' : '0'}`}
|
||||
w={'100%'}
|
||||
h={'100%'}
|
||||
border={'none'}
|
||||
onLoad={() => setIsLoading(false)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Flex
|
||||
position={'fixed'}
|
||||
right={3}
|
||||
bottom={'10%'}
|
||||
zIndex={100}
|
||||
transform={open ? 'none' : 'translateX(32px)'}
|
||||
transition={'transform 0.2s ease-in-out'}
|
||||
>
|
||||
{open && (
|
||||
<>
|
||||
<Box
|
||||
zIndex={10}
|
||||
position={'absolute'}
|
||||
right={-2}
|
||||
top={-2}
|
||||
w={4}
|
||||
h={4}
|
||||
borderRadius={'full'}
|
||||
_hover={{
|
||||
cursor: 'pointer',
|
||||
bgColor: 'myGray.200'
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setOpen.set(false);
|
||||
setShowChat.set(false);
|
||||
}}
|
||||
>
|
||||
<MyIcon name="close" />
|
||||
</Box>
|
||||
{!showChat && (
|
||||
<Box
|
||||
position={'absolute'}
|
||||
left={'-40px'}
|
||||
top={'-30px'}
|
||||
w={'80px'}
|
||||
h={'80px'}
|
||||
zIndex={-10}
|
||||
>
|
||||
{i18n.language === 'zh-CN' ? (
|
||||
<Box bgImage={getWebReqUrl('/imgs/botTextCN.svg')} w={'100%'} h={'100%'} />
|
||||
) : (
|
||||
<Box bgImage={getWebReqUrl('/imgs/botTextEn.svg')} w={'100%'} h={'100%'} />
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<Box
|
||||
bgImage={getWebReqUrl(open ? '/imgs/bot.svg' : '/imgs/botClosed.svg')}
|
||||
w={'60px'}
|
||||
h={'60px'}
|
||||
rounded={'full'}
|
||||
boxShadow={'3px 25px 9.7px 0 rgba(62, 81, 177, 0.05)'}
|
||||
_hover={{
|
||||
cursor: 'pointer'
|
||||
}}
|
||||
onClick={() => {
|
||||
if (open) {
|
||||
setShowChat.toggle();
|
||||
} else {
|
||||
setOpen.set(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default HelperBot;
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { getWorkorderURL } from '@/web/common/workorder/api';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { Box, Flex } from '@chakra-ui/react';
|
||||
import { StandardSubLevelEnum } from '@fastgpt/global/support/wallet/sub/constants';
|
||||
import Icon from '@fastgpt/web/components/common/Icon';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||
import { useToggle } from 'ahooks';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
const WorkOrderShowRouter: { [key: string]: boolean } = {
|
||||
'/dashboard/apps': true,
|
||||
'/dataset/list': true,
|
||||
'/plugin': true
|
||||
};
|
||||
|
||||
function WorkorderButton() {
|
||||
const router = useRouter();
|
||||
const [open, setOpen] = useToggle(true);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { feConfigs, subPlans } = useSystemStore();
|
||||
const { teamPlanStatus } = useUserStore();
|
||||
|
||||
const { isPc } = useSystem();
|
||||
|
||||
const { runAsync: onFeedback } = useRequest2(getWorkorderURL, {
|
||||
manual: true,
|
||||
onSuccess(data) {
|
||||
if (data) {
|
||||
window.open(data.redirectUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const showWorkorder = WorkOrderShowRouter[router.pathname];
|
||||
|
||||
const isPlanUser = useMemo(() => {
|
||||
if (!teamPlanStatus) return false;
|
||||
if (teamPlanStatus.standard?.currentSubLevel !== StandardSubLevelEnum.free) return true;
|
||||
if (teamPlanStatus.datasetMaxSize !== subPlans?.standard?.free?.maxDatasetSize) return true;
|
||||
if (teamPlanStatus.totalPoints !== subPlans?.standard?.free?.totalPoints) return true;
|
||||
return false;
|
||||
}, [
|
||||
subPlans?.standard?.free?.maxDatasetSize,
|
||||
subPlans?.standard?.free?.totalPoints,
|
||||
teamPlanStatus
|
||||
]);
|
||||
|
||||
return showWorkorder && feConfigs?.show_workorder && isPlanUser && isPc ? (
|
||||
<>
|
||||
{open ? (
|
||||
<Flex
|
||||
position="fixed"
|
||||
bottom="10%"
|
||||
right="0"
|
||||
height="56px"
|
||||
width="56px"
|
||||
zIndex={100}
|
||||
boxShadow="0px 12px 32px -4px #00175633"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
direction="column"
|
||||
borderTopLeftRadius="8px"
|
||||
borderBottomLeftRadius="8px"
|
||||
border={'1px'}
|
||||
borderColor={'#DFE6F2'}
|
||||
>
|
||||
<Box
|
||||
zIndex={10}
|
||||
width="1rem"
|
||||
height="1rem"
|
||||
position="absolute"
|
||||
left="-6px"
|
||||
top="-6px"
|
||||
borderRadius="full"
|
||||
background="white"
|
||||
border="1px"
|
||||
borderColor={'myGray.100'}
|
||||
bgColor="myGray.25"
|
||||
_hover={{
|
||||
cursor: 'pointer',
|
||||
bgColor: 'myGray.100'
|
||||
}}
|
||||
onClick={() => setOpen.set(false)}
|
||||
>
|
||||
<Icon name="close" />
|
||||
</Box>
|
||||
<Flex
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
direction="column"
|
||||
bgColor="myGray.25"
|
||||
_hover={{
|
||||
cursor: 'pointer',
|
||||
bgColor: 'myGray.100'
|
||||
}}
|
||||
width="100%"
|
||||
height="100%"
|
||||
borderTopLeftRadius="8px"
|
||||
borderBottomLeftRadius="8px"
|
||||
onClick={onFeedback}
|
||||
>
|
||||
<Icon name="feedback" width="24px" height="24px" />
|
||||
<Box fontSize="xs" fontWeight="500">
|
||||
{t('common:question_feedback')}
|
||||
</Box>
|
||||
</Flex>
|
||||
</Flex>
|
||||
) : (
|
||||
<Flex
|
||||
position="fixed"
|
||||
bottom="10%"
|
||||
right="0"
|
||||
height="44px"
|
||||
width="19px"
|
||||
bgColor="myGray.25"
|
||||
borderTopLeftRadius="8px"
|
||||
borderBottomLeftRadius="8px"
|
||||
border={'1px'}
|
||||
borderColor={'#DFE6F2'}
|
||||
zIndex={100}
|
||||
boxShadow="0px 12px 32px -4px #00175633"
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
direction="column"
|
||||
_hover={{
|
||||
cursor: 'pointer',
|
||||
bgColor: 'myGray.100'
|
||||
}}
|
||||
onClick={() => setOpen.set(true)}
|
||||
>
|
||||
<Icon name="core/chat/chevronLeft" width="16px" height="16px" />
|
||||
</Flex>
|
||||
)}
|
||||
</>
|
||||
) : null;
|
||||
}
|
||||
|
||||
export default WorkorderButton;
|
||||
|
|
@ -14,8 +14,8 @@ import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
|||
import { useDebounceEffect, useMount } from 'ahooks';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import WorkorderButton from './WorkorderButton';
|
||||
import { useCheckCoupon } from './hooks/checkCoupon';
|
||||
import HelperBot from './HelperBot';
|
||||
|
||||
const Navbar = dynamic(() => import('./navbar'));
|
||||
const NavbarPhone = dynamic(() => import('./navbarPhone'));
|
||||
|
|
@ -176,7 +176,7 @@ const Layout = ({ children }: { children: JSX.Element }) => {
|
|||
<ImportantInform informs={importantInforms} refetch={refetchUnRead} />
|
||||
)}
|
||||
<ResetExpiredPswModal />
|
||||
<WorkorderButton />
|
||||
<HelperBot />
|
||||
</>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import { useTranslation } from 'next-i18next';
|
|||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
import MyImage from '@fastgpt/web/components/common/Image/MyImage';
|
||||
import { LOGO_ICON } from '@fastgpt/global/common/system/constants';
|
||||
|
||||
export enum NavbarTypeEnum {
|
||||
normal = 'normal',
|
||||
|
|
@ -55,12 +57,14 @@ const Navbar = ({ unread }: { unread: number }) => {
|
|||
label: t('common:navbar.Studio'),
|
||||
icon: 'navbar/dashboardLight',
|
||||
activeIcon: 'navbar/dashboardFill',
|
||||
link: `/dashboard/apps`,
|
||||
link: `/dashboard/agent`,
|
||||
activeLink: [
|
||||
'/dashboard/apps',
|
||||
'/dashboard/agent',
|
||||
'/dashboard/create',
|
||||
'/app/detail',
|
||||
'/dashboard/tool',
|
||||
'/dashboard/systemTool',
|
||||
'/dashboard/templateMarket',
|
||||
'/dashboard/[pluginGroupId]',
|
||||
'/dashboard/mcpServer',
|
||||
'/dashboard/evaluation',
|
||||
'/dashboard/evaluation/create'
|
||||
|
|
@ -73,13 +77,6 @@ const Navbar = ({ unread }: { unread: number }) => {
|
|||
link: `/dataset/list`,
|
||||
activeLink: ['/dataset/list', '/dataset/detail']
|
||||
},
|
||||
{
|
||||
label: t('common:navbar.plugin'),
|
||||
icon: 'core/app/pluginLight',
|
||||
activeIcon: 'core/app/pluginFill',
|
||||
link: '/plugin/tool',
|
||||
activeLink: ['/plugin/tool']
|
||||
},
|
||||
{
|
||||
label: t('common:navbar.Account'),
|
||||
icon: 'navbar/userLight',
|
||||
|
|
@ -129,16 +126,8 @@ const Navbar = ({ unread }: { unread: number }) => {
|
|||
bg={isSecondNavbarPage ? 'myGray.50' : 'transparent'}
|
||||
>
|
||||
{/* logo */}
|
||||
<Box
|
||||
flex={'0 0 auto'}
|
||||
mb={3}
|
||||
border={'2px solid #fff'}
|
||||
borderRadius={'50%'}
|
||||
overflow={'hidden'}
|
||||
cursor={'pointer'}
|
||||
onClick={() => router.push('/account/info')}
|
||||
>
|
||||
<Avatar w={'2rem'} h={'2rem'} src={userInfo?.avatar} borderRadius={'50%'} />
|
||||
<Box flex={'0 0 auto'} mb={3}>
|
||||
<MyImage w={9} h={9} src={LOGO_ICON} />
|
||||
</Box>
|
||||
{/* 导航列表 */}
|
||||
<Box flex={1}>
|
||||
|
|
@ -254,6 +243,10 @@ const Navbar = ({ unread }: { unread: number }) => {
|
|||
</Link>
|
||||
</MyTooltip>
|
||||
)}
|
||||
|
||||
<Box flex={'0 0 auto'} mb={4} cursor={'pointer'} onClick={() => router.push('/account/info')}>
|
||||
<Avatar w={9} src={userInfo?.avatar} borderRadius={'50%'} />
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,12 +27,13 @@ const NavbarPhone = ({ unread }: { unread: number }) => {
|
|||
label: t('common:navbar.Studio'),
|
||||
icon: 'core/app/aiLight',
|
||||
activeIcon: 'core/app/aiFill',
|
||||
link: `/dashboard/apps`,
|
||||
link: `/dashboard/agent`,
|
||||
activeLink: [
|
||||
'/dashboard/apps',
|
||||
'/dashboard/agent',
|
||||
'/app/detail',
|
||||
'/dashboard/tool',
|
||||
'/dashboard/systemTool',
|
||||
'/dashboard/templateMarket',
|
||||
'/dashboard/[pluginGroupId]',
|
||||
'/dashboard/mcpServer',
|
||||
'/dashboard/evaluation',
|
||||
'/dashboard/evaluation/create'
|
||||
|
|
@ -47,13 +48,6 @@ const NavbarPhone = ({ unread }: { unread: number }) => {
|
|||
activeLink: ['/dataset/list', '/dataset/detail'],
|
||||
unread: 0
|
||||
},
|
||||
{
|
||||
label: t('common:navbar.plugin'),
|
||||
icon: 'core/app/pluginLight',
|
||||
activeIcon: 'core/app/pluginFill',
|
||||
link: '/plugin/tool',
|
||||
activeLink: ['/plugin/tool']
|
||||
},
|
||||
{
|
||||
label: t('common:navbar.Account'),
|
||||
icon: 'support/user/userLight',
|
||||
|
|
|
|||
|
|
@ -123,42 +123,45 @@ const Editor = React.memo(function Editor({
|
|||
}, []);
|
||||
|
||||
return (
|
||||
<Box h={'100%'} w={'100%'} position={'relative'}>
|
||||
<Textarea
|
||||
ref={textareaRef}
|
||||
maxW={'100%'}
|
||||
as={autoHeight ? ResizeTextarea : undefined}
|
||||
sx={
|
||||
!showResize
|
||||
? {
|
||||
'::-webkit-resizer': {
|
||||
display: 'none'
|
||||
<Box h={'100%'} w={'100%'}>
|
||||
<Box position={'relative'}>
|
||||
<Textarea
|
||||
ref={textareaRef}
|
||||
maxW={'100%'}
|
||||
as={autoHeight ? ResizeTextarea : undefined}
|
||||
resize={showResize ? 'vertical' : 'none'}
|
||||
sx={
|
||||
!showResize
|
||||
? {
|
||||
'::-webkit-resizer': {
|
||||
display: 'none !important'
|
||||
}
|
||||
}
|
||||
}
|
||||
: {}
|
||||
}
|
||||
{...props}
|
||||
maxH={`${maxH}px`}
|
||||
minH={`${minH}px`}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
{onOpenModal &&
|
||||
maxH &&
|
||||
textareaRef.current &&
|
||||
textareaRef.current.scrollHeight > Number(maxH) && (
|
||||
<Box
|
||||
zIndex={1}
|
||||
position={'absolute'}
|
||||
bottom={1}
|
||||
right={2}
|
||||
cursor={'pointer'}
|
||||
onClick={onOpenModal}
|
||||
>
|
||||
<MyTooltip label={t('common:ui.textarea.Magnifying')}>
|
||||
<MyIcon name={'common/fullScreenLight'} w={'14px'} color={'myGray.600'} />
|
||||
</MyTooltip>
|
||||
</Box>
|
||||
)}
|
||||
: {}
|
||||
}
|
||||
{...props}
|
||||
maxH={`${maxH}px`}
|
||||
minH={`${minH}px`}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
{onOpenModal &&
|
||||
maxH &&
|
||||
textareaRef.current &&
|
||||
textareaRef.current.scrollHeight > Number(maxH) && (
|
||||
<Box
|
||||
zIndex={1}
|
||||
position={'absolute'}
|
||||
bottom={1}
|
||||
right={2}
|
||||
cursor={'pointer'}
|
||||
onClick={onOpenModal}
|
||||
>
|
||||
<MyTooltip label={t('common:ui.textarea.Magnifying')}>
|
||||
<MyIcon name={'common/fullScreenLight'} w={'14px'} color={'myGray.600'} />
|
||||
</MyTooltip>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,13 +28,15 @@ const AuthValueDisplay = ({
|
|||
index = 0,
|
||||
onEdit,
|
||||
value,
|
||||
onChange
|
||||
onChange,
|
||||
bg
|
||||
}: {
|
||||
showInput: boolean;
|
||||
index?: number;
|
||||
onEdit: (index?: number) => void;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
bg: string;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
|
@ -43,7 +45,7 @@ const AuthValueDisplay = ({
|
|||
{showInput ? (
|
||||
<Input
|
||||
placeholder={'Value'}
|
||||
bg={'myGray.50'}
|
||||
bg={bg}
|
||||
h={8}
|
||||
maxLength={200}
|
||||
onFocus={() => onEdit(index)}
|
||||
|
|
@ -98,11 +100,13 @@ export const getSecretType = (config: HeaderSecretConfigType): HeaderSecretTypeE
|
|||
const HeaderAuthForm = ({
|
||||
headerSecretValue,
|
||||
onChange,
|
||||
fontWeight = 'medium'
|
||||
fontWeight = 'medium',
|
||||
bg = 'myGray.50'
|
||||
}: {
|
||||
headerSecretValue: HeaderSecretConfigType;
|
||||
onChange: (secret: HeaderSecretConfigType) => void;
|
||||
fontWeight?: string;
|
||||
bg?: string;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const headerSecretList = [
|
||||
|
|
@ -138,7 +142,7 @@ const HeaderAuthForm = ({
|
|||
{t('common:auth_type')}
|
||||
</Box>
|
||||
<MySelect
|
||||
bg={'myGray.50'}
|
||||
bg={bg}
|
||||
value={currentAuthType}
|
||||
onChange={(val) => {
|
||||
if (val === HeaderSecretTypeEnum.None) {
|
||||
|
|
@ -192,6 +196,7 @@ const HeaderAuthForm = ({
|
|||
});
|
||||
}
|
||||
}}
|
||||
bg={bg}
|
||||
/>
|
||||
) : (
|
||||
<Box>
|
||||
|
|
@ -201,7 +206,7 @@ const HeaderAuthForm = ({
|
|||
<Input
|
||||
w={1 / 3}
|
||||
h={8}
|
||||
bg="myGray.50"
|
||||
bg={bg}
|
||||
placeholder="key"
|
||||
maxLength={64}
|
||||
value={item.key}
|
||||
|
|
@ -230,6 +235,7 @@ const HeaderAuthForm = ({
|
|||
}}
|
||||
index={index}
|
||||
onEdit={setEditingIndex}
|
||||
bg={bg}
|
||||
/>
|
||||
</Box>
|
||||
{customHeaders.length > 1 && (
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import { LazyCollaboratorProvider } from '@/components/support/permission/Member
|
|||
|
||||
const MyModal = dynamic(() => import('@fastgpt/web/components/common/MyModal'));
|
||||
|
||||
const ModelTable = () => {
|
||||
const ModelTable = ({ permissionConfig = false }: { permissionConfig?: boolean }) => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { getModelProviders, getModelProvider } = useSystemStore();
|
||||
const { userInfo } = useUserStore();
|
||||
|
|
@ -276,7 +276,7 @@ const ModelTable = () => {
|
|||
<Tr color={'myGray.600'}>
|
||||
<Th fontSize={'xs'}>
|
||||
<HStack>
|
||||
{userInfo?.team.permission.hasManagePer && (
|
||||
{permissionConfig && userInfo?.team.permission.hasManagePer && (
|
||||
<Checkbox
|
||||
mr={1}
|
||||
isChecked={isSelecteAll}
|
||||
|
|
@ -288,7 +288,7 @@ const ModelTable = () => {
|
|||
</Th>
|
||||
<Th fontSize={'xs'}>{t('common:model.model_type')}</Th>
|
||||
<Th fontSize={'xs'}>{t('common:model.billing')}</Th>
|
||||
{userInfo?.team.permission.hasManagePer && (
|
||||
{permissionConfig && userInfo?.team.permission.hasManagePer && (
|
||||
<Th fontSize={'xs'}>{t('common:permission.Permission config')}</Th>
|
||||
)}
|
||||
</Tr>
|
||||
|
|
@ -298,7 +298,7 @@ const ModelTable = () => {
|
|||
<Tr key={index} _hover={{ bg: 'myGray.50' }}>
|
||||
<Td fontSize={'sm'}>
|
||||
<HStack>
|
||||
{userInfo?.team.permission.hasManagePer && (
|
||||
{permissionConfig && userInfo?.team.permission.hasManagePer && (
|
||||
<Checkbox
|
||||
mr={1}
|
||||
isChecked={isSelected(item)}
|
||||
|
|
@ -315,7 +315,7 @@ const ModelTable = () => {
|
|||
<MyTag colorSchema={item.tagColor as any}>{item.typeLabel}</MyTag>
|
||||
</Td>
|
||||
<Td fontSize={'sm'}>{item.priceLabel}</Td>
|
||||
{userInfo?.team.permission.hasManagePer && (
|
||||
{permissionConfig && userInfo?.team.permission.hasManagePer && (
|
||||
<Td fontSize={'sm'}>
|
||||
<LazyCollaboratorProvider
|
||||
selectedHint={t('account_model:model_permission_config_hint')}
|
||||
|
|
|
|||
|
|
@ -24,19 +24,15 @@ import { getNanoid } from '@fastgpt/global/common/string/tools';
|
|||
import MyDivider from '@fastgpt/web/components/common/MyDivider';
|
||||
import MyAvatar from '@fastgpt/web/components/common/Avatar';
|
||||
import { z } from 'zod';
|
||||
import { clone } from 'lodash';
|
||||
import { getPresignedChatFileGetUrl, getUploadChatFilePresignedUrl } from '@/web/common/file/api';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { ChatBoxContext } from '../../chat/ChatContainer/ChatBox/Provider';
|
||||
import { POST } from '@/web/common/api/request';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { formatFileSize, parseUrlToFileType } from '@fastgpt/global/common/file/tools';
|
||||
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
|
||||
import { PluginRunContext } from '../../chat/ChatContainer/PluginRunBox/context';
|
||||
import { formatFileSize } from '@fastgpt/global/common/file/tools';
|
||||
import { WorkflowAuthContext } from '@/components/core/chat/ChatContainer/context/workflowAuthContext';
|
||||
|
||||
const FileSelector = ({
|
||||
fileUrls,
|
||||
value,
|
||||
onChange,
|
||||
maxFiles,
|
||||
canSelectFile,
|
||||
|
|
@ -47,10 +43,12 @@ const FileSelector = ({
|
|||
customFileExtensionList,
|
||||
canLocalUpload,
|
||||
canUrlUpload,
|
||||
isDisabled = false
|
||||
isDisabled = false,
|
||||
onUploading
|
||||
}: AppFileSelectConfigType & {
|
||||
fileUrls: string[] | any[]; // Can be string[] or file object[]
|
||||
value: UserInputFileItemType[];
|
||||
onChange: (e: any[]) => void;
|
||||
onUploading?: (e: boolean) => void;
|
||||
canLocalUpload?: boolean;
|
||||
canUrlUpload?: boolean;
|
||||
isDisabled?: boolean;
|
||||
|
|
@ -59,73 +57,16 @@ const FileSelector = ({
|
|||
const { toast } = useToast();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const chatBoxOutLinkAuthData = useContextSelector(ChatBoxContext, (v) => v?.outLinkAuthData);
|
||||
const chatBoxAppId = useContextSelector(ChatBoxContext, (v) => v?.appId);
|
||||
const chatBoxChatId = useContextSelector(ChatBoxContext, (v) => v?.chatId);
|
||||
const appId = useContextSelector(WorkflowAuthContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(WorkflowAuthContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
|
||||
const pluginOutLinkAuthData = useContextSelector(PluginRunContext, (v) => v?.outLinkAuthData);
|
||||
const pluginAppId = useContextSelector(PluginRunContext, (v) => v?.appId);
|
||||
const pluginChatId = useContextSelector(PluginRunContext, (v) => v?.chatId);
|
||||
|
||||
const chatItemAppId = useContextSelector(ChatItemContext, (v) => v?.chatBoxData?.appId);
|
||||
const chatItemChatId = useContextSelector(ChatItemContext, (v) => v?.chatBoxData?.chatId);
|
||||
|
||||
const outLinkAuthData = useMemo(
|
||||
() => ({
|
||||
...(chatBoxOutLinkAuthData || {}),
|
||||
...(pluginOutLinkAuthData || {})
|
||||
}),
|
||||
[chatBoxOutLinkAuthData, pluginOutLinkAuthData]
|
||||
const handleChangeFiles = useCallback(
|
||||
(files: UserInputFileItemType[]) => {
|
||||
onChange([...files]);
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
const appId = useMemo(
|
||||
() => chatBoxAppId || pluginAppId || chatItemAppId || '',
|
||||
[chatBoxAppId, pluginAppId, chatItemAppId]
|
||||
);
|
||||
const chatId = useMemo(
|
||||
() => chatBoxChatId || pluginChatId || chatItemChatId || '',
|
||||
[chatBoxChatId, pluginChatId, chatItemChatId]
|
||||
);
|
||||
|
||||
const [cloneFiles, setCloneFiles] = useState<UserInputFileItemType[]>(() => {
|
||||
return fileUrls
|
||||
.map((item) => {
|
||||
const url = typeof item === 'string' ? item : item?.url || item?.key;
|
||||
const key = typeof item === 'string' ? undefined : item?.key;
|
||||
const name = typeof item === 'string' ? undefined : item?.name;
|
||||
const type = typeof item === 'string' ? undefined : item?.type;
|
||||
|
||||
if (!url) return null as unknown as UserInputFileItemType;
|
||||
|
||||
const fileType = parseUrlToFileType(url);
|
||||
if (!fileType && !type) return null as unknown as UserInputFileItemType;
|
||||
|
||||
return {
|
||||
id: getNanoid(6),
|
||||
name: name || fileType?.name || url,
|
||||
type: type || fileType?.type || ChatFileTypeEnum.file,
|
||||
icon: getFileIcon(name || fileType?.name || url),
|
||||
url: typeof item === 'string' ? fileType?.url : item?.url,
|
||||
status: 1,
|
||||
key: key || (typeof item === 'string' && url.startsWith('chat/') ? url : undefined)
|
||||
};
|
||||
})
|
||||
.filter(Boolean) as UserInputFileItemType[];
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const fileObjects = cloneFiles
|
||||
.filter((file) => file.url || file.key)
|
||||
.map((file) => {
|
||||
const fileObj = {
|
||||
type: file.type,
|
||||
name: file.name,
|
||||
key: file.key,
|
||||
url: file.url || file.key || ''
|
||||
};
|
||||
return fileObj;
|
||||
});
|
||||
onChange(fileObjects as any);
|
||||
}, [cloneFiles, onChange]);
|
||||
|
||||
const fileType = useMemo(() => {
|
||||
return getUploadFileType({
|
||||
|
|
@ -146,9 +87,80 @@ const FileSelector = ({
|
|||
]);
|
||||
const maxSelectFiles = maxFiles ?? 10;
|
||||
const maxSize = (feConfigs?.uploadFileMaxSize || 1024) * 1024 * 1024; // nkb
|
||||
const canSelectFileAmount = maxSelectFiles - cloneFiles.length;
|
||||
const canSelectFileAmount = maxSelectFiles - value.length;
|
||||
const isMaxSelected = canSelectFileAmount <= 0;
|
||||
|
||||
const uploadFiles = useCallback(
|
||||
async (files: UserInputFileItemType[]) => {
|
||||
const filterFiles = files.filter((item) => item.status === 0);
|
||||
if (filterFiles.length === 0) return;
|
||||
|
||||
files.forEach((file) => {
|
||||
file.status = 1;
|
||||
});
|
||||
handleChangeFiles(files);
|
||||
|
||||
await Promise.allSettled(
|
||||
filterFiles.map(async (file) => {
|
||||
if (!file.rawFile) return;
|
||||
|
||||
try {
|
||||
// Get Upload Post Presigned URL
|
||||
const { url, fields } = await getUploadChatFilePresignedUrl({
|
||||
filename: file.rawFile.name,
|
||||
appId,
|
||||
chatId,
|
||||
outLinkAuthData
|
||||
});
|
||||
|
||||
// Upload File to S3
|
||||
const formData = new FormData();
|
||||
Object.entries(fields).forEach(([k, v]) => formData.set(k, v));
|
||||
formData.set('file', file.rawFile);
|
||||
await POST(url, formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data; charset=utf-8'
|
||||
},
|
||||
onUploadProgress: (e) => {
|
||||
if (!e.total) return;
|
||||
const percent = Math.round((e.loaded / e.total) * 100);
|
||||
files.forEach((item) => {
|
||||
if (item.id === file.id) {
|
||||
item.process = percent;
|
||||
}
|
||||
});
|
||||
handleChangeFiles(files);
|
||||
}
|
||||
});
|
||||
const previewUrl = await getPresignedChatFileGetUrl({
|
||||
key: fields.key,
|
||||
appId,
|
||||
outLinkAuthData
|
||||
});
|
||||
|
||||
// Update file url and key
|
||||
files.forEach((item) => {
|
||||
if (item.id === file.id) {
|
||||
item.url = previewUrl;
|
||||
item.key = fields.key;
|
||||
item.process = 100;
|
||||
}
|
||||
});
|
||||
handleChangeFiles(files);
|
||||
} catch (error) {
|
||||
files.forEach((item) => {
|
||||
if (item.id === file.id) {
|
||||
item.error = getErrText(error);
|
||||
}
|
||||
});
|
||||
handleChangeFiles(files);
|
||||
}
|
||||
})
|
||||
);
|
||||
},
|
||||
[handleChangeFiles, appId, chatId, outLinkAuthData]
|
||||
);
|
||||
|
||||
// Selector props
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const onSelectFile = useCallback(
|
||||
|
|
@ -180,7 +192,7 @@ const FileSelector = ({
|
|||
id: getNanoid(6),
|
||||
rawFile: file,
|
||||
type: ChatFileTypeEnum.image,
|
||||
name: file.name,
|
||||
name: file?.name,
|
||||
icon: reader.result as string,
|
||||
status: 0
|
||||
};
|
||||
|
|
@ -194,17 +206,19 @@ const FileSelector = ({
|
|||
id: getNanoid(6),
|
||||
rawFile: file,
|
||||
type: ChatFileTypeEnum.file,
|
||||
name: file.name,
|
||||
icon: getFileIcon(file.name),
|
||||
name: file?.name,
|
||||
icon: getFileIcon(file?.name),
|
||||
status: 0
|
||||
});
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
setCloneFiles((state) => [...loadFiles, ...state]);
|
||||
const newFiles = [...loadFiles, ...value];
|
||||
handleChangeFiles(newFiles);
|
||||
uploadFiles(newFiles);
|
||||
},
|
||||
[maxSelectFiles, maxSize, t, toast]
|
||||
[maxSelectFiles, value, handleChangeFiles, uploadFiles, toast, t, maxSize]
|
||||
);
|
||||
const handleDragEnter = (e: DragEvent<HTMLDivElement>) => {
|
||||
e.preventDefault();
|
||||
|
|
@ -234,7 +248,7 @@ const FileSelector = ({
|
|||
const readFile = (entry: any) => {
|
||||
return new Promise((resolve) => {
|
||||
entry.file((file: File) => {
|
||||
if (filterTypeReg.test(file.name)) {
|
||||
if (filterTypeReg.test(file?.name)) {
|
||||
onSelectFile([file]);
|
||||
}
|
||||
resolve(file);
|
||||
|
|
@ -286,79 +300,12 @@ const FileSelector = ({
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
const { File, onOpen } = useSelectFile({
|
||||
fileType,
|
||||
multiple: canSelectFileAmount > 1,
|
||||
maxCount: canSelectFileAmount
|
||||
});
|
||||
const uploadFiles = useCallback(async () => {
|
||||
const filterFiles = cloneFiles.filter((item) => item.status === 0);
|
||||
if (filterFiles.length === 0) return;
|
||||
|
||||
setCloneFiles((state) => state.map((item) => ({ ...item, status: 1 })));
|
||||
|
||||
await Promise.allSettled(
|
||||
filterFiles.map(async (file) => {
|
||||
const copyFile = clone(file);
|
||||
if (!copyFile.rawFile) return;
|
||||
copyFile.status = 1;
|
||||
|
||||
try {
|
||||
// Get Upload Post Presigned URL
|
||||
const { url, fields } = await getUploadChatFilePresignedUrl({
|
||||
filename: copyFile.rawFile.name,
|
||||
appId,
|
||||
chatId,
|
||||
outLinkAuthData
|
||||
});
|
||||
|
||||
// Upload File to S3
|
||||
const formData = new FormData();
|
||||
Object.entries(fields).forEach(([k, v]) => formData.set(k, v));
|
||||
formData.set('file', copyFile.rawFile);
|
||||
await POST(url, formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data; charset=utf-8'
|
||||
},
|
||||
onUploadProgress: (e) => {
|
||||
if (!e.total) return;
|
||||
const percent = Math.round((e.loaded / e.total) * 100);
|
||||
copyFile.process = percent;
|
||||
setCloneFiles((state) =>
|
||||
state.map((item) => (item.id === file.id ? { ...item, process: percent } : item))
|
||||
);
|
||||
}
|
||||
});
|
||||
const previewUrl = await getPresignedChatFileGetUrl({
|
||||
key: fields.key,
|
||||
appId,
|
||||
outLinkAuthData
|
||||
});
|
||||
|
||||
// Update file url and key
|
||||
copyFile.url = previewUrl;
|
||||
copyFile.key = fields.key;
|
||||
console.log(previewUrl, 232);
|
||||
setCloneFiles((state) =>
|
||||
state.map((item) =>
|
||||
item.id === file.id ? { ...item, url: previewUrl, key: fields.key } : item
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
setCloneFiles((state) =>
|
||||
state.map((item) =>
|
||||
item.id === file.id ? { ...item, error: getErrText(error) } : item
|
||||
)
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
}, [appId, chatId, cloneFiles, outLinkAuthData]);
|
||||
// Watch newfiles,and upload
|
||||
useRequest2(uploadFiles, {
|
||||
refreshDeps: [cloneFiles],
|
||||
manual: false
|
||||
});
|
||||
|
||||
// Url upload props
|
||||
const [urlInput, setUrlInput] = useState('');
|
||||
|
|
@ -377,12 +324,12 @@ const FileSelector = ({
|
|||
|
||||
const trimmedUrl = url.trim();
|
||||
if (trimmedUrl) {
|
||||
setCloneFiles((state) => [
|
||||
...state,
|
||||
handleChangeFiles([
|
||||
...value,
|
||||
{
|
||||
id: getNanoid(6),
|
||||
status: 1,
|
||||
type: 'file',
|
||||
type: ChatFileTypeEnum.file,
|
||||
url: trimmedUrl,
|
||||
name: trimmedUrl,
|
||||
icon: 'common/link'
|
||||
|
|
@ -392,12 +339,22 @@ const FileSelector = ({
|
|||
|
||||
setUrlInput('');
|
||||
},
|
||||
[t, toast]
|
||||
[t, toast, handleChangeFiles, value]
|
||||
);
|
||||
|
||||
const handleDeleteFile = useCallback((id: string) => {
|
||||
setCloneFiles((state) => state.filter((file) => file.id !== id));
|
||||
}, []);
|
||||
const handleDeleteFile = useCallback(
|
||||
(id: string) => {
|
||||
handleChangeFiles(value.filter((file) => file.id !== id));
|
||||
},
|
||||
[handleChangeFiles, value]
|
||||
);
|
||||
|
||||
const isUploading = value.some((file) => !file.url && !file.error);
|
||||
const disabled = isDisabled || isUploading;
|
||||
|
||||
useEffect(() => {
|
||||
onUploading?.(isUploading);
|
||||
}, [isUploading]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -416,10 +373,10 @@ const FileSelector = ({
|
|||
borderColor={'myGray.250'}
|
||||
borderRadius={'md'}
|
||||
userSelect={'none'}
|
||||
{...(isMaxSelected || isDisabled
|
||||
{...(isMaxSelected || disabled
|
||||
? {
|
||||
cursor: 'not-allowed',
|
||||
opacity: isDisabled ? 0.6 : 1
|
||||
opacity: disabled ? 0.6 : 1
|
||||
}
|
||||
: {
|
||||
cursor: 'pointer',
|
||||
|
|
@ -436,10 +393,10 @@ const FileSelector = ({
|
|||
})}
|
||||
>
|
||||
<MyIcon name={'common/uploadFileFill'} w={'32px'} />
|
||||
{isMaxSelected || isDisabled ? (
|
||||
{isMaxSelected ? (
|
||||
<>
|
||||
<Box fontWeight={'500'} fontSize={'sm'}>
|
||||
{isDisabled ? t('common:Running') : t('file:reached_max_file_count')}
|
||||
{t('file:reached_max_file_count')}
|
||||
</Box>
|
||||
</>
|
||||
) : (
|
||||
|
|
@ -476,11 +433,7 @@ const FileSelector = ({
|
|||
pl={8}
|
||||
py={1.5}
|
||||
placeholder={
|
||||
isDisabled
|
||||
? t('common:Running')
|
||||
: isMaxSelected
|
||||
? t('file:reached_max_file_count')
|
||||
: t('chat:click_to_add_url')
|
||||
isMaxSelected ? t('file:reached_max_file_count') : t('chat:click_to_add_url')
|
||||
}
|
||||
/>
|
||||
</InputGroup>
|
||||
|
|
@ -489,52 +442,56 @@ const FileSelector = ({
|
|||
</VStack>
|
||||
|
||||
{/* Preview */}
|
||||
{cloneFiles.length > 0 && (
|
||||
{value.length > 0 && (
|
||||
<>
|
||||
<MyDivider />
|
||||
<VStack>
|
||||
{cloneFiles.map((file) => {
|
||||
{value.map((file) => {
|
||||
const fileIcon =
|
||||
file.type === ChatFileTypeEnum.image ? file.url : getFileIcon(file?.name);
|
||||
return (
|
||||
<Box key={file.id} w={'full'}>
|
||||
<Box key={file?.id} w={'full'}>
|
||||
<HStack py={1} px={3} bg={'white'} borderRadius={'md'} border={'sm'}>
|
||||
<MyAvatar src={file.icon} w={'1.2rem'} />
|
||||
<MyAvatar src={fileIcon} w={'1.2rem'} />
|
||||
<Box
|
||||
fontSize={'sm'}
|
||||
flex={'1 0 0'}
|
||||
className="textEllipsis"
|
||||
title={file.name}
|
||||
{...(file.error && {
|
||||
title={file?.name}
|
||||
{...(file?.error && {
|
||||
color: 'red.600'
|
||||
})}
|
||||
>
|
||||
{file.name}
|
||||
{file?.name}
|
||||
</Box>
|
||||
|
||||
{/* Status icon */}
|
||||
{!!file.url || !!file.error ? (
|
||||
<IconButton
|
||||
size={'xsSquare'}
|
||||
borderRadius={'xs'}
|
||||
variant={'transparentDanger'}
|
||||
aria-label={'Delete file'}
|
||||
icon={<MyIcon name={'close'} w={'1rem'} />}
|
||||
onClick={() => handleDeleteFile(file.id)}
|
||||
isDisabled={isDisabled}
|
||||
/>
|
||||
) : (
|
||||
<HStack w={'24px'} h={'24px'} justifyContent={'center'}>
|
||||
<CircularProgress
|
||||
value={file.process}
|
||||
color="primary.600"
|
||||
bg={'white'}
|
||||
size={'1.2rem'}
|
||||
<>
|
||||
{!!file?.url || !!file?.error ? (
|
||||
<IconButton
|
||||
size={'xsSquare'}
|
||||
borderRadius={'xs'}
|
||||
variant={'transparentDanger'}
|
||||
aria-label={'Delete file'}
|
||||
icon={<MyIcon name={'close'} w={'1rem'} />}
|
||||
onClick={() => handleDeleteFile(file?.id)}
|
||||
isDisabled={disabled}
|
||||
/>
|
||||
</HStack>
|
||||
)}
|
||||
) : (
|
||||
<HStack w={'24px'} h={'24px'} justifyContent={'center'}>
|
||||
<CircularProgress
|
||||
value={file?.process}
|
||||
color="primary.600"
|
||||
bg={'white'}
|
||||
size={'1.2rem'}
|
||||
/>
|
||||
</HStack>
|
||||
)}
|
||||
</>
|
||||
</HStack>
|
||||
{file.error && (
|
||||
{file?.error && (
|
||||
<Box mt={1} fontSize={'xs'} color={'red.600'}>
|
||||
{file.error}
|
||||
{file?.error}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
|
|
|||
|
|
@ -211,10 +211,13 @@ const InputRender = (props: InputRenderProps) => {
|
|||
}
|
||||
|
||||
if (inputType === InputTypeEnum.fileSelect) {
|
||||
const files = Array.isArray(value) ? value : [];
|
||||
return (
|
||||
<FileSelector
|
||||
fileUrls={Array.isArray(value) ? value : []}
|
||||
value={files}
|
||||
onChange={onChange}
|
||||
isDisabled={isDisabled}
|
||||
onUploading={props.setUploading}
|
||||
maxFiles={props.maxFiles}
|
||||
canSelectFile={props.canSelectFile}
|
||||
canSelectImg={props.canSelectImg}
|
||||
|
|
@ -224,7 +227,6 @@ const InputRender = (props: InputRenderProps) => {
|
|||
customFileExtensionList={props.customFileExtensionList}
|
||||
canLocalUpload={props.canLocalUpload}
|
||||
canUrlUpload={props.canUrlUpload}
|
||||
isDisabled={isDisabled}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { useFieldArray, type UseFormReturn } from 'react-hook-form';
|
|||
import { ChatBoxContext } from '../Provider';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { WorkflowAuthContext } from '../../context/workflowAuthContext';
|
||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||
import { documentFileType } from '@fastgpt/global/common/file/constants';
|
||||
import FilePreview from '../../components/FilePreview';
|
||||
|
|
@ -56,9 +57,9 @@ const ChatInput = ({
|
|||
|
||||
const InputLeftComponent = useContextSelector(ChatBoxContext, (v) => v.InputLeftComponent);
|
||||
|
||||
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(ChatBoxContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(ChatBoxContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(WorkflowAuthContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(WorkflowAuthContext, (v) => v.chatId);
|
||||
const isChatting = useContextSelector(ChatBoxContext, (v) => v.isChatting);
|
||||
const whisperConfig = useContextSelector(ChatBoxContext, (v) => v.whisperConfig);
|
||||
const chatInputGuide = useContextSelector(ChatBoxContext, (v) => v.chatInputGuide);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { useTranslation } from 'next-i18next';
|
|||
import HighlightText from '@fastgpt/web/components/common/String/HighlightText';
|
||||
import { ChatBoxContext } from '../Provider';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { WorkflowAuthContext } from '../../context/workflowAuthContext';
|
||||
|
||||
export default function InputGuideBox({
|
||||
appId,
|
||||
|
|
@ -22,7 +23,7 @@ export default function InputGuideBox({
|
|||
}) {
|
||||
const { t } = useTranslation();
|
||||
const chatInputGuide = useContextSelector(ChatBoxContext, (v) => v.chatInputGuide);
|
||||
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
|
||||
const { data = [] } = useRequest2(
|
||||
async () => {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
|||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { ChatBoxContext } from '../Provider';
|
||||
import { WorkflowAuthContext } from '../../context/workflowAuthContext';
|
||||
import MyIconButton from '@/pageComponents/account/team/OrgManage/IconButton';
|
||||
import { isMobile } from '@fastgpt/web/common/system/utils';
|
||||
|
||||
|
|
@ -286,8 +287,8 @@ const VoiceInput = forwardRef<VoiceInputComponentRef, VoiceInputProps>(
|
|||
const isMobileDevice = isMobile();
|
||||
const { isPc } = useSystem();
|
||||
|
||||
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(ChatBoxContext, (v) => v.appId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(WorkflowAuthContext, (v) => v.appId);
|
||||
const whisperConfig = useContextSelector(ChatBoxContext, (v) => v.whisperConfig);
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { ChatRecordContext } from '@/web/core/chat/context/chatRecordContext';
|
|||
import { useCreation } from 'ahooks';
|
||||
import type { ChatTypeEnum } from './constants';
|
||||
import type { ChatQuickAppType } from '@fastgpt/global/core/chat/setting/type';
|
||||
import { WorkflowRuntimeContextProvider } from '@/components/core/chat/ChatContainer/context/workflowAuthContext';
|
||||
|
||||
export type ChatProviderProps = {
|
||||
appId: string;
|
||||
|
|
@ -43,7 +44,7 @@ export type ChatProviderProps = {
|
|||
onSwitchQuickApp?: (appId: string) => Promise<void>;
|
||||
};
|
||||
|
||||
type useChatStoreType = ChatProviderProps & {
|
||||
type useChatStoreType = Omit<ChatProviderProps, 'appId' | 'chatId' | 'outLinkAuthData'> & {
|
||||
welcomeText: string;
|
||||
variableList: VariableItemType[];
|
||||
questionGuide: AppQGConfigType;
|
||||
|
|
@ -72,10 +73,6 @@ type useChatStoreType = ChatProviderProps & {
|
|||
chatInputGuide: ChatInputGuideConfigType;
|
||||
getHistoryResponseData: ({ dataId }: { dataId: string }) => Promise<ChatHistoryItemResType[]>;
|
||||
fileSelectConfig: AppFileSelectConfigType;
|
||||
|
||||
appId: string;
|
||||
chatId: string;
|
||||
outLinkAuthData: OutLinkChatAuthProps;
|
||||
};
|
||||
|
||||
export const ChatBoxContext = createContext<useChatStoreType>({
|
||||
|
|
@ -131,7 +128,6 @@ export const ChatBoxContext = createContext<useChatStoreType>({
|
|||
open: false,
|
||||
customUrl: ''
|
||||
},
|
||||
outLinkAuthData: {},
|
||||
// @ts-ignore
|
||||
variablesForm: undefined
|
||||
});
|
||||
|
|
@ -255,14 +251,19 @@ const Provider = ({
|
|||
setAudioPlayingChatId,
|
||||
isChatting,
|
||||
chatInputGuide,
|
||||
appId,
|
||||
chatId,
|
||||
outLinkAuthData: formatOutLinkAuth,
|
||||
getHistoryResponseData,
|
||||
chatType
|
||||
};
|
||||
|
||||
return <ChatBoxContext.Provider value={value}>{children}</ChatBoxContext.Provider>;
|
||||
return (
|
||||
<WorkflowRuntimeContextProvider
|
||||
appId={appId}
|
||||
chatId={chatId}
|
||||
outLinkAuthData={formatOutLinkAuth}
|
||||
>
|
||||
<ChatBoxContext.Provider value={value}>{children}</ChatBoxContext.Provider>
|
||||
</WorkflowRuntimeContextProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(Provider);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {
|
|||
import FilesBlock from './FilesBox';
|
||||
import { ChatBoxContext } from '../Provider';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { WorkflowAuthContext } from '../../context/workflowAuthContext';
|
||||
import AIResponseBox from '../../../components/AIResponseBox';
|
||||
import { useCopyData } from '@fastgpt/web/hooks/useCopyData';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
|
|
@ -158,9 +159,9 @@ const ChatItem = (props: Props) => {
|
|||
const chatType = useContextSelector(ChatBoxContext, (v) => v.chatType);
|
||||
const showNodeStatus = useContextSelector(ChatItemContext, (v) => v.showNodeStatus);
|
||||
|
||||
const appId = useContextSelector(ChatBoxContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(ChatBoxContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(WorkflowAuthContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(WorkflowAuthContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
const isShowReadRawSource = useContextSelector(ChatItemContext, (v) => v.isShowReadRawSource);
|
||||
|
||||
const { totalQuoteList: quoteList = [] } = useMemo(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { useRequest } from '@fastgpt/web/hooks/useRequest';
|
|||
import { useTranslation } from 'next-i18next';
|
||||
import { updateChatUserFeedback } from '@/web/core/chat/api';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { ChatBoxContext } from '../Provider';
|
||||
import { WorkflowAuthContext } from '../../context/workflowAuthContext';
|
||||
|
||||
const FeedbackModal = ({
|
||||
appId,
|
||||
|
|
@ -22,7 +22,7 @@ const FeedbackModal = ({
|
|||
}) => {
|
||||
const ref = useRef<HTMLTextAreaElement>(null);
|
||||
const { t } = useTranslation();
|
||||
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
|
||||
const { mutate, isLoading } = useRequest({
|
||||
mutationFn: async () => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Box, useTheme } from '@chakra-ui/react';
|
|||
import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type';
|
||||
import QuoteItem, { formatScore } from '@/components/core/dataset/QuoteItem';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { ChatBoxContext } from '../Provider';
|
||||
import { WorkflowAuthContext } from '../../context/workflowAuthContext';
|
||||
import { ChatItemContext } from '@/web/core/chat/context/chatItemContext';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useChatStore } from '@/web/core/chat/context/useChatStore';
|
||||
|
|
@ -20,7 +20,7 @@ const QuoteList = React.memo(function QuoteList({
|
|||
const theme = useTheme();
|
||||
const { appId, outLinkAuthData } = useChatStore();
|
||||
|
||||
const RawSourceBoxProps = useContextSelector(ChatBoxContext, (v) => ({
|
||||
const RawSourceBoxProps = useContextSelector(WorkflowAuthContext, (v) => ({
|
||||
chatItemDataId,
|
||||
appId: v.appId,
|
||||
chatId: v.chatId,
|
||||
|
|
|
|||
|
|
@ -41,13 +41,14 @@ import {
|
|||
ChatStatusEnum
|
||||
} from '@fastgpt/global/core/chat/constants';
|
||||
import {
|
||||
checkIsInteractiveByHistories,
|
||||
getInteractiveByHistories,
|
||||
formatChatValue2InputType,
|
||||
setUserSelectResultToHistories
|
||||
setInteractiveResultToHistories
|
||||
} from './utils';
|
||||
import { ChatTypeEnum, textareaMinH } from './constants';
|
||||
import { SseResponseEventEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import ChatProvider, { ChatBoxContext, type ChatProviderProps } from './Provider';
|
||||
import { WorkflowAuthContext } from '../context/workflowAuthContext';
|
||||
import ChatItem from './components/ChatItem';
|
||||
import dynamic from 'next/dynamic';
|
||||
import type { StreamResponseType } from '@/web/common/api/fetch';
|
||||
|
|
@ -64,6 +65,7 @@ import MyBox from '@fastgpt/web/components/common/MyBox';
|
|||
import { VariableInputEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { valueTypeFormat } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { formatTime2YMDHMS } from '@fastgpt/global/common/string/time';
|
||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
|
||||
const FeedbackModal = dynamic(() => import('./components/FeedbackModal'));
|
||||
const ReadFeedbackModal = dynamic(() => import('./components/ReadFeedbackModal'));
|
||||
|
|
@ -74,6 +76,7 @@ const VariableInputForm = dynamic(() => import('./components/VariableInputForm')
|
|||
const ChatHomeVariablesForm = dynamic(() => import('./components/home/ChatHomeVariablesForm'));
|
||||
const WelcomeHomeBox = dynamic(() => import('./components/home/WelcomeHomeBox'));
|
||||
const QuickApps = dynamic(() => import('./components/home/QuickApps'));
|
||||
const WorkorderEntrance = dynamic(() => import('@/pageComponents/chat/WorkorderEntrance'));
|
||||
|
||||
enum FeedbackTypeEnum {
|
||||
user = 'user',
|
||||
|
|
@ -89,6 +92,7 @@ type Props = OutLinkChatAuthProps &
|
|||
showVoiceIcon?: boolean;
|
||||
showEmptyIntro?: boolean;
|
||||
active?: boolean; // can use
|
||||
showWorkorder?: boolean;
|
||||
|
||||
onStartChat?: (e: StartChatFnProps) => Promise<
|
||||
StreamResponseType & {
|
||||
|
|
@ -104,13 +108,14 @@ const ChatBox = ({
|
|||
showVoiceIcon = true,
|
||||
showEmptyIntro = false,
|
||||
active = true,
|
||||
showWorkorder,
|
||||
onStartChat,
|
||||
chatType
|
||||
}: Props) => {
|
||||
const ScrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
const { t } = useTranslation();
|
||||
const { toast } = useToast();
|
||||
const { feConfigs } = useSystemStore();
|
||||
const { feConfigs, setNotSufficientModalType } = useSystemStore();
|
||||
const { isPc } = useSystem();
|
||||
const TextareaDom = useRef<HTMLTextAreaElement>(null);
|
||||
const chatController = useRef(new AbortController());
|
||||
|
|
@ -140,9 +145,9 @@ const ChatBox = ({
|
|||
const isChatRecordsLoaded = useContextSelector(ChatRecordContext, (v) => v.isChatRecordsLoaded);
|
||||
const ScrollData = useContextSelector(ChatRecordContext, (v) => v.ScrollData);
|
||||
|
||||
const appId = useContextSelector(ChatBoxContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(ChatBoxContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(WorkflowAuthContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(WorkflowAuthContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
const welcomeText = useContextSelector(ChatBoxContext, (v) => v.welcomeText);
|
||||
const variableList = useContextSelector(ChatBoxContext, (v) => v.variableList);
|
||||
const questionGuide = useContextSelector(ChatBoxContext, (v) => v.questionGuide);
|
||||
|
|
@ -153,7 +158,7 @@ const ChatBox = ({
|
|||
const isChatting = useContextSelector(ChatBoxContext, (v) => v.isChatting);
|
||||
|
||||
// Workflow running, there are user input or selection
|
||||
const isInteractive = useMemo(() => checkIsInteractiveByHistories(chatRecords), [chatRecords]);
|
||||
const lastInteractive = useMemo(() => getInteractiveByHistories(chatRecords), [chatRecords]);
|
||||
|
||||
const showExternalVariable = useMemo(() => {
|
||||
const map: Record<string, boolean> = {
|
||||
|
|
@ -537,7 +542,7 @@ const ChatBox = ({
|
|||
setChatRecords(
|
||||
isInteractivePrompt
|
||||
? // 把交互的结果存储到对话记录中,交互模式下,不需要新的会话轮次
|
||||
setUserSelectResultToHistories(newChatList.slice(0, -2), text)
|
||||
setInteractiveResultToHistories(newChatList.slice(0, -2), text)
|
||||
: newChatList
|
||||
);
|
||||
|
||||
|
|
@ -598,11 +603,18 @@ const ChatBox = ({
|
|||
responseData
|
||||
};
|
||||
});
|
||||
|
||||
const lastInteractive = getInteractiveByHistories(state);
|
||||
if (lastInteractive?.type === 'paymentPause' && !lastInteractive.params.continue) {
|
||||
setNotSufficientModalType(TeamErrEnum.aiPointsNotEnough);
|
||||
}
|
||||
|
||||
return newChatHistories;
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
if (!checkIsInteractiveByHistories(newChatHistories)) {
|
||||
// If there is no interactive mode, create a question guide
|
||||
if (!getInteractiveByHistories(newChatHistories)) {
|
||||
createQuestionGuide();
|
||||
}
|
||||
|
||||
|
|
@ -887,7 +899,7 @@ const ChatBox = ({
|
|||
abortRequest('leave');
|
||||
}, [chatId, appId, abortRequest, setValue]);
|
||||
|
||||
const canSendPrompt = onStartChat && chatStarted && active && !isInteractive;
|
||||
const canSendPrompt = onStartChat && chatStarted && active && !lastInteractive;
|
||||
|
||||
// Add listener
|
||||
useEffect(() => {
|
||||
|
|
@ -989,6 +1001,7 @@ const ChatBox = ({
|
|||
}
|
||||
}, [ScrollContainerRef, setIsVariableVisible]);
|
||||
|
||||
// Home chat, and no chat records
|
||||
const isHomeRender = useMemo(() => {
|
||||
return chatType === ChatTypeEnum.home && chatRecords.length === 0 && !chatStartedWatch;
|
||||
}, [chatType, chatRecords.length, chatStartedWatch]);
|
||||
|
|
@ -1096,6 +1109,8 @@ const ChatBox = ({
|
|||
showMarkIcon,
|
||||
onCloseCustomFeedback
|
||||
]);
|
||||
|
||||
// Child box
|
||||
const AppChatRenderBox = useMemo(() => {
|
||||
return (
|
||||
<ScrollData
|
||||
|
|
@ -1180,6 +1195,8 @@ const ChatBox = ({
|
|||
w={'100%'}
|
||||
maxW={['auto', 'min(820px, 100%)']}
|
||||
>
|
||||
{showWorkorder && <WorkorderEntrance />}
|
||||
|
||||
<ChatInput
|
||||
onSendMessage={sendPrompt}
|
||||
onStop={() => chatController.current?.abort('stop')}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { type ChatBoxInputType, type UserInputFileItemType } from './type';
|
|||
import { getFileIcon } from '@fastgpt/global/common/file/icon';
|
||||
import { ChatItemValueTypeEnum, ChatStatusEnum } from '@fastgpt/global/core/chat/constants';
|
||||
import { extractDeepestInteractive } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import type { WorkflowInteractiveResponseType } from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||
|
||||
export const formatChatValue2InputType = (value?: ChatItemValueItemType[]): ChatBoxInputType => {
|
||||
if (!value) {
|
||||
|
|
@ -44,9 +45,11 @@ export const formatChatValue2InputType = (value?: ChatItemValueItemType[]): Chat
|
|||
};
|
||||
};
|
||||
|
||||
export const checkIsInteractiveByHistories = (chatHistories: ChatSiteItemType[]) => {
|
||||
export const getInteractiveByHistories = (
|
||||
chatHistories: ChatSiteItemType[]
|
||||
): WorkflowInteractiveResponseType | undefined => {
|
||||
const lastAIHistory = chatHistories[chatHistories.length - 1];
|
||||
if (!lastAIHistory) return false;
|
||||
if (!lastAIHistory) return;
|
||||
|
||||
const lastMessageValue = lastAIHistory.value[
|
||||
lastAIHistory.value.length - 1
|
||||
|
|
@ -57,19 +60,24 @@ export const checkIsInteractiveByHistories = (chatHistories: ChatSiteItemType[])
|
|||
lastMessageValue.type === ChatItemValueTypeEnum.interactive &&
|
||||
!!lastMessageValue?.interactive?.params
|
||||
) {
|
||||
const params = lastMessageValue.interactive.params;
|
||||
const finalInteractive = extractDeepestInteractive(lastMessageValue.interactive);
|
||||
|
||||
// 如果用户选择了,则不认为是交互模式(可能是上一轮以交互结尾,发起的新的一轮对话)
|
||||
if ('userSelectOptions' in params) {
|
||||
return !params.userSelectedVal;
|
||||
} else if ('inputForm' in params) {
|
||||
return !params.submitted;
|
||||
if (finalInteractive.type === 'userSelect') {
|
||||
if (!!finalInteractive.params.userSelectedVal) return;
|
||||
} else if (finalInteractive.type === 'userInput') {
|
||||
if (!!finalInteractive.params.submitted) return;
|
||||
} else if (finalInteractive.type === 'paymentPause') {
|
||||
if (!!finalInteractive.params.continue) return;
|
||||
}
|
||||
|
||||
return finalInteractive;
|
||||
}
|
||||
|
||||
return false;
|
||||
return;
|
||||
};
|
||||
|
||||
export const setUserSelectResultToHistories = (
|
||||
export const setInteractiveResultToHistories = (
|
||||
histories: ChatSiteItemType[],
|
||||
interactiveVal: string
|
||||
): ChatSiteItemType[] => {
|
||||
|
|
@ -116,6 +124,19 @@ export const setUserSelectResultToHistories = (
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (finalInteractive.type === 'paymentPause') {
|
||||
return {
|
||||
...val,
|
||||
interactive: {
|
||||
...finalInteractive,
|
||||
params: {
|
||||
...finalInteractive.params,
|
||||
continue: true
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/consta
|
|||
import InputRender from '@/components/core/app/formRender';
|
||||
import { nodeInputTypeToInputType } from '@/components/core/app/formRender/utils';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { WorkflowAuthContext } from '@/components/core/chat/ChatContainer/context/workflowAuthContext';
|
||||
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
|
||||
import { useDeepCompareEffect } from 'ahooks';
|
||||
import PopoverConfirm from '@fastgpt/web/components/common/MyPopover/PopoverConfirm';
|
||||
|
||||
const RenderInput = () => {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -36,9 +40,9 @@ const RenderInput = () => {
|
|||
const isChatting = useContextSelector(PluginRunContext, (v) => v.isChatting);
|
||||
const fileSelectConfig = useContextSelector(PluginRunContext, (v) => v.fileSelectConfig);
|
||||
const instruction = useContextSelector(PluginRunContext, (v) => v.instruction);
|
||||
const appId = useContextSelector(PluginRunContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(PluginRunContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(PluginRunContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(WorkflowAuthContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(WorkflowAuthContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
|
||||
const { llmModelList } = useSystemStore();
|
||||
|
||||
|
|
@ -74,17 +78,8 @@ const RenderInput = () => {
|
|||
});
|
||||
/* Global files(abandon) <=== */
|
||||
|
||||
const [restartData, setRestartData] = useState<ChatBoxInputFormType>();
|
||||
const onClickNewChat = useCallback(
|
||||
(e: ChatBoxInputFormType) => {
|
||||
setRestartData(e);
|
||||
onNewChat?.();
|
||||
},
|
||||
[onNewChat, setRestartData]
|
||||
);
|
||||
|
||||
// Get plugin input components
|
||||
const formatPluginInputs = useMemo(() => {
|
||||
const formatPluginInputs = useMemoEnhance(() => {
|
||||
if (histories.length === 0) return pluginInputs;
|
||||
try {
|
||||
const historyValue = histories[0]?.value as UserChatItemValueItemType[];
|
||||
|
|
@ -98,8 +93,30 @@ const RenderInput = () => {
|
|||
}
|
||||
}, [histories, pluginInputs]);
|
||||
|
||||
const [restartData, setRestartData] = useState<ChatBoxInputFormType>();
|
||||
const onClickNewChat = useCallback(
|
||||
(e: ChatBoxInputFormType) => {
|
||||
setRestartData(e);
|
||||
onNewChat?.();
|
||||
},
|
||||
[onNewChat]
|
||||
);
|
||||
|
||||
const onResetDefault = useCallback(() => {
|
||||
reset({
|
||||
files: [],
|
||||
variables: formatPluginInputs.reduce(
|
||||
(acc, input) => {
|
||||
acc[input.key] = input.defaultValue;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, any>
|
||||
)
|
||||
});
|
||||
}, [reset, formatPluginInputs]);
|
||||
|
||||
// Reset input value
|
||||
useEffect(() => {
|
||||
useDeepCompareEffect(() => {
|
||||
// Set config default value
|
||||
if (histories.length === 0) {
|
||||
if (restartData) {
|
||||
|
|
@ -108,16 +125,7 @@ const RenderInput = () => {
|
|||
return;
|
||||
}
|
||||
|
||||
reset({
|
||||
files: [],
|
||||
variables: formatPluginInputs.reduce(
|
||||
(acc, input) => {
|
||||
acc[input.key] = input.defaultValue;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, any>
|
||||
)
|
||||
});
|
||||
onResetDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -159,13 +167,13 @@ const RenderInput = () => {
|
|||
variables: historyVariables,
|
||||
files: historyFileList
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [histories, formatPluginInputs]);
|
||||
|
||||
const [uploading, setUploading] = useState(false);
|
||||
|
||||
const fileUploading = uploading || hasFileUploading;
|
||||
const isDisabledInput = fileUploading || histories.length > 0;
|
||||
const hasHistory = histories.length > 0;
|
||||
const isDisabledInput = !!hasHistory;
|
||||
|
||||
return (
|
||||
<Box>
|
||||
|
|
@ -196,6 +204,7 @@ const RenderInput = () => {
|
|||
<Button
|
||||
leftIcon={<MyIcon name={selectFileIcon as any} w={'16px'} />}
|
||||
variant={'whiteBase'}
|
||||
isDisabled={isChatting || fileUploading}
|
||||
onClick={() => {
|
||||
onOpenSelectFile();
|
||||
}}
|
||||
|
|
@ -292,13 +301,20 @@ const RenderInput = () => {
|
|||
})}
|
||||
{/* Run Button */}
|
||||
{onStartChat && onNewChat && (
|
||||
<Flex justifyContent={'end'} mt={8}>
|
||||
<Flex justifyContent={'end'} mt={8} gap={4}>
|
||||
<PopoverConfirm
|
||||
content={t('chat:confirm_clear_input_value')}
|
||||
onConfirm={onResetDefault}
|
||||
Trigger={<Button variant={'whiteBase'}>{t('chat:clear_input_value')}</Button>}
|
||||
/>
|
||||
|
||||
<Button
|
||||
isLoading={isChatting}
|
||||
isDisabled={fileUploading}
|
||||
onClick={() => {
|
||||
handleSubmit((e) => {
|
||||
if (isDisabledInput) {
|
||||
if (hasHistory) {
|
||||
console.log(e);
|
||||
onClickNewChat(e);
|
||||
} else {
|
||||
onSubmit(e);
|
||||
|
|
@ -306,7 +322,7 @@ const RenderInput = () => {
|
|||
})();
|
||||
}}
|
||||
>
|
||||
{isDisabledInput ? t('common:Restart') : t('common:Run')}
|
||||
{hasHistory ? t('common:Restart') : t('common:Run')}
|
||||
</Button>
|
||||
</Flex>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import { type AppFileSelectConfigType } from '@fastgpt/global/core/app/type';
|
|||
import { defaultAppSelectFileConfig } from '@fastgpt/global/core/app/constants';
|
||||
import { mergeChatResponseData } from '@fastgpt/global/core/chat/utils';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { WorkflowRuntimeContextProvider } from '@/components/core/chat/ChatContainer/context/workflowAuthContext';
|
||||
|
||||
type PluginRunContextType = PluginRunBoxProps & {
|
||||
isChatting: boolean;
|
||||
|
|
@ -31,16 +32,15 @@ type PluginRunContextType = PluginRunBoxProps & {
|
|||
fileSelectConfig: AppFileSelectConfigType;
|
||||
};
|
||||
|
||||
export const PluginRunContext = createContext<PluginRunContextType>({
|
||||
export const PluginRunContext = createContext<
|
||||
Omit<PluginRunContextType, 'appId' | 'chatId' | 'outLinkAuthData'>
|
||||
>({
|
||||
isChatting: false,
|
||||
onSubmit: function (e: FieldValues): Promise<any> {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
instruction: '',
|
||||
fileSelectConfig: defaultAppSelectFileConfig,
|
||||
appId: '',
|
||||
chatId: '',
|
||||
outLinkAuthData: {}
|
||||
fileSelectConfig: defaultAppSelectFileConfig
|
||||
});
|
||||
|
||||
const PluginRunContextProvider = ({
|
||||
|
|
@ -229,25 +229,13 @@ const PluginRunContextProvider = ({
|
|||
});
|
||||
|
||||
try {
|
||||
// Remove files icon
|
||||
const formatVariables = cloneDeep(variables);
|
||||
for (const key in formatVariables) {
|
||||
if (Array.isArray(formatVariables[key])) {
|
||||
formatVariables[key].forEach((item) => {
|
||||
if (item.url && item.icon) {
|
||||
delete item.icon;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
await onStartChat({
|
||||
messages,
|
||||
controller: chatController.current,
|
||||
generatingMessage,
|
||||
variables: {
|
||||
files,
|
||||
...formatVariables
|
||||
...variables
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -304,7 +292,15 @@ const PluginRunContextProvider = ({
|
|||
instruction,
|
||||
fileSelectConfig
|
||||
};
|
||||
return <PluginRunContext.Provider value={contextValue}>{children}</PluginRunContext.Provider>;
|
||||
return (
|
||||
<WorkflowRuntimeContextProvider
|
||||
appId={props.appId}
|
||||
chatId={props.chatId}
|
||||
outLinkAuthData={props.outLinkAuthData || {}}
|
||||
>
|
||||
<PluginRunContext.Provider value={contextValue}>{children}</PluginRunContext.Provider>
|
||||
</WorkflowRuntimeContextProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default PluginRunContextProvider;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
import type { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat';
|
||||
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
|
||||
import { createContext } from 'use-context-selector';
|
||||
|
||||
type WorkflowAuthContextType = {
|
||||
outLinkAuthData: OutLinkChatAuthProps;
|
||||
appId: string;
|
||||
chatId: string;
|
||||
};
|
||||
|
||||
export const WorkflowAuthContext = createContext<WorkflowAuthContextType>({
|
||||
outLinkAuthData: {},
|
||||
appId: '',
|
||||
chatId: ''
|
||||
});
|
||||
|
||||
export const WorkflowRuntimeContextProvider = ({
|
||||
appId,
|
||||
chatId,
|
||||
outLinkAuthData,
|
||||
children
|
||||
}: {
|
||||
appId: string;
|
||||
chatId: string;
|
||||
outLinkAuthData: OutLinkChatAuthProps;
|
||||
children: React.ReactNode;
|
||||
}) => {
|
||||
const value = useMemoEnhance(
|
||||
() => ({
|
||||
outLinkAuthData,
|
||||
appId,
|
||||
chatId
|
||||
}),
|
||||
[outLinkAuthData, appId, chatId]
|
||||
);
|
||||
|
||||
return <WorkflowAuthContext.Provider value={value}>{children}</WorkflowAuthContext.Provider>;
|
||||
};
|
||||
|
|
@ -21,6 +21,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
|||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||
import type {
|
||||
InteractiveBasicType,
|
||||
PaymentPauseInteractive,
|
||||
UserInputInteractive,
|
||||
UserSelectInteractive
|
||||
} from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||
|
|
@ -31,7 +32,7 @@ import { SelectOptionsComponent, FormInputComponent } from './Interactive/Intera
|
|||
import { extractDeepestInteractive } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { type OnOpenCiteModalProps } from '@/web/core/chat/context/chatItemContext';
|
||||
import { ChatBoxContext } from '../ChatContainer/ChatBox/Provider';
|
||||
import { WorkflowAuthContext } from '../ChatContainer/context/workflowAuthContext';
|
||||
import { useCreation } from 'ahooks';
|
||||
|
||||
const accordionButtonStyle = {
|
||||
|
|
@ -98,9 +99,9 @@ const RenderText = React.memo(function RenderText({
|
|||
chatItemDataId: string;
|
||||
onOpenCiteModal?: (e?: OnOpenCiteModalProps) => void;
|
||||
}) {
|
||||
const appId = useContextSelector(ChatBoxContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(ChatBoxContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(ChatBoxContext, (v) => v.outLinkAuthData);
|
||||
const appId = useContextSelector(WorkflowAuthContext, (v) => v.appId);
|
||||
const chatId = useContextSelector(WorkflowAuthContext, (v) => v.chatId);
|
||||
const outLinkAuthData = useContextSelector(WorkflowAuthContext, (v) => v.outLinkAuthData);
|
||||
|
||||
const source = useMemo(() => {
|
||||
if (!text) return '';
|
||||
|
|
@ -254,6 +255,32 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
|||
</Flex>
|
||||
);
|
||||
});
|
||||
const RenderPaymentPauseInteractive = React.memo(function RenderPaymentPauseInteractive({
|
||||
interactive
|
||||
}: {
|
||||
interactive: InteractiveBasicType & PaymentPauseInteractive;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return interactive.params.continue ? (
|
||||
<Box>{t('chat:task_has_continued')}</Box>
|
||||
) : (
|
||||
<>
|
||||
<Box color={'myGray.500'}>{t(interactive.params.description)}</Box>
|
||||
<Button
|
||||
maxW={'250px'}
|
||||
onClick={() => {
|
||||
onSendPrompt({
|
||||
text: 'Continue',
|
||||
isInteractivePrompt: true
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('chat:continue_run')}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
const AIResponseBox = ({
|
||||
chatItemDataId,
|
||||
|
|
@ -298,6 +325,9 @@ const AIResponseBox = ({
|
|||
if (finalInteractive.type === 'userInput') {
|
||||
return <RenderUserFormInteractive interactive={finalInteractive} />;
|
||||
}
|
||||
if (finalInteractive.type === 'paymentPause') {
|
||||
return <RenderPaymentPauseInteractive interactive={finalInteractive} />;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { LOGO_ICON } from '@fastgpt/global/common/system/constants';
|
|||
import { getSystemMsgModalData } from '@/web/support/user/inform/api';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { webPushTrack } from '@/web/common/middle/tracks/utils';
|
||||
const Markdown = dynamic(() => import('@/components/Markdown'), { ssr: false });
|
||||
|
||||
const SystemMsgModal = ({}: {}) => {
|
||||
|
|
@ -36,6 +37,11 @@ const SystemMsgModal = ({}: {}) => {
|
|||
const onclickRead = useCallback(() => {
|
||||
if (!data) return;
|
||||
setSysMsgReadId(data.id);
|
||||
|
||||
webPushTrack.readSystemAnnouncement({
|
||||
announcementId: data.id
|
||||
});
|
||||
|
||||
onClose();
|
||||
}, [data, onClose, setSysMsgReadId]);
|
||||
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ const AccountContainer = ({
|
|||
]
|
||||
: []),
|
||||
{
|
||||
icon: 'common/settingLight',
|
||||
label: t('common:Setting'),
|
||||
icon: 'support/usage/usageRecordLight',
|
||||
label: t('account:language'),
|
||||
value: TabEnum.setting
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ import { useRouter } from 'next/router';
|
|||
|
||||
const TeamSelector = ({
|
||||
showManage,
|
||||
showAvatar = true,
|
||||
onChange,
|
||||
...props
|
||||
}: Omit<ButtonProps, 'onChange'> & {
|
||||
showManage?: boolean;
|
||||
showAvatar?: boolean;
|
||||
onChange?: () => void;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -43,7 +45,7 @@ const TeamSelector = ({
|
|||
|
||||
const teamList = useMemo(() => {
|
||||
return myTeams.map((team) => ({
|
||||
icon: team.avatar,
|
||||
...(showAvatar ? { icon: team.avatar } : {}),
|
||||
iconSize: '1.25rem',
|
||||
label: team.teamName,
|
||||
value: team.teamId
|
||||
|
|
|
|||
|
|
@ -1,23 +1,45 @@
|
|||
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { i18nT } from '@fastgpt/web/i18n/utils';
|
||||
|
||||
export const appTypeMap = {
|
||||
[AppTypeEnum.simple]: {
|
||||
icon: 'core/app/simpleBot',
|
||||
title: i18nT('app:type.Create simple bot'),
|
||||
avatar: 'core/app/type/simpleFill',
|
||||
emptyCreateText: i18nT('app:create_empty_app')
|
||||
},
|
||||
export const createAppTypeMap = {
|
||||
[AppTypeEnum.workflow]: {
|
||||
type: AppTypeEnum.workflow,
|
||||
icon: 'core/app/type/workflowFill',
|
||||
avatar: 'core/app/type/workflowFill',
|
||||
title: i18nT('app:type.Create workflow bot'),
|
||||
emptyCreateText: i18nT('app:create_empty_workflow')
|
||||
title: i18nT('app:type.Workflow bot'),
|
||||
intro: i18nT('app:type_workflow_intro'),
|
||||
description: i18nT('app:type_workflow_description'),
|
||||
imgUrl: '/imgs/app/workflowPreview.svg'
|
||||
},
|
||||
[AppTypeEnum.plugin]: {
|
||||
[AppTypeEnum.simple]: {
|
||||
type: AppTypeEnum.simple,
|
||||
icon: 'core/app/simpleBot',
|
||||
title: i18nT('app:type.Chat_Agent'),
|
||||
intro: i18nT('app:type_simple_intro'),
|
||||
description: i18nT('app:type_simple_description'),
|
||||
imgUrl: '/imgs/app/simpleAgentPreview.svg'
|
||||
},
|
||||
[AppTypeEnum.workflowTool]: {
|
||||
type: AppTypeEnum.workflowTool,
|
||||
icon: 'core/app/type/pluginFill',
|
||||
avatar: 'core/app/type/pluginFill',
|
||||
title: i18nT('app:type.Create plugin bot'),
|
||||
emptyCreateText: i18nT('app:create_empty_plugin')
|
||||
title: i18nT('app:toolType_workflow'),
|
||||
intro: i18nT('app:type_plugin_intro'),
|
||||
description: i18nT('app:type_plugin_description'),
|
||||
imgUrl: '/imgs/app/pluginPreview.svg'
|
||||
},
|
||||
[AppTypeEnum.mcpToolSet]: {
|
||||
type: AppTypeEnum.mcpToolSet,
|
||||
icon: 'core/app/type/mcpToolsFill',
|
||||
title: i18nT('app:toolType_mcp'),
|
||||
intro: i18nT('app:type_mcp_intro'),
|
||||
description: i18nT('app:type.Create mcp tools tip'),
|
||||
imgUrl: '/imgs/app/mcpToolsPreview.svg'
|
||||
},
|
||||
[AppTypeEnum.httpToolSet]: {
|
||||
type: AppTypeEnum.httpToolSet,
|
||||
icon: 'core/app/type/httpPluginFill',
|
||||
title: i18nT('app:toolType_http'),
|
||||
intro: i18nT('app:type_http_tool_set_intro'),
|
||||
description: i18nT('app:type.Create http toolset tip'),
|
||||
imgUrl: '/imgs/app/httpToolSetPreview.svg'
|
||||
}
|
||||
};
|
||||
|
|
|
|||