diff --git a/src/components/AssistantMenu.vue b/src/components/AssistantMenu.vue
index 4fee14f..1c12f1c 100644
--- a/src/components/AssistantMenu.vue
+++ b/src/components/AssistantMenu.vue
@@ -6,7 +6,11 @@
ċĉ˘ċİç
-
+
{{ a.name }}
@@ -18,10 +22,12 @@
import { useUserStore } from "../stores/user";
import { updateAll } from "../plugins/update/update";
import { useAssistantStore } from "../stores/assistants";
+import { useChatStore } from "@/stores/chat";
const loaded = ref(false);
const userStore = useUserStore();
const assistantStore = useAssistantStore();
+const chatStore = useChatStore();
watch(
() => userStore.logined,
@@ -36,5 +42,11 @@ function update() {
loaded.value = true;
}
+const changeAssistant = (id: number | undefined) => {
+ if (id) {
+ chatStore.currentAssistantId = id;
+ }
+};
+
update();
diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue
index 0a90060..159da13 100644
--- a/src/components/chat/Chat.vue
+++ b/src/components/chat/Chat.vue
@@ -141,6 +141,7 @@ import {
EntityChatMessage,
SchemaChatMessageAddRequestRoleEnum,
EntityChat,
+ SchemaChatMessageAddRequest,
} from "@/api";
import getApi from "@/plugins/api";
import MessageList from "./MessageList.vue";
@@ -339,12 +340,20 @@ async function sendMessage(
});
}
+ let payload: SchemaChatMessageAddRequest = {
+ message: text,
+ role: role,
+ };
+ if (chatStore.currentAssistantId) {
+ payload = {
+ ...payload,
+ assistant_id: chatStore.currentAssistantId,
+ };
+ }
+
toolError.value = false;
getApi()
- .ChatMessage.apiV1ChatsIdMessagesPost(Number(chatId.value), {
- message: text,
- role: role,
- })
+ .ChatMessage.apiV1ChatsIdMessagesPost(Number(chatId.value), payload)
.then(async (res) => {
// const newMessage = {
// content: text,
@@ -529,7 +538,7 @@ const chatData: Ref = ref({});
const getChat = async () => {
chatData.value = (
await getApi().Chat.apiV1ChatsIdGet(chatStore.currentChatId)
- ).data.data;
+ ).data.data ?? {};
};
onMounted(() => {
diff --git a/src/config/config.ts b/src/config/config.ts
index d2c8e61..a601ecf 100644
--- a/src/config/config.ts
+++ b/src/config/config.ts
@@ -16,7 +16,7 @@ if (process.env.NODE_ENV === "production") {
config.oauth_client_id = "16";
}
-// config.backend = "https://amber-api.leaflow.cn";
+config.backend = "https://amber-api.leaflow.cn";
// console.log("api endpoint: " + config.backend);
diff --git a/src/stores/chat.ts b/src/stores/chat.ts
index d2f3817..a1771ed 100644
--- a/src/stores/chat.ts
+++ b/src/stores/chat.ts
@@ -5,6 +5,7 @@ export const useChatStore = defineStore("chats", {
persist: false,
state: () => ({
currentChatId: 0,
+ currentAssistantId: 0,
chats: [],
}),
});