mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-21 21:52:07 +02:00
completion context limit check
This commit is contained in:
parent
6fc33525d8
commit
cac31cc171
1 changed files with 3 additions and 1 deletions
|
@ -27,11 +27,13 @@ export async function sendRequest(turns, systemMessage, stop_seq='***') {
|
|||
messages: messages,
|
||||
stop: stop_seq,
|
||||
});
|
||||
if (completion.choices[0].finish_reason == 'length')
|
||||
throw new Error('Context length exceeded');
|
||||
console.log('Received.')
|
||||
res = completion.choices[0].message.content;
|
||||
}
|
||||
catch (err) {
|
||||
if (err.code == 'context_length_exceeded' && turns.length > 1) {
|
||||
if ((err.message == 'Context length exceeded' || err.code == 'context_length_exceeded') && turns.length > 1) {
|
||||
console.log('Context length exceeded, trying again with shorter context.');
|
||||
return await sendRequest(turns.slice(1), systemMessage, stop_seq);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue