Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose and add default Json serialization to ToolConfig #778

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

realdavidvega
Copy link
Contributor

@realdavidvega realdavidvega commented Aug 21, 2024

Background

Currently, tool input decoding and output encoding is using the global Json serialization configuration.

This configuration, by default, uses ignoreUnknownKeys = true in Json serialization, which is useful when the provider, like OpenAI, returns unknown keys that are not supported yet. However, on tools, it provokes swallowing decoding errors of non-strict tool inputs, and can lead to unexpected results. When not swallowing this error, the assistant can recover from this kind of problems by trying again.

Also, by default it uses explicitNulls = false, so the assistant sometimes interprets that the absence of the key means that there is not value. This leads to the assistant not calling a Tool, which not happens so often when we pass a pattern of { key: null }, so the assistant interprets that it has to call a Tool to recover that information.

This PR

In any case, this PR makes the tool decoding and encoding to use a separate Json serialization configuration object, which can be specified per tool, and is by default Json.Default. Allowing to override the Json configuration per tool based on the consumer needs.

In future, we could improve the input encoding by adding the strict: true parameter per tool, as supported in OpenAI.

@javipacheco javipacheco merged commit 46a4d4f into main Aug 22, 2024
6 checks passed
@javipacheco javipacheco deleted the feature/tool-json-config branch August 22, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants