fix bug where it would thrown errors when model provided wrong JSON

This commit is contained in:
Wlad Paiva
2023-10-23 13:51:36 -03:00
parent 2250784690
commit 355026f342
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'aibitat': patch
---
fix bug where it would thrown errors when model provided wrong JSON
+2 -2
View File
@@ -241,8 +241,8 @@ export class OpenAIProvider extends AIProvider<OpenAI> {
try {
json = JSON.parse(call.arguments)
} catch (error) {
throw new Error(
`Model created an invalid JSON: '${call.arguments}' for function '${call.name}'`,
return Promise.resolve(
`Invalid JSON parameters: ${(error as Error).message}`,
)
}