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"
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 >
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'
121110import { Notify , Loading , TinyPopover , TinyDialogBox } from ' @opentiny/vue'
122111import {
123112 useRobot ,
@@ -152,9 +141,9 @@ import LoadingRenderer from './mcp/LoadingRenderer.vue'
152141import { sendMcpRequest , serializeError } from ' ./mcp/utils'
153142import type { RobotMessage } from ' ./mcp/types'
154143import 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'
158147import { jsonrepair } from ' jsonrepair'
159148
160149export 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 }
0 commit comments