@@ -27,11 +27,14 @@ export async function generateAnswersWithGptCompletionApi(
2727) {
2828 const { controller, messageListener } = setAbortController ( port )
2929
30+ const config = await getUserConfig ( )
3031 const prompt =
3132 ( await getCompletionPromptBase ( ) ) +
32- getConversationPairs ( session . conversationRecords , true ) +
33+ getConversationPairs (
34+ session . conversationRecords . slice ( - config . maxConversationContextLength ) ,
35+ true ,
36+ ) +
3337 `Human: ${ question } \nAI: `
34- const config = await getUserConfig ( )
3538 const apiUrl = config . customOpenAiApiUrl
3639
3740 let answer = ''
@@ -89,10 +92,13 @@ export async function generateAnswersWithGptCompletionApi(
8992export async function generateAnswersWithChatgptApi ( port , question , session , apiKey , modelName ) {
9093 const { controller, messageListener } = setAbortController ( port )
9194
92- const prompt = getConversationPairs ( session . conversationRecords , false )
95+ const config = await getUserConfig ( )
96+ const prompt = getConversationPairs (
97+ session . conversationRecords . slice ( - config . maxConversationContextLength ) ,
98+ false ,
99+ )
93100 prompt . unshift ( { role : 'system' , content : await getChatSystemPromptBase ( ) } )
94101 prompt . push ( { role : 'user' , content : question } )
95- const config = await getUserConfig ( )
96102 const apiUrl = config . customOpenAiApiUrl
97103
98104 let answer = ''
0 commit comments