fix command chat

This commit is contained in:
Chuck1sn
2025-05-25 21:09:04 +08:00
parent 402c421370
commit dde5fecd62
5 changed files with 1743 additions and 1710 deletions

View File

@@ -1,11 +0,0 @@
import client from "../../api/client";
const useAiAction = () => {
const actionChat = (message: string) => {
return client.POST("/ai/action/chat", {
body: message,
});
};
return { actionChat };
};

View File

@@ -1,7 +1,7 @@
import { fetchEventSource } from "@microsoft/fetch-event-source";
import { ref } from "vue";
import useAuthStore from "../store/useAuthStore";
import useAlertStore from "../store/useAlertStore";
import client from "../../api/client";
const authStore = useAuthStore();
@@ -43,6 +43,21 @@ export const useAiChat = () => {
}
};
const actionChat = async (message: string) => {
messages.value.push(message);
messages.value.push("");
isLoading.value = true;
try {
const { data } = await client.POST("/ai/action/chat", {
body: message,
});
messages.value[messages.value.length - 1] += "接收到指令,请您执行。";
return data;
} finally {
isLoading.value = false;
}
};
const cancel = () => {
if (currentController) {
currentController.abort();
@@ -50,5 +65,5 @@ export const useAiChat = () => {
}
};
return { messages, chat, isLoading, cancel };
return { messages, chat, isLoading, cancel, actionChat };
};