提交 6bfd8177 编写于 作者: D DebugIsFalse

feature: 继续提问题

上级 5f643949
......@@ -120,6 +120,7 @@
<UButton
size="xl"
square
@click="handleContinueAsk(continueQuestion)"
:trailing-icon="asking ? '' : 'i-heroicons-chevron-right-20-solid'"
:disabled="!continueQuestion"
:loading="asking"
......@@ -181,6 +182,7 @@ let asking = ref(false)
const handleContinueAsk = (question) => {
if (asking.value) return;
asking.value = true;
generateFetchData(question);
}
// 处理ai generate
......@@ -198,6 +200,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,
......@@ -238,10 +241,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', {
......@@ -258,6 +261,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.
先完成此消息的编辑!
想要评论请 注册