Skip to content

Commit ea39870

Browse files
committed
fix: ai plugin text and ui and upgrade robot version
1 parent 7b38576 commit ea39870

File tree

12 files changed

+65
-110
lines changed

12 files changed

+65
-110
lines changed

packages/common/js/completion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ const fetchAiInlineCompletion = (codeBeforeCursor, codeAfterCursor) => {
218218
{
219219
headers: {
220220
'Content-Type': 'application/json',
221-
Authorization: `Bearer ${apiKey}`
221+
Authorization: `Bearer ${apiKey || ''}`
222222
}
223223
}
224224
)

packages/plugins/robot/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
"@opentiny/tiny-engine-meta-register": "workspace:*",
2929
"@opentiny/tiny-engine-common": "workspace:*",
3030
"@opentiny/tiny-engine-utils": "workspace:*",
31-
"@opentiny/tiny-robot": "0.3.0-rc.0",
32-
"@opentiny/tiny-robot-kit": "0.3.0-rc.0",
33-
"@opentiny/tiny-robot-svgs": "0.3.0-rc.0",
31+
"@opentiny/tiny-robot": "0.3.0-rc.5",
32+
"@opentiny/tiny-robot-kit": "0.3.0-rc.5",
33+
"@opentiny/tiny-robot-svgs": "0.3.0-rc.5",
3434
"@opentiny/tiny-schema-renderer": "1.0.0-beta.6",
3535
"fast-json-patch": "~3.1.1",
3636
"dompurify": "^3.0.1",

packages/plugins/robot/src/Main.vue

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
class="footer-sender"
6969
ref="senderRef"
7070
v-model="inputContent"
71-
placeholder="请输入问题或“/”唤起指令,支持粘贴文档"
71+
placeholder="请输入您的问题"
7272
:clearable="true"
7373
:showWordLimit="true"
74-
:allowFiles="singleAttachmentItems.length < 1 && isVisualModel() && aiType === AI_MODES['Builder']"
74+
:allowFiles="singleAttachmentItems.length < 1 && isVisualModel() && aiType === AI_MODES.Agent"
7575
uploadTooltip="支持上传1张图片"
7676
@submit="sendContent(inputContent, false)"
7777
@files-selected="handleSingleFilesSelected"
@@ -91,7 +91,7 @@
9191
</template>
9292
<template #footer-left>
9393
<robot-type-select :aiType="aiType" @typeChange="typeChange"></robot-type-select>
94-
<mcp-server :position="mcpDrawerPosition" v-if="aiType === AI_MODES['Chat']"></mcp-server>
94+
<mcp-server :position="mcpDrawerPosition" v-if="aiType === AI_MODES.Chat"></mcp-server>
9595
</template>
9696
</tr-sender>
9797
</template>
@@ -106,18 +106,7 @@
106106

