Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

add description and required control#32

Open
adamskrodzki wants to merge 3 commits into
aspecto-io:masterfrom
adamskrodzki:master
Open

add description and required control#32
adamskrodzki wants to merge 3 commits into
aspecto-io:masterfrom
adamskrodzki:master

Conversation

@adamskrodzki
Copy link
Copy Markdown

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.

Comment thread src/schema-builder.ts Outdated
case 'number':
if (Number.isInteger(value)) {
return { type: ValueType.Integer };
return description ? { type: ValueType.Integer, description } : { type: ValueType.Integer };
Copy link
Copy Markdown
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.

Comment thread src/schema-builder.ts

if (!options?.noRequired) {
schema.required = keys;
if(obj["excludeFromRequired"]){
Copy link
Copy Markdown
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

Comment thread src/schema-builder.ts Outdated
let description : string | undefined = undefined;

if(obj["addDescriptionOfProperty"]){
description= obj["addDescriptionOfProperty"](key);
Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant