forked from Leaf/amber-ui
改进
This commit is contained in:
parent
c56e569ec3
commit
50e3030db5
@ -6,7 +6,11 @@
|
||||
<span class="text-xl">切换助理</span>
|
||||
</div>
|
||||
</template>
|
||||
<n-list-item v-for="a in assistantStore.assistants" :key="a.id">
|
||||
<n-list-item
|
||||
v-for="a in assistantStore.assistants"
|
||||
:key="a.id"
|
||||
@click="changeAssistant(a.id)"
|
||||
>
|
||||
<n-thing>
|
||||
{{ a.name }}
|
||||
</n-thing>
|
||||
@ -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();
|
||||
</script>
|
||||
|
@ -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<EntityChat> = ref({});
|
||||
const getChat = async () => {
|
||||
chatData.value = (
|
||||
await getApi().Chat.apiV1ChatsIdGet(chatStore.currentChatId)
|
||||
).data.data;
|
||||
).data.data ?? {};
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -5,6 +5,7 @@ export const useChatStore = defineStore("chats", {
|
||||
persist: false,
|
||||
state: () => ({
|
||||
currentChatId: 0,
|
||||
currentAssistantId: 0,
|
||||
chats: <EntityChat[] | undefined>[],
|
||||
}),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user