107107
<script lang="ts">
108108
/* metaService: engine.plugins.robot.Main */
109-
import {
110-
ref,
111-
onMounted,
112-
watchEffect,
113-
type CSSProperties,
114-
h,
115-
resolveComponent,
116-
computed,
117-
watch,
118-
nextTick,
119-
type Component
120-
} from 'vue'
109+
import { ref, onMounted, type CSSProperties, h, resolveComponent, computed, watch, nextTick, type Component } from 'vue'
121110
import { Notify, Loading, TinyPopover, TinyDialogBox } from '@opentiny/vue'
122111
import {
123112
useRobot,
@@ -152,9 +141,9 @@ import LoadingRenderer from './mcp/LoadingRenderer.vue'
152141
import { sendMcpRequest, serializeError } from './mcp/utils'
153142
import type { RobotMessage } from './mcp/types'
154143
import RobotTypeSelect from './RobotTypeSelect.vue'
155-
import McpIconComponent from './icon-prompt/mcp-icon.vue'
156-
import PageIconComponent from './icon-prompt/page-icon.vue'
157-
import StudyIconComponent from './icon-prompt/study-icon.vue'
144+
import McpIconComponent from './icons/mcp-icon.vue'
145+
import PageIconComponent from './icons/page-icon.vue'
146+
import StudyIconComponent from './icons/study-icon.vue'
158147
import { jsonrepair } from 'jsonrepair'
159148
160149
export default {
@@ -183,19 +172,11 @@ export default {
183172
},
184173
emits: ['close-chat'],
185174
setup() {
186-
const {
187-
getBlockContent,
188-
initBlockList,
189-
getAIModelOptions,
190-
isValidFastJsonPatch,
191-
VISUAL_MODEL,
192-
AI_MODES,
193-
robotSettingState
194-
} = useRobot()
175+
const { getBlockContent, initBlockList, getAIModelOptions, isValidFastJsonPatch, AI_MODES, robotSettingState } =
176+
useRobot()
195177
const { pageState, importSchema, setSaved } = useCanvas()
196178
const AIModelOptions = getAIModelOptions()
197179
const robotVisible = ref(false)
198-
const avatarUrl = ref('')
199180
const chatWindowOpened = ref(true)
200181
let sessionProcess = null
201182
const messages = ref<RobotMessage[]>([])
@@ -211,14 +192,11 @@ export default {
211192
const singleAttachmentItems = ref([])
212193
const imageUrl = ref('')
213194
const MESSAGE_TIP = '已生成新的页面效果。'
214-
const aiType = ref(AI_MODES['Chat'])
195+
const aiType = ref(AI_MODES.Agent)
215196
const chatContainerRef = ref(null)
216197
const showTeleport = ref(false)
217198
const { deepClone, string2Obj, reactiveObj2String: obj2String } = utils
218199
const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
219-
watchEffect(() => {
220-
avatarUrl.value = 'img/defaultAvator.png'
221-
})
222200
223201
const setContextSession = () => {
224202
localStorage.setItem(
@@ -261,7 +239,7 @@ export default {
261239
const sendProcess = { ...sessionProcess }
262240
const firstMessage = sendProcess.messages[0]
263241
let firstContent = firstMessage.content
264-
if (aiType.value === AI_MODES['Builder']) {
242+
if (aiType.value === AI_MODES.Agent) {
265243
firstContent = firstMessage.content.map((item) => {
266244
if (item.type === 'text') {
267245
item.text = `[指令] ${PROMPTS}\n[知识] ${searchContent.value}\n[当前schema] ${JSON.stringify(
@@ -271,7 +249,7 @@ export default {
271249
return item
272250
})
273251
}
274-
if (useMcpServer().isToolsEnabled && aiType.value === AI_MODES['Chat']) {
252+
if (useMcpServer().isToolsEnabled && aiType.value === AI_MODES.Chat) {
275253
firstContent = `${getBlockContent()}\n${codeRules}\n${firstMessage.content[0]?.text || ''}`
276254
}
277255
@@ -314,7 +292,7 @@ export default {
314292
// 处理响应
315293
const handleResponse = ({ id, chatMessage }: { id: string; chatMessage: any }, currentJson) => {
316294
try {
317-
if (aiType.value === AI_MODES['Builder']) {
295+
if (aiType.value === AI_MODES.Agent) {
318296
const regex = /```json([\s\S]*?)```/
319297
const match = chatMessage?.content.match(regex)
320298
@@ -338,7 +316,7 @@ export default {
338316
inProcesing.value = false
339317
connectedFailed.value = false
340318
}
341-
if (aiType.value === AI_MODES['Chat']) {
319+
if (aiType.value === AI_MODES.Chat) {
342320
sessionProcess.messages.push(getAiRespMessage(chatMessage?.content))
343321
sessionProcess.displayMessages.push(getAiRespMessage(chatMessage?.content))
344322
messages.value[messages.value.length - 1].content = chatMessage?.content
@@ -354,14 +332,14 @@ export default {
354332
// 发送流式请求
355333
const sendStreamRequest = async () => {
356334
const requestData = getSendSeesionProcess()
357-
if (useMcpServer().isToolsEnabled && aiType.value === AI_MODES['Chat']) {
335+
if (useMcpServer().isToolsEnabled && aiType.value === AI_MODES.Chat) {
358336
try {
359337
requestLoading.value = true
360338
await scrollContent()
361339
await sendMcpRequest(messages.value, {
362340
model: robotSettingState.selectedModel.model,
363341
headers: {
364-
Authorization: `Bearer ${robotSettingState.selectedModel.apiKey || import.meta.env.VITE_API_TOKEN}`
342+
Authorization: `Bearer ${robotSettingState.selectedModel.apiKey || import.meta.env.VITE_API_TOKEN || ''}`
365343
},
366344
baseUrl: robotSettingState.selectedModel.baseUrl
367345
})
@@ -459,7 +437,7 @@ export default {
459437
}
460438
},
461439
{
462-
Authorization: `Bearer ${robotSettingState.selectedModel.apiKey || import.meta.env.VITE_API_TOKEN}`
440+
Authorization: `Bearer ${robotSettingState.selectedModel.apiKey || import.meta.env.VITE_API_TOKEN || ''}`
463441
}
464442
)
465443
}
@@ -500,7 +478,7 @@ export default {
500478
text
501479
}
502480
]
503-
if (singleAttachmentItems.value.length > 0 && aiType.value === AI_MODES['Builder']) {
481+
if (singleAttachmentItems.value.length > 0 && aiType.value === AI_MODES.Agent) {
504482
content.push({
505483
type: 'image_url',
506484
image_url: {
@@ -530,7 +508,7 @@ export default {
530508
if (chatWindowOpened.value === false) {
531509
await resizeChatWindow()
532510
}
533-
if (!sessionProcess?.messages?.length && aiType.value !== AI_MODES['Chat']) {
511+
if (!sessionProcess?.messages?.length && aiType.value !== AI_MODES.Chat) {
534512
sessionProcess?.messages.push({
535513
role: 'system',
536514
content: [
@@ -546,7 +524,7 @@ export default {
546524
messages.value.push(message)
547525
sessionProcess?.messages.push(getSessionMessage(realContent))
548526
sessionProcess?.displayMessages.push(message)
549-
if (aiType.value === AI_MODES['Builder'] && (!searchContent.value || !sessionProcess.messages?.length)) {
527+
if (aiType.value === AI_MODES.Agent && (!searchContent.value || !sessionProcess.messages?.length)) {
550528
await search(realContent)
551529
}
552530
@@ -805,7 +783,6 @@ export default {
805783
return {
806784
chatContainerRef,
807785
robotVisible,
808-
avatarUrl,
809786
chatWindowOpened,
810787
activeMessages,
811788
inputContent,
@@ -819,7 +796,6 @@ export default {
819796
currentSchema,
820797
showPreview,
821798
singleAttachmentItems,
822-
VISUAL_MODEL,
823799
promptItems,
824800
MarkdownRenderer,
825801
requestLoading,
@@ -880,6 +856,7 @@ export default {
880856
--tr-container-width: 400px;
881857
position: relative;
882858
height: 100%;
859+
border: 1px solid var(--te-layout-common-border-color);
883860
.tr-container__dragging-bar {
884861
display: none;
885862
}

packages/plugins/robot/src/RobotSettingPopover.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@
2525
placeholder="请选择"
2626
></tiny-select>
2727
</tiny-form-item>
28-
<tiny-form-item prop="completeModel" label="补全模型名称" label-width="150px">
28+
<tiny-form-item prop="completeModel" label-width="150px">
29+
<template #label>
30+
补全模型名称
31+
<tiny-tooltip
32+
effect="light"
33+
content="页面JS插件代码补全使用的AI模型。建议选择小模型以实现更快的补全速度,例如8b或14b。"
34+
placement="top"
35+
>
36+
<svg-icon class="help-link" name="plugin-icon-plugin-help"></svg-icon>
37+
</tiny-tooltip>
38+
</template>
2939
<tiny-select
3040
v-model="state.existFormData.completeModel"
3141
:options="state.modelOptions"
@@ -62,7 +72,17 @@
6272
<tiny-form-item prop="model" label="模型名称" label-width="150px">
6373
<tiny-input class="filedName" v-model="state.customizeFormData.model" placeholder="请输入"></tiny-input>
6474
</tiny-form-item>
65-
<tiny-form-item prop="completeModel" label="补全模型名称" label-width="150px">
75+
<tiny-form-item prop="completeModel" label-width="150px">
76+
<template #label>
77+
补全模型名称
78+
<tiny-tooltip
79+
effect="light"
80+
content="页面JS插件代码补全使用的AI模型。建议选择小模型以实现更快的补全速度,例如8b或14b。"
81+
placement="top"
82+
>
83+
<svg-icon class="help-link" name="plugin-icon-plugin-help"></svg-icon>
84+
</tiny-tooltip>
85+
</template>
6686
<tiny-input
6787
class="filedName"
6888
v-model="state.customizeFormData.completeModel"

packages/plugins/robot/src/RobotTypeSelect.vue

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
<template>
22
<div class="button-wrapper">
33
<tiny-tabs v-model="state.activeNameTabs" tab-style="button-card">
4-
<tiny-tab-item class="json-tab" :name="AI_MODES['Chat']">
4+
<tiny-tab-item :name="AI_MODES.Agent">
55
<template #title>
6-
<tiny-tooltip effect="light" content="对话">
6+
<tiny-tooltip effect="light">
77
<template #content>
88
<div class="tip-cantainer">
99
<div>
10-
<svg-icon name="chat" class="tip-common_icon"></svg-icon>
10+
<svg-icon name="intelligent-construction" class="tip-common_icon"></svg-icon>
1111
</div>
1212
<div class="tips">
13-
<div class="tip-header">对话</div>
14-
<div class="tip-content">回答日常问题或在开始任务前进行对话。</div>
13+
<div class="tip-header">Agent</div>
14+
<div class="tip-content">根据描述文案或图片自动搭建对应的页面。</div>
1515
</div>
1616
</div>
1717
</template>
18-
<svg-icon name="chat" class="plugin-common_icon"></svg-icon>
18+
<svg-icon name="intelligent-construction" class="plugin-common_icon"></svg-icon>
1919
</tiny-tooltip>
2020
</template>
2121
</tiny-tab-item>
22-
<tiny-tab-item :name="AI_MODES['Builder']">
22+
<tiny-tab-item class="json-tab" :name="AI_MODES.Chat">
2323
<template #title>
24-
<tiny-tooltip effect="light" content="智能搭建">
24+
<tiny-tooltip effect="light">
2525
<template #content>
2626
<div class="tip-cantainer">
2727
<div>
28-
<svg-icon name="intelligent-construction" class="tip-common_icon"></svg-icon>
28+
<svg-icon name="chat" class="tip-common_icon"></svg-icon>
2929
</div>
3030
<div class="tips">
31-
<div class="tip-header">智能搭建</div>
32-
<div class="tip-content">根据描述文案自动搭建对应的页面。</div>
31+
<div class="tip-header">Chat</div>
32+
<div class="tip-content">回答日常问题或在开始任务前进行对话。</div>
3333
</div>
3434
</div>
3535
</template>
36-
<svg-icon name="intelligent-construction" class="plugin-common_icon"></svg-icon>
36+
<svg-icon name="chat" class="plugin-common_icon"></svg-icon>
3737
</tiny-tooltip>
3838
</template>
3939
</tiny-tab-item>
@@ -55,15 +55,14 @@ export default {
5555
},
5656
props: {
5757
aiType: {
58-
type: String,
59-
default: 'chat'
58+
type: String
6059
}
6160
},
6261
emits: ['typeChange'],
6362
setup(props, { emit }) {
6463
const { AI_MODES } = useRobot()
6564
const state = reactive({
66-
activeNameTabs: props.aiType || AI_MODES['Chat']
65+
activeNameTabs: props.aiType || AI_MODES.Agent
6766
})
6867
6968
const handleTabChange = (value) => {

packages/plugins/robot/src/icon-prompt/mcp-icon.vue renamed to packages/plugins/robot/src/icons/mcp-icon.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
xmlns="http://www.w3.org/2000/svg"
88
xmlns:xlink="http://www.w3.org/1999/xlink"
99
>
10-
<desc>Created with Pixso.</desc>
11-
<defs />
1210
<rect id="矩形" rx="6.000000" width="24.000000" height="24.000000" fill="#1476FF" fill-opacity="1.000000" />
1311
<rect
1412
id="矩形"
@@ -30,9 +28,3 @@
3028
/>
3129
</svg>
3230
</template>
33-
34-
<script>
35-
export default {
36-
name: 'McpIconComponent'
37-
}
38-
</script>

packages/plugins/robot/src/icon-prompt/page-icon.vue renamed to packages/plugins/robot/src/icons/page-icon.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
xmlns="http://www.w3.org/2000/svg"
88
xmlns:xlink="http://www.w3.org/1999/xlink"
99
>
10-
<desc>Created with Pixso.</desc>
11-
<defs />
1210
<rect id="矩形" rx="6.000000" width="24.000000" height="24.000000" fill="#25C251" fill-opacity="1.000000" />
1311
<rect
1412
id="矩形"
@@ -31,9 +29,3 @@
3129
<path id="矢量 642" d="" fill="#979797" fill-opacity="0" fill-rule="evenodd" />
3230
</svg>
3331
</template>
34-
35-
<script>
36-
export default {
37-
name: 'PageIconComponent'
38-
}
39-
</script>

packages/plugins/robot/src/icon-prompt/study-icon.vue renamed to packages/plugins/robot/src/icons/study-icon.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
xmlns="http://www.w3.org/2000/svg"
88
xmlns:xlink="http://www.w3.org/1999/xlink"
99
>
10-
<desc>Created with Pixso.</desc>
11-
<defs />
1210
<rect id="矩形" rx="6.000000" width="24.000000" height="24.000000" fill="#00C4BE" fill-opacity="1.000000" />
1311
<rect
1412
id="矩形"
@@ -30,9 +28,3 @@
3028
/>
3129
</svg>
3230
</template>
33-
34-
<script>
35-
export default {
36-
name: 'StudyIconComponent'
37-
}
38-
</script>

0 commit comments

Comments
 (0)