mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
This commit is contained in:
parent
9af53c8821
commit
8594fd4d09
|
|
@ -196,6 +196,31 @@ const postChatMessage: (chat_id: string, message: string) => Promise<any> = (cha
|
|||
return postStream(`/api/${prefix}/chat_message/${chat_id}`, { message })
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞、点踩
|
||||
* @param 参数
|
||||
* application_id : string; chat_id : string; chat_record_id : string
|
||||
* {
|
||||
"vote_status": "string", // -1 0 1
|
||||
}
|
||||
*/
|
||||
const putChatVote: (
|
||||
application_id: string,
|
||||
chat_id: string,
|
||||
chat_record_id: string,
|
||||
vote_status: string,
|
||||
loading?: Ref<boolean>
|
||||
) => Promise<any> = (application_id, chat_id, chat_record_id, vote_status, loading) => {
|
||||
return put(
|
||||
`${prefix}/${application_id}/chat/${chat_id}/chat_record/${chat_record_id}/vote`,
|
||||
{
|
||||
vote_status
|
||||
},
|
||||
undefined,
|
||||
loading
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
getAllAppilcation,
|
||||
getApplication,
|
||||
|
|
@ -210,5 +235,6 @@ export default {
|
|||
getAPIKey,
|
||||
getAccessToken,
|
||||
postAppAuthentication,
|
||||
getProfile
|
||||
getProfile,
|
||||
putChatVote
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ interface chatType {
|
|||
* 是否暂停
|
||||
*/
|
||||
is_stop?: boolean
|
||||
record_id: string
|
||||
vote_status: string
|
||||
}
|
||||
|
||||
export class ChatRecordManage {
|
||||
|
|
|
|||
|
|
@ -7,45 +7,85 @@
|
|||
</el-tooltip>
|
||||
<el-divider direction="vertical" />
|
||||
<el-tooltip effect="dark" content="复制" placement="top">
|
||||
<el-button text @click="copyClick(item?.answer_text)">
|
||||
<el-button text @click="copyClick(data?.answer_text)">
|
||||
<AppIcon iconName="app-copy"></AppIcon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-divider direction="vertical" />
|
||||
<el-tooltip effect="dark" content="赞同" placement="top">
|
||||
<el-button text>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
content="赞同"
|
||||
placement="top"
|
||||
v-if="buttonData?.vote_status === '-1'"
|
||||
>
|
||||
<el-button text @click="voteHandle('1')" :disabled="loading">
|
||||
<AppIcon iconName="app-like"></AppIcon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="取消赞同" placement="top">
|
||||
<el-button text>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
content="取消赞同"
|
||||
placement="top"
|
||||
v-if="buttonData?.vote_status === '1'"
|
||||
>
|
||||
<el-button text @click="voteHandle('-1')" :disabled="loading">
|
||||
<AppIcon iconName="app-like-color"></AppIcon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-divider direction="vertical" />
|
||||
<el-tooltip effect="dark" content="反对" placement="top">
|
||||
<el-button text>
|
||||
<el-divider direction="vertical" v-if="buttonData?.vote_status === '-1'" />
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
content="反对"
|
||||
placement="top"
|
||||
v-if="buttonData?.vote_status === '-1'"
|
||||
>
|
||||
<el-button text @click="voteHandle('0')" :disabled="loading">
|
||||
<AppIcon iconName="app-oppose"></AppIcon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="取消反对" placement="top">
|
||||
<el-button text>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
content="取消反对"
|
||||
placement="top"
|
||||
v-if="buttonData?.vote_status === '0'"
|
||||
>
|
||||
<el-button text @click="voteHandle('-1')" :disabled="loading">
|
||||
<AppIcon iconName="app-oppose-color"></AppIcon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch, onMounted } from 'vue'
|
||||
import { copyClick } from '@/utils/clipboard'
|
||||
|
||||
defineProps({
|
||||
import applicationApi from '@/api/application'
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
applicationId: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
chartId: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:data'])
|
||||
|
||||
const buttonData = ref(props.data)
|
||||
const loading = ref(false)
|
||||
|
||||
function voteHandle(val: string) {
|
||||
applicationApi
|
||||
.putChatVote(props.applicationId, props.chartId, props.data.record_id, val, loading)
|
||||
.then((res) => {
|
||||
buttonData.value['vote_status'] = val
|
||||
emit('update:data', buttonData.value)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@
|
|||
>
|
||||
</div>
|
||||
|
||||
<!-- <div v-if="item.write_ed && props.appId">
|
||||
<OperationButton :data="item" />
|
||||
</div> -->
|
||||
<div v-if="item.write_ed && props.appId">
|
||||
<OperationButton :data="item" :applicationId="appId" :chartId="chartOpenId" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -109,10 +109,16 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick, onUpdated, computed } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import OperationButton from './OperationButton.vue'
|
||||
import applicationApi from '@/api/application'
|
||||
import { ChatManagement, type chatType } from '@/api/type/application'
|
||||
import { randomId } from '@/utils/utils'
|
||||
import useStore from '@/stores'
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { accessToken }
|
||||
} = route as any
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
|
|
@ -120,6 +126,7 @@ const props = defineProps({
|
|||
},
|
||||
appId: String
|
||||
})
|
||||
const { application } = useStore()
|
||||
|
||||
const scrollDiv = ref()
|
||||
const dialogScrollbar = ref()
|
||||
|
|
@ -171,7 +178,12 @@ function getChartOpenId() {
|
|||
chartOpenId.value = res.data
|
||||
chatMessage()
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((res) => {
|
||||
if (res.response.status === 403) {
|
||||
application.asyncAppAuthentication(accessToken).then(() => {
|
||||
getChartOpenId()
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
})
|
||||
} else {
|
||||
|
|
@ -199,7 +211,9 @@ function chatMessage() {
|
|||
answer_text: '',
|
||||
buffer: [],
|
||||
write_ed: false,
|
||||
is_stop: false
|
||||
is_stop: false,
|
||||
record_id: '',
|
||||
vote_status: '-1'
|
||||
})
|
||||
applicationApi.postChatMessage(chartOpenId.value, problem_text).then(async (response) => {
|
||||
inputValue.value = ''
|
||||
|
|
@ -219,9 +233,10 @@ function chatMessage() {
|
|||
try {
|
||||
const decoder = new TextDecoder('utf-8')
|
||||
const str = decoder.decode(value, { stream: true })
|
||||
if (str && str.startsWith('data:')) {
|
||||
const content = JSON?.parse(str.replace('data:', ''))?.content
|
||||
|
||||
if (str && str.startsWith('data:')) {
|
||||
row.record_id = JSON?.parse(str.replace('data:', '')).id
|
||||
const content = JSON?.parse(str.replace('data:', ''))?.content
|
||||
if (content) {
|
||||
ChatManagement.append(id, content)
|
||||
}
|
||||
|
|
@ -260,11 +275,15 @@ onUpdated(() => {
|
|||
&__content {
|
||||
width: 99%;
|
||||
padding-bottom: 96px;
|
||||
|
||||
.avatar {
|
||||
float: left;
|
||||
}
|
||||
.content {
|
||||
padding-left: var(--padding-left);
|
||||
:deep(ol) {
|
||||
margin-left: 16px!important;
|
||||
}
|
||||
}
|
||||
.text {
|
||||
word-break: break-all;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ instance.interceptors.response.use(
|
|||
router.push({ name: 'login' })
|
||||
}
|
||||
|
||||
if (err.response?.status === 403) {
|
||||
if (err.response?.status === 403 && !err.response.config.url.includes('chat/open')) {
|
||||
MsgError(
|
||||
err.response.data && err.response.data.message ? err.response.data.message : '没有权限访问'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@ const useApplicationStore = defineStore({
|
|||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
async refreshAccessToken(token: string) {
|
||||
this.asyncAppAuthentication(token)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -155,7 +155,6 @@
|
|||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
{{ datasetLoading }}
|
||||
<AddDatasetDialog
|
||||
ref="AddDatasetDialogRef"
|
||||
@addData="addDataset"
|
||||
|
|
@ -254,6 +253,11 @@ function getDetail() {
|
|||
application.asyncGetApplicationDetail(id, loading).then((res: any) => {
|
||||
applicationForm.value = res.data
|
||||
applicationForm.value.model_id = res.data.model
|
||||
if (res.data?.example.length === 2) {
|
||||
exampleList.value = res.data?.example
|
||||
} else if (res.data?.example.length === 1) {
|
||||
exampleList.value = [res.data?.example[0], '']
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="chat__main chat-width" v-loading="loading">
|
||||
<AiDialog :data="applicationDetail" :appId="applicationDetail?.id"></AiDialog>
|
||||
<AiDialog v-model:data="applicationDetail" :appId="applicationDetail?.id"></AiDialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue