vue-agent-start 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/package.json +30 -0
  2. package/pnpm-workspace.yaml +3 -0
  3. package/src/agent-flow/adapter/backend.ts +99 -0
  4. package/src/agent-flow/components/ChatIframePanel.vue +773 -0
  5. package/src/agent-flow/components/DatasetItemCard.vue +313 -0
  6. package/src/agent-flow/components/MemoryWindow.vue +104 -0
  7. package/src/agent-flow/components/PromptEditor.vue +804 -0
  8. package/src/agent-flow/components/PromptEditorTagPanel.vue +460 -0
  9. package/src/agent-flow/components/SvgIcon.vue +32 -0
  10. package/src/agent-flow/components/ToolItemCard.vue +169 -0
  11. package/src/agent-flow/components/VariableCard.vue +161 -0
  12. package/src/agent-flow/components/VariableSelector.vue +162 -0
  13. package/src/agent-flow/components/chat-iframe-types.ts +35 -0
  14. package/src/agent-flow/components/stubs/DatasetChooser.vue +70 -0
  15. package/src/agent-flow/components/stubs/Embedding.vue +22 -0
  16. package/src/agent-flow/components/stubs/ModelSelect.vue +24 -0
  17. package/src/agent-flow/components/stubs/RestfulSelectCard.vue +24 -0
  18. package/src/agent-flow/components/stubs/ToolChooser.vue +96 -0
  19. package/src/agent-flow/components/stubs/TriggersItemCard.vue +126 -0
  20. package/src/agent-flow/components/stubs/VariableModal.vue +115 -0
  21. package/src/agent-flow/index.ts +73 -0
  22. package/src/agent-flow/stores/workflow.ts +72 -0
  23. package/src/agent-flow/utils/langUtils.ts +173 -0
  24. package/src/agent-flow/workflow/Ability.vue +65 -0
  25. package/src/agent-flow/workflow/AuthorizationItem.vue +101 -0
  26. package/src/agent-flow/workflow/ConversationVar.vue +42 -0
  27. package/src/agent-flow/workflow/CustomEdge.vue +94 -0
  28. package/src/agent-flow/workflow/EnvironmentVar.vue +40 -0
  29. package/src/agent-flow/workflow/FlowDesigner.vue +2802 -0
  30. package/src/agent-flow/workflow/Icon.vue +179 -0
  31. package/src/agent-flow/workflow/NodeConfig.vue +509 -0
  32. package/src/agent-flow/workflow/NodeConfigCard.vue +460 -0
  33. package/src/agent-flow/workflow/NodeHandle.vue +147 -0
  34. package/src/agent-flow/workflow/NodeHeaderToolbar.vue +77 -0
  35. package/src/agent-flow/workflow/NodeHoverToolbar.vue +176 -0
  36. package/src/agent-flow/workflow/OutputItemCard.vue +668 -0
  37. package/src/agent-flow/workflow/ParamTableItem.vue +200 -0
  38. package/src/agent-flow/workflow/StructTable.vue +202 -0
  39. package/src/agent-flow/workflow/VarInsertField.vue +517 -0
  40. package/src/agent-flow/workflow/VarSelectField.vue +223 -0
  41. package/src/agent-flow/workflow/VariableSelectorItem.vue +48 -0
  42. package/src/agent-flow/workflow/WfField.vue +206 -0
  43. package/src/agent-flow/workflow/_config-base.css +470 -0
  44. package/src/agent-flow/workflow/composables/useNode.js +55 -0
  45. package/src/agent-flow/workflow/index.vue +53 -0
  46. package/src/agent-flow/workflow/nodeCard/AgentNodeCard.vue +180 -0
  47. package/src/agent-flow/workflow/nodeCard/AnswerNodeCard.vue +65 -0
  48. package/src/agent-flow/workflow/nodeCard/ClassifierCard.vue +152 -0
  49. package/src/agent-flow/workflow/nodeCard/CodeNodeCard.vue +139 -0
  50. package/src/agent-flow/workflow/nodeCard/ConditionNodeCard.vue +323 -0
  51. package/src/agent-flow/workflow/nodeCard/DocumentExtractorCard.vue +83 -0
  52. package/src/agent-flow/workflow/nodeCard/EndNodeCard.vue +123 -0
  53. package/src/agent-flow/workflow/nodeCard/HttpNodeCard.vue +451 -0
  54. package/src/agent-flow/workflow/nodeCard/HumanInputCard.vue +152 -0
  55. package/src/agent-flow/workflow/nodeCard/IterationCard.vue +66 -0
  56. package/src/agent-flow/workflow/nodeCard/KnowledgeRetrievalCard.vue +48 -0
  57. package/src/agent-flow/workflow/nodeCard/LLMNodeCard.vue +206 -0
  58. package/src/agent-flow/workflow/nodeCard/ListOperatorCard.vue +188 -0
  59. package/src/agent-flow/workflow/nodeCard/ParameterExtractorCard.vue +352 -0
  60. package/src/agent-flow/workflow/nodeCard/ServiceApiNodeCard.vue +188 -0
  61. package/src/agent-flow/workflow/nodeCard/StartNodeCard.vue +216 -0
  62. package/src/agent-flow/workflow/nodeCard/VariableAssignerCard.vue +125 -0
  63. package/src/agent-flow/workflow/nodeCard/VariableNodeCard.vue +121 -0
  64. package/src/agent-flow/workflow/nodes/AgentNode.vue +122 -0
  65. package/src/agent-flow/workflow/nodes/AnswerNode.vue +99 -0
  66. package/src/agent-flow/workflow/nodes/ClassifierNode.vue +199 -0
  67. package/src/agent-flow/workflow/nodes/CodeNode.vue +152 -0
  68. package/src/agent-flow/workflow/nodes/ConditionNode.vue +232 -0
  69. package/src/agent-flow/workflow/nodes/DocumentExtractorNode.vue +96 -0
  70. package/src/agent-flow/workflow/nodes/EndNode.vue +119 -0
  71. package/src/agent-flow/workflow/nodes/FileUploadNode.vue +97 -0
  72. package/src/agent-flow/workflow/nodes/HttpNode.vue +204 -0
  73. package/src/agent-flow/workflow/nodes/HumanInputNode.vue +110 -0
  74. package/src/agent-flow/workflow/nodes/IterationNode.vue +98 -0
  75. package/src/agent-flow/workflow/nodes/KnowledgeRetrievalNode.vue +253 -0
  76. package/src/agent-flow/workflow/nodes/LLMNode.vue +134 -0
  77. package/src/agent-flow/workflow/nodes/ListOperatorNode.vue +111 -0
  78. package/src/agent-flow/workflow/nodes/LoopNode.vue +94 -0
  79. package/src/agent-flow/workflow/nodes/ParameterExtractorNode.vue +147 -0
  80. package/src/agent-flow/workflow/nodes/ServiceApiNode.vue +161 -0
  81. package/src/agent-flow/workflow/nodes/StartNode.vue +199 -0
  82. package/src/agent-flow/workflow/nodes/TemplateNode.vue +103 -0
  83. package/src/agent-flow/workflow/nodes/UserInputNode.vue +92 -0
  84. package/src/agent-flow/workflow/nodes/VariableAssignerNode.vue +145 -0
  85. package/src/agent-flow/workflow/nodes/VariableNode.vue +130 -0
  86. package/src/agent-flow/workflow/nodes/_node-base.css +338 -0
  87. package/src/agent-flow/workflow/utils/node_card_form.ts +335 -0
  88. package/src/agent-flow/workflow/utils/node_config.ts +63 -0
  89. package/src/agent-flow/workflow/utils/workflow_utils.ts +151 -0
  90. package/src/agent-studio/adapters/springAgentStart.ts +390 -0
  91. package/src/agent-studio/api/index.ts +1 -0
  92. package/src/agent-studio/api/types.ts +173 -0
  93. package/src/agent-studio/components/AgentApiDocs.vue +500 -0
  94. package/src/agent-studio/components/AgentAppsPage.vue +1601 -0
  95. package/src/agent-studio/components/AgentCardGrid.vue +259 -0
  96. package/src/agent-studio/components/AgentChatPage.vue +553 -0
  97. package/src/agent-studio/components/AgentDebugPanel.vue +350 -0
  98. package/src/agent-studio/components/AgentLogsPanel.vue +391 -0
  99. package/src/agent-studio/components/AgentMonitorPanel.vue +204 -0
  100. package/src/agent-studio/components/AgentOrchestrate.vue +505 -0
  101. package/src/agent-studio/components/AgentPromptEditor.vue +237 -0
  102. package/src/agent-studio/components/AgentStudioShell.vue +227 -0
  103. package/src/agent-studio/components/AgentToolsPanel.vue +394 -0
  104. package/src/agent-studio/components/AgentVariablesPanel.vue +205 -0
  105. package/src/agent-studio/components/ApiKeyManager.vue +251 -0
  106. package/src/agent-studio/components/AppDesignDrawer.vue +3391 -0
  107. package/src/agent-studio/components/CreateAppModal.vue +737 -0
  108. package/src/agent-studio/components/SparkChart.vue +200 -0
  109. package/src/agent-studio/components/VariableEditorModal.vue +499 -0
  110. package/src/agent-studio/composables/useAgentStudio.ts +347 -0
  111. package/src/agent-studio/index.ts +60 -0
  112. package/src/agent-studio/panels/DrawerFlowDesigner.vue +203 -0
  113. package/src/agent-studio/panels/LogAnnotationPanel.vue +490 -0
  114. package/src/agent-studio/panels/MonitorPanel.vue +535 -0
  115. package/src/agent-studio/types.ts +242 -0
  116. package/src/index.ts +155 -0
  117. package/src/knowledge-hub/adapters/springAgentStart.ts +472 -0
  118. package/src/knowledge-hub/components/AddDocumentsWizard.vue +1452 -0
  119. package/src/knowledge-hub/components/CreateDatasetWizard.vue +1723 -0
  120. package/src/knowledge-hub/components/DatasetCardGrid.vue +467 -0
  121. package/src/knowledge-hub/components/DatasetDetailDrawer.vue +888 -0
  122. package/src/knowledge-hub/components/DatasetPicker.vue +65 -0
  123. package/src/knowledge-hub/components/DatasetPickerModal.vue +526 -0
  124. package/src/knowledge-hub/components/DatasetSettingsPanel.vue +908 -0
  125. package/src/knowledge-hub/components/DatasetSidebar.vue +781 -0
  126. package/src/knowledge-hub/components/DocumentChunksView.vue +802 -0
  127. package/src/knowledge-hub/components/DocumentTable.vue +552 -0
  128. package/src/knowledge-hub/components/HitTestingPanel.vue +74 -0
  129. package/src/knowledge-hub/components/KnowledgeApp.vue +66 -0
  130. package/src/knowledge-hub/components/KnowledgeHubApp.vue +504 -0
  131. package/src/knowledge-hub/components/RecallTestingPanelV2.vue +515 -0
  132. package/src/knowledge-hub/components/RetrievalConfigPopover.vue +270 -0
  133. package/src/knowledge-hub/components/RetrievalMethodPicker.vue +547 -0
  134. package/src/knowledge-hub/components/RetrievedList.vue +24 -0
  135. package/src/knowledge-hub/components/internal/KhDialog.vue +195 -0
  136. package/src/knowledge-hub/composables/useKnowledge.ts +89 -0
  137. package/src/knowledge-hub/i18n/index.ts +2 -0
  138. package/src/knowledge-hub/i18n/messages.ts +422 -0
  139. package/src/knowledge-hub/i18n/useKhI18n.ts +107 -0
  140. package/src/knowledge-hub/index.ts +46 -0
  141. package/src/knowledge-hub/styles/index.css +4 -0
  142. package/src/knowledge-hub/styles/tokens.css +138 -0
  143. package/src/knowledge-hub/types/api.ts +213 -0
  144. package/src/knowledge-hub/types/dataset.ts +88 -0
  145. package/src/knowledge-hub/types/document.ts +45 -0
  146. package/src/knowledge-hub/types/index.ts +9 -0
  147. package/src/knowledge-hub/types/retrieval.ts +46 -0
  148. package/src/provider-hub/components/CredentialForm.vue +103 -0
  149. package/src/provider-hub/components/DefaultModelsPanel.vue +270 -0
  150. package/src/provider-hub/components/GroupedModelSelect.vue +445 -0
  151. package/src/provider-hub/components/ModelCardGrid.vue +332 -0
  152. package/src/provider-hub/components/ModelParameterDrawer.vue +739 -0
  153. package/src/provider-hub/components/ModelPickerPopover.vue +1282 -0
  154. package/src/provider-hub/components/ProviderApp.vue +159 -0
  155. package/src/provider-hub/components/ProviderCredentialModal.vue +321 -0
  156. package/src/provider-hub/components/ProviderGallery.vue +131 -0
  157. package/src/provider-hub/components/ProviderHubShell.vue +1992 -0
  158. package/src/provider-hub/components/ProviderIcon.vue +130 -0
  159. package/src/provider-hub/composables/useProviderHub.ts +358 -0
  160. package/src/provider-hub/index.ts +43 -0
  161. package/src/provider-hub/svg/MiniMax.svg +1 -0
  162. package/src/provider-hub/svg/Volcengine.svg +1 -0
  163. package/src/provider-hub/svg/Zhipu.svg +1 -0
  164. package/src/provider-hub/svg/deepseek.svg +1 -0
  165. package/src/provider-hub/svg/moonshot.svg +1 -0
  166. package/src/provider-hub/svg/openai.svg +1 -0
  167. package/src/provider-hub/svg/qwen.svg +1 -0
  168. package/src/provider-hub/svg/siliconflow.svg +1 -0
  169. package/src/provider-hub/types.ts +256 -0
