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

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

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