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

add description and required control #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adamskrodzki
Copy link

Intention of this PR is to upgrade this library to be easier to use with OpenAI function calling
https://openai.com/blog/function-calling-and-other-api-updates

OpenAI function calling utilize heavily not required description schema property and also works better if you can exclude some properties from required array.

switch (typeof value) {
case 'number':
if (Number.isInteger(value)) {
return { type: ValueType.Integer };
return description ? { type: ValueType.Integer, description } : { type: ValueType.Integer };
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description should be added to schema only if description is not null.

if (!options?.noRequired) {
schema.required = keys;
if(obj["excludeFromRequired"]){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

special, reserved function. Use to specify which properties should be excluded from the required of specific object schema. terurns array of names of properties that should not be included in required array

let description : string | undefined = undefined;

if(obj["addDescriptionOfProperty"]){
description= obj["addDescriptionOfProperty"](key);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

special, reserved function. function takes property name and returns description or undefined

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.

1 participant