Fixed history poisoning on empty tool response
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/ai-utils",
|
"name": "@ztimson/ai-utils",
|
||||||
"version": "1.2.10",
|
"version": "1.2.11",
|
||||||
"description": "AI Utility library",
|
"description": "AI Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ export class OpenAi extends LLMProvider {
|
|||||||
}));
|
}));
|
||||||
history.splice(i, 1, ...tools);
|
history.splice(i, 1, ...tools);
|
||||||
i += tools.length - 1;
|
i += tools.length - 1;
|
||||||
} else if(h.role === 'tool' && h.content) {
|
} else if(h.role === 'tool') {
|
||||||
const record = history.find(h2 => h.tool_call_id == h2.id);
|
const record = history.find(h2 => h.tool_call_id == h2.id);
|
||||||
if(record) {
|
if(record) {
|
||||||
if(h.content.includes('"error":')) record.error = h.content;
|
if(h.content?.includes('"error":')) record.error = h.content;
|
||||||
else record.content = h.content;
|
else record.content = h.content || '';
|
||||||
}
|
}
|
||||||
history.splice(i, 1);
|
history.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
|
|||||||
Reference in New Issue
Block a user