View Source LangChain.FunctionParam (LangChain v0.1.6)
Define a function parameter as a struct. Used to generate the expected
JSONSchema data for describing one or more arguments being passed to a
LangChain.Function
.
Note: This is not intended to be a fully compliant implementation of JSONSchema types. This is intended to be a convenience for working with the most common situations when working with an LLM that understands JSONSchema.
Supports:
- simple values - string, integer, number, boolean
- enum values -
enum: ["alpha", "beta"]
. The values can be strings, integers, etc. - array values -
type: :array
couples withitem_type: "string"
to express it is an array of.item_type
is optional. When omitted, it can be a mixed array.item_type: "object"
allows for creating an array of objects. Useobject_properties: [...]
to describe the structure of the objects.
- objects - Define the object's expected values or supported structure using
object_properties
.
The function to_parameters_schema/1
is used to convert a list of
FunctionParam
structs into a JSONSchema formatted data map.
Summary
Functions
Build a new FunctionParam struct.
Build a new FunctionParam
struct and return it or raise an error if invalid.
Return the list of required property names.
Transform a FunctionParam
to a JSONSchema compatible definition that is
added to the passed in data
map.
Transform a list of FunctionParam
structs into a map expressing the structure
in a JSONSchema compatible way.
Types
Functions
@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Build a new FunctionParam struct.
Build a new FunctionParam
struct and return it or raise an error if invalid.
Return the list of required property names.
Transform a FunctionParam
to a JSONSchema compatible definition that is
added to the passed in data
map.
Transform a list of FunctionParam
structs into a map expressing the structure
in a JSONSchema compatible way.