@@ -0,0 +1,126 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+
4
+ import {
5
+ ApiOutlined,
6
+ ClockCircleOutlined,
7
+ ThunderboltOutlined,
8
+ } from '@ant-design/icons-vue';
9
+
10
+ /**
11
+ * 触发器基础实现:只提供开关 + 类型选择。
12
+ * 具体每种触发器的详细配置(HTTP 端点、cron 表达式、webhook 密钥等)应由宿主
13
+ * 组件替换本 stub 实现。
14
+ */
15
+
16
+ const formState: any = defineModel();
17
+
18
+ const TRIGGERS = [
19
+ { key: 'http', label: 'HTTP 请求', icon: ApiOutlined, color: '#06b6d4' },
20
+ { key: 'schedule', label: '定时', icon: ClockCircleOutlined, color: '#f59e0b' },
21
+ { key: 'webhook', label: 'Webhook', icon: ThunderboltOutlined, color: '#8b5cf6' },
22
+ ];
23
+
24
+ const enabled = computed({
25
+ get: () => formState.value?.triggersEnabled ?? false,
26
+ set: (v: boolean) => (formState.value.triggersEnabled = v),
27
+ });
28
+
29
+ const currentType = computed({
30
+ get: () => formState.value?.triggers?.type ?? 'http',
31
+ set: (v: string) => {
32
+ if (!formState.value.triggers) formState.value.triggers = { type: v };
33
+ else formState.value.triggers.type = v;
34
+ },
35
+ });
36
+ </script>
37
+
38
+ <template>
39
+ <div class="wf-triggers">
40
+ <div class="wf-triggers-toggle">
41
+ <span>启用触发器</span>
42
+ <a-switch v-model:checked="enabled" size="small" />
43
+ </div>
44
+
45
+ <div v-if="enabled" class="wf-triggers-types">
46
+ <div
47
+ v-for="t in TRIGGERS"
48
+ :key="t.key"
49
+ class="wf-triggers-type"
50
+ :class="{ 'is-active': currentType === t.key }"
51
+ :style="{ '--tc': t.color }"
52
+ @click="currentType = t.key"
53
+ >
54
+ <component :is="t.icon" class="wf-triggers-type-icon" />
55
+ <span>{{ t.label }}</span>
56
+ </div>
57
+ </div>
58
+
59
+ <div v-if="enabled" class="wf-triggers-hint">
60
+ 触发器详细配置由宿主项目提供。
61
+ </div>
62
+ </div>
63
+ </template>
64
+
65
+ <style scoped>
66
+ .wf-triggers {
67
+ display: flex;
68
+ flex-direction: column;
69
+ gap: 8px;
70
+ }
71
+
72
+ .wf-triggers-toggle {
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: space-between;
76
+ padding: 6px 10px;
77
+ background: #f9fafb;
78
+ border-radius: 6px;
79
+ font-size: 12px;
80
+ color: #4b5563;
81
+ }
82
+
83
+ .wf-triggers-types {
84
+ display: grid;
85
+ grid-template-columns: repeat(3, 1fr);
86
+ gap: 6px;
87
+ }
88
+
89
+ .wf-triggers-type {
90
+ display: flex;
91
+ flex-direction: column;
92
+ align-items: center;
93
+ gap: 4px;
94
+ padding: 10px 6px;
95
+ background: #ffffff;
96
+ border: 1px solid #e5e7eb;
97
+ border-radius: 6px;
98
+ cursor: pointer;
99
+ transition: border-color 0.15s, background 0.15s;
100
+ color: #4b5563;
101
+ font-size: 11px;
102
+ }
103
+
104
+ .wf-triggers-type:hover {
105
+ border-color: var(--tc);
106
+ }
107
+
108
+ .wf-triggers-type.is-active {
109
+ background: color-mix(in srgb, var(--tc) 10%, transparent);
110
+ border-color: var(--tc);
111
+ color: var(--tc);
112
+ }
113
+
114
+ .wf-triggers-type-icon {
115
+ font-size: 18px;
116
+ color: var(--tc);
117
+ }
118
+
119
+ .wf-triggers-hint {
120
+ padding: 6px 10px;
121
+ font-size: 11px;
122
+ color: #92400e;
123
+ background: #fef3c7;
124
+ border-radius: 4px;
125
+ }
126
+ </style>
@@ -0,0 +1,115 @@
1
+ <script setup lang="ts">
2
+ import { reactive, ref } from 'vue';
3
+
4
+ /**
5
+ * 输入变量编辑模态框
6
+ *
7
+ * 这是 @agent-start/agent-flow 内置的基础实现,覆盖了新增/编辑一个变量的
8
+ * 常见字段(name / label / type / required / description / default)。
9
+ * 宿主项目可通过 `app.component('VariableModal', RealVariableModal)`
10
+ * 全局替换为自己更强大的实现。
11
+ *
12
+ * 用法:`variableModalRef.value.showModal(item?)` —— 编辑传 item、新增
13
+ * 传 undefined / {}。之前用 :main-data prop + 同步 showModal() 的写法会
14
+ * 撞上 Vue 的父→子 prop 传递需要一个 tick 才刷新的时序问题,导致:
15
+ * · 第一次点编辑:表单不带出数据(读到的还是初始 prop)
16
+ * · 再点一次:终于带出上一次的数据
17
+ * · 第一次点新增:错带出上一次编辑/新增的数据
18
+ * 现在直接把要展示的对象作为参数传进来,就地写进 form,避免绕一圈 prop
19
+ * 更新,多快好省。
20
+ */
21
+
22
+ const TYPES = [
23
+ { value: 'string', label: 'String' },
24
+ { value: 'number', label: 'Number' },
25
+ { value: 'boolean', label: 'Boolean' },
26
+ { value: 'array', label: 'Array' },
27
+ { value: 'object', label: 'Object' },
28
+ { value: 'file', label: 'File' },
29
+ ];
30
+
31
+ // 保留 mainData prop 只为向后兼容宿主项目里可能存在的老用法;showModal(item)
32
+ // 传参会覆盖它。新代码不要再依赖 :main-data。
33
+ const props = defineProps<{ mainData?: any }>();
34
+ const emit = defineEmits<{ (e: 'formSubmit', v: any): void }>();
35
+
36
+ const open = ref(false);
37
+ const form = reactive<any>({
38
+ id: undefined,
39
+ name: '',
40
+ label: '',
41
+ type: 'string',
42
+ required: false,
43
+ description: '',
44
+ defaultValue: '',
45
+ });
46
+
47
+ function resetForm(src: any) {
48
+ form.id = src.id;
49
+ form.name = src.name || '';
50
+ form.label = src.label || '';
51
+ form.type = src.type || 'string';
52
+ form.required = !!src.required;
53
+ form.description = src.description || '';
54
+ form.defaultValue = src.defaultValue ?? '';
55
+ }
56
+
57
+ function showModal(item?: any) {
58
+ // 优先使用调用方直接传入的 item,回退到 mainData(老 API),最后 {}。
59
+ const src = item ?? props.mainData ?? {};
60
+ resetForm(src);
61
+ open.value = true;
62
+ }
63
+
64
+ function hideModal() {
65
+ open.value = false;
66
+ }
67
+
68
+ function submit() {
69
+ emit('formSubmit', { ...form });
70
+ open.value = false;
71
+ }
72
+
73
+ defineExpose({ showModal, hideModal });
74
+ </script>
75
+
76
+ <template>
77
+ <a-modal
78
+ v-model:open="open"
79
+ :title="form.id ? '编辑输入变量' : '新增输入变量'"
80
+ width="480px"
81
+ :ok-text="form.id ? '保存' : '添加'"
82
+ cancel-text="取消"
83
+ @ok="submit"
84
+ >
85
+ <a-form
86
+ layout="vertical"
87
+ :model="form"
88
+ autocomplete="off"
89
+ style="padding-top: 8px"
90
+ >
91
+ <a-form-item label="变量名" required>
92
+ <a-input v-model:value="form.name" placeholder="例如 query" />
93
+ </a-form-item>
94
+ <a-form-item label="显示名">
95
+ <a-input v-model:value="form.label" placeholder="用户看到的中文标题" />
96
+ </a-form-item>
97
+ <a-form-item label="类型">
98
+ <a-select v-model:value="form.type" :options="TYPES" />
99
+ </a-form-item>
100
+ <a-form-item label="默认值">
101
+ <a-input v-model:value="form.defaultValue" placeholder="留空表示无默认值" />
102
+ </a-form-item>
103
+ <a-form-item label="描述">
104
+ <a-textarea
105
+ v-model:value="form.description"
106
+ placeholder="给填写者的说明"
107
+ :auto-size="{ minRows: 2, maxRows: 4 }"
108
+ />
109
+ </a-form-item>
110
+ <a-form-item>
111
+ <a-checkbox v-model:checked="form.required">必填</a-checkbox>
112
+ </a-form-item>
113
+ </a-form>
114
+ </a-modal>
115
+ </template>
@@ -0,0 +1,73 @@
1
+ import type { App } from 'vue';
2
+
3
+ import FlowDesigner from './workflow/FlowDesigner.vue';
4
+ import NodeConfig from './workflow/NodeConfig.vue';
5
+ import NodeConfigCard from './workflow/NodeConfigCard.vue';
6
+ import CustomEdge from './workflow/CustomEdge.vue';
7
+ import NodeHandle from './workflow/NodeHandle.vue';
8
+ import Icon from './workflow/Icon.vue';
9
+ import ChatIframePanel from './components/ChatIframePanel.vue';
10
+
11
+ import { useWorkflowStore } from './stores/workflow';
12
+ import { provideBackend, type BackendAdapter } from './adapter/backend';
13
+
14
+ import nodeCatalog from './workflow/utils/node_config';
15
+ import nodeCardForm from './workflow/utils/node_card_form';
16
+ import workflowUtils from './workflow/utils/workflow_utils';
17
+
18
+ export {
19
+ FlowDesigner,
20
+ NodeConfig,
21
+ NodeConfigCard,
22
+ CustomEdge,
23
+ NodeHandle,
24
+ Icon,
25
+ ChatIframePanel,
26
+ useWorkflowStore,
27
+ provideBackend,
28
+ nodeCatalog,
29
+ nodeCardForm,
30
+ workflowUtils,
31
+ };
32
+
33
+ export type { BackendAdapter } from './adapter/backend';
34
+ export type {
35
+ ChatDebugVariable,
36
+ ChatIframeConfig,
37
+ } from './components/chat-iframe-types';
38
+
39
+ export interface AgentFlowInstallOptions {
40
+ /** 后端 API 适配器;不传则使用内置 no-op(所有请求返回空数据) */
41
+ backend?: BackendAdapter;
42
+ /** 全局注册核心组件(默认 true) */
43
+ registerGlobal?: boolean;
44
+ }
45
+
46
+ /**
47
+ * Vue 插件形式安装。
48
+ *
49
+ * @example
50
+ * import { createApp } from 'vue';
51
+ * import AgentFlow from '@agent-start/agent-flow';
52
+ * import '@agent-start/agent-flow/style.css';
53
+ *
54
+ * const app = createApp(App);
55
+ * app.use(AgentFlow, {
56
+ * backend: {
57
+ * getCurrentModel: (t) => http.post(`/model/current/${t}`),
58
+ * getWorkflow: (q) => http.get('/workflow', { params: q }),
59
+ * publishWorkflow: (p) => http.post('/workflow/publish', p),
60
+ * },
61
+ * });
62
+ */
63
+ export default {
64
+ install(app: App, options: AgentFlowInstallOptions = {}) {
65
+ if (options.backend) {
66
+ provideBackend(app, options.backend);
67
+ }
68
+ if (options.registerGlobal !== false) {
69
+ app.component('FlowDesigner', FlowDesigner);
70
+ app.component('NodeConfigCard', NodeConfigCard);
71
+ }
72
+ },
73
+ };
@@ -0,0 +1,72 @@
1
+ import { defineStore } from 'pinia';
2
+
3
+ interface WorkflowState {
4
+ graph: any; // 字典数据缓存
5
+ selectDataCache: any; // 下拉数据缓存
6
+ }
7
+ export const useWorkflowStore = defineStore('workflow', {
8
+ state: (): WorkflowState => ({
9
+ graph: {},
10
+ selectDataCache: {},
11
+ }),
12
+ getters: {},
13
+ actions: {
14
+ setGraph(graph: any) {
15
+ this.graph = graph;
16
+ },
17
+ getNodes() {
18
+ return this.graph.nodes;
19
+ },
20
+ getStartNode() {
21
+ return this.getNodeById('1');
22
+ },
23
+ getStartNodeVariable() {
24
+ const startNode: any = this.getStartNode();
25
+ const data = startNode.data;
26
+ const items: any = [];
27
+ if (data.triggersEnabled) {
28
+ const triggers = data.structOutput.data;
29
+ items.push(...triggers);
30
+ } else {
31
+ items.push({
32
+ type: 'string',
33
+ name: 'query',
34
+ value: '',
35
+ label: '用户查询',
36
+ });
37
+ }
38
+ return items;
39
+ },
40
+ getNodeById(id: string) {
41
+ const nodes = this.graph.nodes;
42
+ for (const node of nodes) {
43
+ if (node.id === id) {
44
+ return node;
45
+ }
46
+ }
47
+ return {};
48
+ },
49
+ getParentNodeList(nodeId: string, items: any = []) {
50
+ const edges = this.graph.edges || [];
51
+ const parentEdges = edges.filter((edge: any) => edge.target === nodeId);
52
+ parentEdges.forEach((edge: any) => {
53
+ const parentNode = this.getNodeById(edge.source);
54
+ if (
55
+ parentNode &&
56
+ !items.some((item: any) => item.id === parentNode.id)
57
+ ) {
58
+ items.unshift(parentNode);
59
+ this.getParentNodeList(parentNode.id, items);
60
+ }
61
+ });
62
+ return items;
63
+ },
64
+ getOutputItemsTree(nodeId: string, items: any = []) {
65
+ const nodeList = this.getParentNodeList(nodeId);
66
+ for (const node of nodeList) {
67
+ const output = node.data.output;
68
+ items.push(this.getNodeById(node));
69
+ }
70
+ },
71
+ },
72
+ });
@@ -0,0 +1,173 @@
1
+ import { createVNode } from 'vue';
2
+
3
+ import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
4
+ import { message, Modal } from 'ant-design-vue';
5
+
6
+ const config = { hostname: '' };
7
+
8
+ export default {
9
+ getId(str: never | string = ''): string {
10
+ if (!str) {
11
+ str = '';
12
+ }
13
+ // 取时间戳后6位 + 3位随机数
14
+ return `${str}_${Date.now().toString().slice(-6)}${Math.random().toString(36).slice(-3)}`;
15
+ },
16
+ getResponseImageUri(datas: any): string {
17
+ if (datas) {
18
+ const data = datas[0];
19
+ return `${data.bucketName}/${data.objectName}`;
20
+ }
21
+ return '';
22
+ },
23
+ getImageUrl(str: never | string = ''): string {
24
+ if (str) {
25
+ if (str.includes('data:image/')) {
26
+ return str;
27
+ }
28
+ if (str.startsWith('http://') || str.startsWith('https://')) {
29
+ return str;
30
+ }
31
+ return `/api/agent-start/storage/file/${str}`;
32
+ }
33
+ return '';
34
+ },
35
+ getQueryString(name: string) {
36
+ const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`, 'i');
37
+ const r = window.location.search.slice(1).match(reg);
38
+ if (r) {
39
+ return unescape(r[2]);
40
+ }
41
+ return null;
42
+ },
43
+ message(ar: any) {
44
+ if (ar.error) {
45
+ this.error(ar.message);
46
+ return false;
47
+ } else if (ar.success) {
48
+ this.info(ar.message);
49
+ return true;
50
+ } else {
51
+ this.warn(ar.message);
52
+ return false;
53
+ }
54
+ },
55
+ info(msg: any) {
56
+ if (!msg) {
57
+ msg = '完成';
58
+ }
59
+ message.info(msg);
60
+ },
61
+ warn(msg: any) {
62
+ message.warning(msg);
63
+ },
64
+ error(msg: any) {
65
+ message.error(msg);
66
+ },
67
+ confirm(prop: any, ok?: any, cancel?: any) {
68
+ prop = prop || {};
69
+ Modal.confirm({
70
+ title: prop.title || '确定要继续操作吗?',
71
+ icon: createVNode(ExclamationCircleOutlined),
72
+ content: createVNode(
73
+ 'div',
74
+ {
75
+ style: 'color:red;',
76
+ },
77
+ prop.message || '',
78
+ ),
79
+ onOk() {
80
+ if (ok) {
81
+ ok();
82
+ }
83
+ },
84
+ onCancel() {
85
+ if (cancel) {
86
+ cancel();
87
+ }
88
+ },
89
+ class: 'test',
90
+ });
91
+ },
92
+ copy(from: any, to: any) {
93
+ for (const attr in from) {
94
+ // eslint-disable-next-line eqeqeq
95
+ if (from[attr] !== null || from[attr] != undefined) {
96
+ to[attr] = from[attr];
97
+ }
98
+ }
99
+ },
100
+ clone(obj: any) {
101
+ let o: any;
102
+ switch (typeof obj) {
103
+ case 'boolean': {
104
+ o = obj;
105
+ break;
106
+ }
107
+ case 'number': {
108
+ o = obj - 0;
109
+ break;
110
+ }
111
+ case 'object': {
112
+ if (obj === null) {
113
+ o = null;
114
+ } else {
115
+ if (Array.isArray(obj)) {
116
+ o = [];
117
+ for (let i = 0, len = obj.length; i < len; i++) {
118
+ o.push(this.clone(obj[i]));
119
+ }
120
+ } else {
121
+ o = {};
122
+ for (const k in obj) {
123
+ o[k] = this.clone(obj[k]);
124
+ }
125
+ }
126
+ }
127
+ break;
128
+ }
129
+ case 'string': {
130
+ o = `${obj}`;
131
+ break;
132
+ }
133
+ case 'undefined': {
134
+ break;
135
+ }
136
+ default: {
137
+ o = obj;
138
+ break;
139
+ }
140
+ }
141
+ return o;
142
+ },
143
+ buildTreeData(data: any, rootId: string) {
144
+ if (!data) {
145
+ return [];
146
+ }
147
+ if (!rootId) {
148
+ rootId = '0';
149
+ }
150
+ const jsonstr = JSON.stringify(data);
151
+ const cloneData = JSON.parse(jsonstr);
152
+ const newData = cloneData.filter((father: any) => {
153
+ const branchArr = cloneData.filter(
154
+ (child) => father.id === child.parentId,
155
+ );
156
+ if (branchArr.length > 0) {
157
+ father.children = branchArr;
158
+ } else {
159
+ father.children = [];
160
+ father.isLeaf = true; // 设置为叶子节点
161
+ }
162
+ return father.parentId === rootId;
163
+ });
164
+ return newData.length > 0 ? newData : cloneData;
165
+ },
166
+ cdn(url: string) {
167
+ if (!url) return '';
168
+ if (url.indexOf('http') === 0) {
169
+ return url;
170
+ }
171
+ return config.hostname + url;
172
+ },
173
+ };
@@ -0,0 +1,65 @@
1
+ <script setup lang="ts">
2
+ import { h, reactive } from 'vue';
3
+
4
+ import { PlusOutlined } from '@ant-design/icons-vue';
5
+
6
+ const formState = reactive<any>({
7
+ prologue: '',
8
+ context: '',
9
+ system: '',
10
+ selectOptions: [],
11
+ required: false,
12
+ memory: { windows: 1 },
13
+ });
14
+ </script>
15
+
16
+ <template>
17
+ <div>
18
+ <div>
19
+ <div>
20
+ <div>对话开场白</div>
21
+ <div></div>
22
+ <div><a-switch v-model:checked="formState.prologue" /></div>
23
+ </div>
24
+ <div>在对话型应用中,让 AI 主动说第一段话可以拉近与用户间的距离。</div>
25
+ <div>
26
+ <a-button :icon="h(PlusOutlined)" size="small">编辑开场白</a-button>
27
+ </div>
28
+ </div>
29
+ <div>
30
+ <div>
31
+ <div>下一步问题建议</div>
32
+ <div></div>
33
+ <div><a-switch v-model:checked="formState.prologue" /></div>
34
+ </div>
35
+ <div>设置下一步问题建议可以让用户更好的对话。</div>
36
+ <div>
37
+ <a-button :icon="h(PlusOutlined)" size="small">编辑开场白</a-button>
38
+ </div>
39
+ </div>
40
+ <div>
41
+ <div>
42
+ <div>引用和归属</div>
43
+ <div></div>
44
+ <div><a-switch v-model:checked="formState.prologue" /></div>
45
+ </div>
46
+ <div>显示源文档和生成内容的归属部分。</div>
47
+ <div>
48
+ <a-button :icon="h(PlusOutlined)" size="small">编辑开场白</a-button>
49
+ </div>
50
+ </div>
51
+ <div>
52
+ <div>
53
+ <div>内容审查</div>
54
+ <div></div>
55
+ <div><a-switch v-model:checked="formState.prologue" /></div>
56
+ </div>
57
+ <div>您可以调用审查 API 或者维护敏感词库来使模型更安全地输出</div>
58
+ <div>
59
+ <a-button :icon="h(PlusOutlined)" size="small">编辑开场白</a-button>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ </template>
64
+
65
+ <style scoped></style>