Skip to content

Commit

Permalink
feat: support all openai function calling extra parameters (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Mar 13, 2024
1 parent dbee793 commit b067d63
Showing 1 changed file with 49 additions and 8 deletions.
57 changes: 49 additions & 8 deletions globals/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,57 @@ type ToolParameters struct {

type ToolProperties map[string]ToolProperty

// https://github.com/openai/openai-node/blob/6175eca426b15990be5e5cdb0e8497e547f87d8a/src/lib/jsonschema.ts

type JsonSchemaType any
type JSONSchemaDefinition any
type ToolProperty struct {
Type string `json:"type"`
Description string `json:"description"`
Enum *[]string `json:"enum,omitempty"`
Items *ToolItem `json:"items,omitempty"`
MinItems *int `json:"minItems,omitempty"`
MaxItems *int `json:"maxItems,omitempty"`
}
Type *JsonSchemaType `json:"type,omitempty"`
Enum *[]JsonSchemaType `json:"enum,omitempty"`
Const *JsonSchemaType `json:"const,omitempty"`

MultipleOf *int `json:"multipleOf,omitempty"`
Maximum *int `json:"maximum,omitempty"`
ExclusiveMaximum *int `json:"exclusiveMaximum,omitempty"`
Minimum *int `json:"minimum,omitempty"`
ExclusiveMinimum *int `json:"exclusiveMinimum,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
MinLength *int `json:"minLength,omitempty"`
Pattern *string `json:"pattern,omitempty"`

Items *JSONSchemaDefinition `json:"items,omitempty"`
AdditionalItems *JSONSchemaDefinition `json:"additionalItems,omitempty"`
MaxItems *int `json:"maxItems,omitempty"`
MinItems *int `json:"minItems,omitempty"`
UniqueItems *bool `json:"uniqueItems,omitempty"`
Contains *JSONSchemaDefinition `json:"contains,omitempty"`

MaxProperties *int `json:"maxProperties,omitempty"`
MinProperties *int `json:"minProperties,omitempty"`
Required *[]string `json:"required,omitempty"`
Properties *map[string]ToolProperty `json:"properties,omitempty"`
PatternProperties *map[string]ToolProperty `json:"patternProperties,omitempty"`
AdditionalProperties *JSONSchemaDefinition `json:"additionalProperties,omitempty"`
PropertyNames *JSONSchemaDefinition `json:"propertyNames,omitempty"`

type ToolItem map[string]string
If *JSONSchemaDefinition `json:"if,omitempty"`
Then *JSONSchemaDefinition `json:"then,omitempty"`
Else *JSONSchemaDefinition `json:"else,omitempty"`

AllOf *[]JSONSchemaDefinition `json:"allOf,omitempty"`
AnyOf *[]JSONSchemaDefinition `json:"anyOf,omitempty"`
OneOf *[]JSONSchemaDefinition `json:"oneOf,omitempty"`
Not *JSONSchemaDefinition `json:"not,omitempty"`

Format *string `json:"format,omitempty"`

Title *string `json:"title,omitempty"`
Description *string `json:"description,omitempty"`
Default *string `json:"default,omitempty"`
ReadOnly *bool `json:"readOnly,omitempty"`
WriteOnly *bool `json:"writeOnly,omitempty"`
Examples *JsonSchemaType `json:"examples,omitempty"`
}

type ToolCallFunction struct {
Name string `json:"name,omitempty"`
Expand Down

0 comments on commit b067d63

Please sign in to comment.