forked from Leaf/amber-ui
改进
This commit is contained in:
parent
c56e569ec3
commit
50e3030db5
@ -6,7 +6,11 @@
|
|||||||
<span class="text-xl">切换助理</span>
|
<span class="text-xl">切换助理</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</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>
|
<n-thing>
|
||||||
{{ a.name }}
|
{{ a.name }}
|
||||||
</n-thing>
|
</n-thing>
|
||||||
@ -18,10 +22,12 @@
|
|||||||
import { useUserStore } from "../stores/user";
|
import { useUserStore } from "../stores/user";
|
||||||
import { updateAll } from "../plugins/update/update";
|
import { updateAll } from "../plugins/update/update";
|
||||||
import { useAssistantStore } from "../stores/assistants";
|
import { useAssistantStore } from "../stores/assistants";
|
||||||
|
import { useChatStore } from "@/stores/chat";
|
||||||
|
|
||||||
const loaded = ref(false);
|
const loaded = ref(false);
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const assistantStore = useAssistantStore();
|
const assistantStore = useAssistantStore();
|
||||||
|
const chatStore = useChatStore();
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => userStore.logined,
|
() => userStore.logined,
|
||||||
@ -36,5 +42,11 @@ function update() {
|
|||||||
loaded.value = true;
|
loaded.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const changeAssistant = (id: number | undefined) => {
|
||||||
|
if (id) {
|
||||||
|
chatStore.currentAssistantId = id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
update();
|
update();
|
||||||
</script>
|
</script>
|
||||||
|
@ -141,6 +141,7 @@ import {
|
|||||||
EntityChatMessage,
|
EntityChatMessage,
|
||||||
SchemaChatMessageAddRequestRoleEnum,
|
SchemaChatMessageAddRequestRoleEnum,
|
||||||
EntityChat,
|
EntityChat,
|
||||||
|
SchemaChatMessageAddRequest,
|
||||||
} from "@/api";
|
} from "@/api";
|
||||||
import getApi from "@/plugins/api";
|
import getApi from "@/plugins/api";
|
||||||
import MessageList from "./MessageList.vue";
|
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;
|
toolError.value = false;
|
||||||
getApi()
|
getApi()
|
||||||
.ChatMessage.apiV1ChatsIdMessagesPost(Number(chatId.value), {
|
.ChatMessage.apiV1ChatsIdMessagesPost(Number(chatId.value), payload)
|
||||||
message: text,
|
|
||||||
role: role,
|
|
||||||
})
|
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
// const newMessage = {
|
// const newMessage = {
|
||||||
// content: text,
|
// content: text,
|
||||||
@ -529,7 +538,7 @@ const chatData: Ref<EntityChat> = ref({});
|
|||||||
const getChat = async () => {
|
const getChat = async () => {
|
||||||
chatData.value = (
|
chatData.value = (
|
||||||
await getApi().Chat.apiV1ChatsIdGet(chatStore.currentChatId)
|
await getApi().Chat.apiV1ChatsIdGet(chatStore.currentChatId)
|
||||||
).data.data;
|
).data.data ?? {};
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -16,7 +16,7 @@ if (process.env.NODE_ENV === "production") {
|
|||||||
config.oauth_client_id = "16";
|
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);
|
// console.log("api endpoint: " + config.backend);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export const useChatStore = defineStore("chats", {
|
|||||||
persist: false,
|
persist: false,
|
||||||
state: () => ({
|
state: () => ({
|
||||||
currentChatId: 0,
|
currentChatId: 0,
|
||||||
|
currentAssistantId: 0,
|
||||||
chats: <EntityChat[] | undefined>[],
|
chats: <EntityChat[] | undefined>[],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user