perf: Assistant dynamic certificate

This commit is contained in:
fit2cloud-chenyw
2025-07-22 12:20:51 +08:00
parent b8e60eadf8
commit 36d52dfa67
10 changed files with 40 additions and 30 deletions
+10
View File
@@ -75,6 +75,11 @@ class HttpService {
if (assistantStore.getToken) {
config.headers['X-SQLBOT-ASSISTANT-TOKEN'] = `Assistant ${assistantStore.getToken}`
if (config.headers['X-SQLBOT-TOKEN']) config.headers.delete('X-SQLBOT-TOKEN')
if (assistantStore.getType && assistantStore.getCertificate) {
config.headers['X-SQLBOT-ASSISTANT-CERTIFICATE'] = btoa(
encodeURIComponent(assistantStore.getCertificate)
)
}
}
const locale = getLocale()
if (locale) {
@@ -239,6 +244,11 @@ class HttpService {
if (assistantStore.getToken) {
heads['X-SQLBOT-ASSISTANT-TOKEN'] = `Assistant ${assistantStore.getToken}`
if (heads['X-SQLBOT-TOKEN']) delete heads['X-SQLBOT-TOKEN']
if (assistantStore.getType && assistantStore.getCertificate) {
heads['X-SQLBOT-ASSISTANT-CERTIFICATE'] = btoa(
encodeURIComponent(assistantStore.getCertificate)
)
}
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
@@ -1,9 +1,7 @@
<script setup lang="ts">
import BaseAnswer from './BaseAnswer.vue'
import { Chat, chatApi, ChatInfo, type ChatMessage, ChatRecord, questionApi } from '@/api/chat.ts'
import { useAssistantStore } from '@/stores/assistant'
import { computed, nextTick, onBeforeUnmount, ref } from 'vue'
const assistantStore = useAssistantStore()
const props = withDefaults(
defineProps<{
chatList?: Array<ChatInfo>
@@ -102,10 +100,7 @@ const sendMessage = async () => {
const param = {
question: currentRecord.question,
chat_id: _currentChatId.value,
assistant_certificate: assistantStore.getCertificate,
}
console.log(assistantStore.getCertificate)
console.log(param)
const response = await questionApi.add(param, controller)
const reader = response.body.getReader()
const decoder = new TextDecoder()
@@ -109,7 +109,6 @@ const communicationCb = async (event: any) => {
}
if (event.data?.busi == 'certificate') {
const certificate = event.data['certificate']
console.log(certificate)
assistantStore.setType(1)
assistantStore.setCertificate(certificate)
// store certificate to pinia