@ -15,6 +15,8 @@ import { t } from '@/locales'
let controller = new AbortController ( )
const openLongReply = import . meta . env . VITE _GLOB _OPEN _LONG _REPLY === 'true'
const route = useRoute ( )
const dialog = useDialog ( )
const ms = useMessage ( )
@ -41,7 +43,7 @@ function handleSubmit() {
}
async function onConversation ( ) {
cons t message = prompt . value
le t message = prompt . value
if ( loading . value )
return
@ -88,6 +90,8 @@ async function onConversation() {
scrollToBottom ( )
try {
let lastText = ''
const fetchChatAPIOnce = async ( ) => {
await fetchChatAPIProcess < Chat .ConversationResponse > ( {
prompt : message ,
options ,
@ -107,7 +111,7 @@ async function onConversation() {
dataSources . value . length - 1 ,
{
dateTime : new Date ( ) . toLocaleString ( ) ,
text : data . text ? ? '' ,
text : lastText + data . text ? ? '' ,
inversion : false ,
error : false ,
loading : false ,
@ -115,6 +119,14 @@ async function onConversation() {
requestOptions : { prompt : message , options : { ... options } } ,
} ,
)
if ( openLongReply && data . detail . choices [ 0 ] . finish _reason === 'length' ) {
options . parentMessageId = data . id
lastText = data . text
message = ''
return fetchChatAPIOnce ( )
}
scrollToBottom ( )
}
catch ( error ) {
@ -123,6 +135,9 @@ async function onConversation() {
} ,
} )
}
await fetchChatAPIOnce ( )
}
catch ( error : any ) {
const errorMessage = error ? . message ? ? t ( 'common.wrong' )
@ -181,7 +196,7 @@ async function onRegenerate(index: number) {
const { requestOptions } = dataSources . value [ index ]
cons t message = requestOptions ? . prompt ? ? ''
le t message = requestOptions ? . prompt ? ? ''
let options : Chat . ConversationRequest = { }
@ -205,6 +220,8 @@ async function onRegenerate(index: number) {
)
try {
let lastText = ''
const fetchChatAPIOnce = async ( ) => {
await fetchChatAPIProcess < Chat .ConversationResponse > ( {
prompt : message ,
options ,
@ -224,7 +241,7 @@ async function onRegenerate(index: number) {
index ,
{
dateTime : new Date ( ) . toLocaleString ( ) ,
text : data . text ? ? '' ,
text : lastText + data . text ? ? '' ,
inversion : false ,
error : false ,
loading : false ,
@ -232,6 +249,13 @@ async function onRegenerate(index: number) {
requestOptions : { prompt : message , ... options } ,
} ,
)
if ( openLongReply && data . detail . choices [ 0 ] . finish _reason === 'length' ) {
options . parentMessageId = data . id
lastText = data . text
message = ''
return fetchChatAPIOnce ( )
}
}
catch ( error ) {
/ /
@ -239,6 +263,8 @@ async function onRegenerate(index: number) {
} ,
} )
}
await fetchChatAPIOnce ( )
}
catch ( error : any ) {
if ( error . message === 'canceled' ) {
updateChatSome (