提交 07bb17b6 编写于 作者: View Design's avatar View Design

Merge branch 'main' of gitcode.com:git_bot/ai-fe

......@@ -129,6 +129,7 @@
<UButton
size="xl"
square
@click="handleContinueAsk(continueQuestion)"
:trailing-icon="asking ? '' : 'i-heroicons-chevron-right-20-solid'"
:disabled="!continueQuestion"
:loading="asking"
......@@ -190,6 +191,7 @@ let asking = ref(false)
const handleContinueAsk = (question) => {
if (asking.value) return;
asking.value = true;
generateFetchData(question);
}
// 处理ai generate
......@@ -207,6 +209,7 @@ const handleFormFetchData = (fetchData) => {
const index = data.value.length === 0 ? 0 : data.value.length - 1;
data.value[index] = data.value[index] || {};
const { meta, choices } = message;
console.log(`meta:`, meta, choices)
if (meta.type === 'answer') {
Object.assign(data.value[index], {
question: state.query,
......@@ -247,10 +250,10 @@ const handleError = (event) => {
console.log(`error`, event)
handleStopGenerate();
}
const generateFetchData = () => {
const generateFetchData = (query) => {
const { repo, id } = state;
const messages = [];
messages.push({ role: 'user', content: state.query });
messages.push({ role: 'user', content: query });
aiChatController = new AbortController();
asking.value = true;
fetchEventSource('/v1/chat/completions', {
......@@ -267,6 +270,6 @@ const generateFetchData = () => {
})
}
onMounted(() => {
generateFetchData();
generateFetchData(state.query);
})
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册