|
@@ -80,10 +80,10 @@ const openPromptDialog = ref(false)
|
|
// 模型选择
|
|
// 模型选择
|
|
const modelOptions = ref<LmConfigInfo[]>([])
|
|
const modelOptions = ref<LmConfigInfo[]>([])
|
|
|
|
|
|
-const {loading: loadingModels, doLoading: loadModel} = useLoading(async ()=> {
|
|
|
|
- const data: {list: LmConfigInfo[],total: number} = await assist.model.getList().catch(() => {
|
|
|
|
|
|
+const { loading: loadingModels, doLoading: loadModel } = useLoading(async () => {
|
|
|
|
+ const data: { list: LmConfigInfo[]; total: number } = await assist.model.getList().catch(() => {
|
|
return {
|
|
return {
|
|
- list: []
|
|
|
|
|
|
+ list: [],
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
@@ -95,7 +95,6 @@ onMounted(loadModel)
|
|
|
|
|
|
const selectedModel = ref<number | undefined>(undefined)
|
|
const selectedModel = ref<number | undefined>(undefined)
|
|
|
|
|
|
-
|
|
|
|
const chatInstance = ref<(() => void) | undefined>(undefined)
|
|
const chatInstance = ref<(() => void) | undefined>(undefined)
|
|
onUnmounted(() => chatInstance.value?.())
|
|
onUnmounted(() => chatInstance.value?.())
|
|
// 是否正在对话
|
|
// 是否正在对话
|
|
@@ -122,9 +121,13 @@ const sendMessage = () => {
|
|
role: 'assistant',
|
|
role: 'assistant',
|
|
content: '',
|
|
content: '',
|
|
timestamp: Date.now(),
|
|
timestamp: Date.now(),
|
|
|
|
+ tools_calls: []
|
|
})
|
|
})
|
|
|
|
|
|
- const fn = watch(()=>rtn.content,(newVal)=>console.log(newVal))
|
|
|
|
|
|
+ const fn = watch(
|
|
|
|
+ () => rtn.content,
|
|
|
|
+ (newVal) => console.log(newVal)
|
|
|
|
+ )
|
|
|
|
|
|
inputMessage.value = ''
|
|
inputMessage.value = ''
|
|
|
|
|
|
@@ -133,47 +136,52 @@ const sendMessage = () => {
|
|
// let toolcall: { name: string; param?: string; value?: string } | undefined = undefined
|
|
// let toolcall: { name: string; param?: string; value?: string } | undefined = undefined
|
|
chatInstance.value = assist.chat({
|
|
chatInstance.value = assist.chat({
|
|
chatRequest: {
|
|
chatRequest: {
|
|
- message: prompt.value ? [
|
|
|
|
- {
|
|
|
|
- id: 0,
|
|
|
|
- role: 'system',
|
|
|
|
- content: prompt.value,
|
|
|
|
- timestamp: Date.now(),
|
|
|
|
- },
|
|
|
|
- ...messages.value,
|
|
|
|
- ]: messages.value,
|
|
|
|
- modelClassId: selectedModel.value
|
|
|
|
|
|
+ message: prompt.value
|
|
|
|
+ ? [
|
|
|
|
+ {
|
|
|
|
+ id: 0,
|
|
|
|
+ role: 'system',
|
|
|
|
+ content: prompt.value,
|
|
|
|
+ timestamp: Date.now(),
|
|
|
|
+ },
|
|
|
|
+ ...messages.value,
|
|
|
|
+ ]
|
|
|
|
+ : messages.value,
|
|
|
|
+ modelClassId: selectedModel.value,
|
|
},
|
|
},
|
|
onReceive: (resp: ChatResponse) => {
|
|
onReceive: (resp: ChatResponse) => {
|
|
switch (resp.type) {
|
|
switch (resp.type) {
|
|
case 'message':
|
|
case 'message':
|
|
rtn.content += resp.message
|
|
rtn.content += resp.message
|
|
break
|
|
break
|
|
- case 'toolcall':
|
|
|
|
- rtn.content += `
|
|
|
|
-\`\`\`tools-loading
|
|
|
|
-request
|
|
|
|
-${resp.request.name}
|
|
|
|
-${resp.request.data.replace('\n', '')}
|
|
|
|
-\`\`\`
|
|
|
|
-
|
|
|
|
-`
|
|
|
|
|
|
+ case 'toolcall': {
|
|
|
|
+ rtn.tools_calls?.push({
|
|
|
|
+ id: 'qwq',
|
|
|
|
+ type: 'function',
|
|
|
|
+ function: {
|
|
|
|
+ name: resp.request.name,
|
|
|
|
+ arguments: resp.request.data,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
break
|
|
break
|
|
- case 'toolres':
|
|
|
|
|
|
+ }
|
|
|
|
+ case 'toolres': {
|
|
rtn.content += `
|
|
rtn.content += `
|
|
-\`\`\`tools-loading
|
|
|
|
-resp
|
|
|
|
-${resp.response.name}
|
|
|
|
-${resp.response.data.replace('\n', '')}
|
|
|
|
-\`\`\`
|
|
|
|
-
|
|
|
|
|
|
+> ### ${resp.response.name}调用结果
|
|
|
|
+>
|
|
|
|
+>
|
|
|
|
+>\`\`\`json
|
|
|
|
+>${resp.response.data.split('\n').join('\n> ')}
|
|
|
|
+>\`\`\`
|
|
`
|
|
`
|
|
break
|
|
break
|
|
-
|
|
|
|
|
|
+ }
|
|
case 'error':
|
|
case 'error':
|
|
rtn.content += `
|
|
rtn.content += `
|
|
> ### 系统报错
|
|
> ### 系统报错
|
|
-> ${resp.error}
|
|
|
|
|
|
+>
|
|
|
|
+>
|
|
|
|
+> ${resp.error.split('\n').join('\n> ')}
|
|
|
|
|
|
`
|
|
`
|
|
break
|
|
break
|
|
@@ -449,20 +457,13 @@ const redirectToModelManager = () => router.push('manage/model')
|
|
<!-- 模型选择 -->
|
|
<!-- 模型选择 -->
|
|
<div class="model-selector" v-loading="loadingModels">
|
|
<div class="model-selector" v-loading="loadingModels">
|
|
<el-select v-model="selectedModel" placeholder="选择模型" size="small" style="width: 200px">
|
|
<el-select v-model="selectedModel" placeholder="选择模型" size="small" style="width: 200px">
|
|
- <el-option v-for="item in modelOptions" :key="item.id" :value="item.id" :label="item.modelName"/>
|
|
|
|
|
|
+ <el-option v-for="item in modelOptions" :key="item.id" :value="item.id" :label="item.modelName" />
|
|
</el-select>
|
|
</el-select>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<!-- 提示词输入框 -->
|
|
<!-- 提示词输入框 -->
|
|
<div class="prompt-selector">
|
|
<div class="prompt-selector">
|
|
- <el-input
|
|
|
|
- v-model="prompt"
|
|
|
|
- placeholder="点击设置提示词..."
|
|
|
|
- size="small"
|
|
|
|
- style="width: 200px"
|
|
|
|
- readonly
|
|
|
|
- @click="openPromptDialog = true"
|
|
|
|
- />
|
|
|
|
|
|
+ <el-input v-model="prompt" placeholder="点击设置提示词..." size="small" style="width: 200px" readonly @click="openPromptDialog = true" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -484,14 +485,7 @@ const redirectToModelManager = () => router.push('manage/model')
|
|
|
|
|
|
<!-- 按钮组 -->
|
|
<!-- 按钮组 -->
|
|
<div class="button-group">
|
|
<div class="button-group">
|
|
- <el-button
|
|
|
|
- type="warning"
|
|
|
|
- size="small"
|
|
|
|
- @click="clearMessage"
|
|
|
|
- style="margin-left: 12px"
|
|
|
|
- >
|
|
|
|
- 清空
|
|
|
|
- </el-button>
|
|
|
|
|
|
+ <el-button type="warning" size="small" @click="clearMessage" style="margin-left: 12px"> 清空</el-button>
|
|
<el-button
|
|
<el-button
|
|
v-if="!isConversationActive"
|
|
v-if="!isConversationActive"
|
|
type="primary"
|
|
type="primary"
|
|
@@ -513,15 +507,13 @@ const redirectToModelManager = () => router.push('manage/model')
|
|
v-model="openPromptDialog"
|
|
v-model="openPromptDialog"
|
|
title="设置提示词"
|
|
title="设置提示词"
|
|
width="600px"
|
|
width="600px"
|
|
- :before-close="() => { openPromptDialog = false }"
|
|
|
|
|
|
+ :before-close="
|
|
|
|
+ () => {
|
|
|
|
+ openPromptDialog = false
|
|
|
|
+ }
|
|
|
|
+ "
|
|
>
|
|
>
|
|
- <el-input
|
|
|
|
- v-model="prompt"
|
|
|
|
- type="textarea"
|
|
|
|
- placeholder="请输入提示词..."
|
|
|
|
- :rows="8"
|
|
|
|
- resize="none"
|
|
|
|
- />
|
|
|
|
|
|
+ <el-input v-model="prompt" type="textarea" placeholder="请输入提示词..." :rows="8" resize="none" />
|
|
<template #footer>
|
|
<template #footer>
|
|
<div class="dialog-footer">
|
|
<div class="dialog-footer">
|
|
<el-button @click="openPromptDialog = false">取消</el-button>
|
|
<el-button @click="openPromptDialog = false">取消</el-button>
|
|
@@ -530,8 +522,6 @@ const redirectToModelManager = () => router.push('manage/model')
|
|
</template>
|
|
</template>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</el-container>
|
|
</el-container>
|
|
-
|
|
|
|
-
|
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
@@ -794,7 +784,9 @@ const redirectToModelManager = () => router.push('manage/model')
|
|
}
|
|
}
|
|
|
|
|
|
@keyframes loading-bounce {
|
|
@keyframes loading-bounce {
|
|
- 0%, 80%, 100% {
|
|
|
|
|
|
+ 0%,
|
|
|
|
+ 80%,
|
|
|
|
+ 100% {
|
|
transform: scale(0.8);
|
|
transform: scale(0.8);
|
|
opacity: 0.5;
|
|
opacity: 0.5;
|
|
}
|
|
}
|