1010 <Teleport v-if =" showTeleport" defer :to =" fullscreen ? 'body' : '.tiny-engine-right-robot'" >
1111 <div class =" robot-chat-container" :class =" { 'robot-chat-container-fullscreen': fullscreen }" >
1212 <robot-chat
13- : ref =" robotChatRef"
13+ ref =" robotChatRef"
1414 :prompt-items =" promptItems"
15- :allowFiles =" isVisualModel() && aiType === AI_MODES.Agent"
15+ :bubbleRenderers ="
16+ aiMode === CHAT_MODE.Agent ? { markdown: BuildLoadingRenderer, loading: BuildLoadingRenderer } : {}
17+ "
18+ :allowFiles =" isVisualModel() && aiMode === CHAT_MODE.Agent"
1619 @fileSelected =" handleFileSelected"
1720 >
1821 <template #operations >
2528 >
2629 <robot-setting-popover
2730 v-if =" showSettingPopover"
28- @changeType =" changeModel "
31+ @changeType =" handleChatModeChange "
2932 @close =" closePanel"
3033 ></robot-setting-popover >
3134 <template #reference >
32- <span class =" chat-title-dropdown " @click.stop =" showSettingPopover = true " >
35+ <span class =" setting-icon " @click.stop =" showSettingPopover = !showSettingPopover " >
3336 <svg-icon name =" setting" class =" operations-setting ml8" > </svg-icon >
3437 </span >
3538 </template >
3639 </tiny-popover >
3740 </template >
3841 <template #footer-left >
39- <robot-type-select :aiType = " aiType " @typeChange =" typeChange" ></robot-type-select >
40- <mcp-server :position =" mcpDrawerPosition" v-if =" aiType === AI_MODES .Chat" ></mcp-server >
42+ <robot-type-select :aiMode = " aiMode " @typeChange =" typeChange" ></robot-type-select >
43+ <mcp-server :position =" mcpDrawerPosition" v-if =" aiMode === CHAT_MODE .Chat" ></mcp-server >
4144 </template >
4245 </robot-chat >
43- <tiny-dialog-box v-model:visible =" showPreview" title =" 当前AI渲染效果" width =" 80%" >
44- <schema-renderer v-if =" showPreview" :schema =" currentSchema" ></schema-renderer >
45- </tiny-dialog-box >
4646 </div >
4747 </Teleport >
4848 </div >
@@ -53,16 +53,17 @@ import { computed, h, onMounted, ref } from 'vue'
5353import { ToolbarBase } from ' @opentiny/tiny-engine-common'
5454import RobotChat from ' ./components/RobotChat.vue'
5555import RobotSettingPopover from ' ./components/RobotSettingPopover.vue'
56- import { TinyPopover , TinyDialogBox } from ' @opentiny/vue'
56+ import { TinyPopover } from ' @opentiny/vue'
5757import { useRobot , getMetaApi , META_SERVICE } from ' @opentiny/tiny-engine-meta-register'
5858import McpIconComponent from ' ./icons/mcp-icon.vue'
5959import PageIconComponent from ' ./icons/page-icon.vue'
6060import StudyIconComponent from ' ./icons/study-icon.vue'
6161import type { PromptProps } from ' @opentiny/tiny-robot'
62- import SchemaRenderer from ' @opentiny/tiny-schema-renderer'
6362import RobotTypeSelect from ' ./components/RobotTypeSelect.vue'
6463import McpServer from ' ./mcp/McpServer.vue'
64+ import BuildLoadingRenderer from ' ./BuildLoadingRenderer.vue'
6565import { updateLLMConfig } from ' ./client'
66+ import useChat from ' ./composables/useChat'
6667
6768const { options } = defineProps ({
6869 options: {
@@ -71,7 +72,7 @@ const { options } = defineProps({
7172 }
7273})
7374
74- const robotChatRef = ref (' robotChatRef ' )
75+ const robotChatRef = ref (null )
7576
7677const fullscreen = computed (() => {
7778 return robotChatRef .value ?.fullscreen
@@ -107,54 +108,30 @@ const promptItems: PromptProps[] = [
107108 }
108109]
109110
110- const showPreview = ref (false )
111- const currentSchema = ref (null )
112111const showTeleport = ref (false )
113112const showSettingPopover = ref (false )
114113
115- const { robotSettingState, AI_MODES, AIModelOptions } = useRobot ()
114+ const { robotSettingState, CHAT_MODE, AIModelOptions, aiMode } = useRobot ()
115+ const { inputMessage } = useChat ()
116116
117117const isVisualModel = () => {
118118 const platform = AIModelOptions .find ((option ) => option .value === robotSettingState .selectedModel .baseUrl )
119- const modelAbility = platform .model .find ((item ) => item .value === robotSettingState .selectedModel .model )
119+ const modelAbility = platform ? .model .find ((item ) => item .value === robotSettingState .selectedModel .model )
120120 return modelAbility ?.ability ?.includes (' visual' ) || false
121121}
122122
123- const aiType = ref (AI_MODES .Agent )
124-
125123const typeChange = (type : string ) => {
126- aiType .value = type
124+ aiMode .value = type
127125 robotChatRef .value ?.createConversation ()
128126 updateLLMConfig ({
129- apiUrl: type === AI_MODES .Agent ? ' /app-center/api/ai/chat' : ' /app-center/api/chat/completions'
127+ apiUrl: type === CHAT_MODE .Agent ? ' /app-center/api/ai/chat' : ' /app-center/api/chat/completions'
130128 })
131129}
132130
133- const changeApiKey = () => {
134- localStorage .removeItem (' aiChat' )
135- }
136-
137- const changeModel = (model ) => {
138- robotSettingState .selectedModel = {
139- label: model .label || model .model ,
140- activeName: model .activeName ,
141- baseUrl: model .baseUrl ,
142- model: model .model ,
143- completeModel: model .completeModel ,
144- apiKey: model .apiKey
145- }
131+ const handleChatModeChange = () => {
146132 // singleAttachmentItems.value = []
147133 // imageUrl.value = ''
148134 // endContent()
149-
150- if (
151- robotSettingState .selectedModel .apiKey !== model .apiKey &&
152- robotSettingState .selectedModel .baseUrl === model .baseUrl &&
153- robotSettingState .selectedModel .model === model .model
154- ) {
155- robotSettingState .selectedModel .apiKey = model .apiKey
156- changeApiKey ()
157- }
158135}
159136
160137const closePanel = () => {
@@ -175,6 +152,9 @@ const handleFileSelected = (formData: unknown, updateAttachment: (resourceUrl: s
175152 })
176153 .then ((res : any ) => {
177154 updateAttachment (res ?.resourceUrl )
155+ if (! inputMessage .value ) {
156+ inputMessage .value = ' 生成图片中UI效果'
157+ }
178158 })
179159 } catch (error ) {
180160 // eslint-disable-next-line no-console
@@ -203,6 +183,10 @@ onMounted(async () => {
203183 }
204184}
205185
186+ .setting-icon {
187+ cursor : pointer ;
188+ }
189+
206190.operations-setting {
207191 font-size : 28px ;
208192 padding : 4px ;
0 commit comments