View Source GptAgent.Events.AssistantMessageAdded (gpt_agent v6.2.0)
An OpenAI Assistants assistant message was added to a thread
Summary
Functions
Returns the struct's type spec t()
description for debugging purposes.
Ensures that struct conforms to its t()
type and all preconditions
are fulfilled.
Ensures that struct conforms to its t()
type and all preconditions
are fulfilled.
Creates a struct validating type conformance and preconditions.
Creates a struct validating type conformance and preconditions.
Returns the list of struct's fields having type others then nil
or any()
.
Returns the list of struct's fields defined with explicit types in its t()
type spec.
Types
@type t() :: %GptAgent.Events.AssistantMessageAdded{ assistant_id: GptAgent.Types.assistant_id(), content: GptAgent.Types.nonblank_string(), message_id: GptAgent.Types.message_id(), run_id: GptAgent.Types.run_id(), thread_id: GptAgent.Types.thread_id() }
Functions
Returns the struct's type spec t()
description for debugging purposes.
Domo compiled validation functions for the given struct based on the described type spec.
Ensures that struct conforms to its t()
type and all preconditions
are fulfilled.
Returns struct when it's valid in the shape of {:ok, struct}
.
Otherwise returns the error in the shape of {:error, message_by_field}
.
Takes the same options as new/2
.
Useful for struct validation when its fields changed with map syntax
or with Map
module functions.
Options are the same as for new/2
.
Examples
alias GptAgent.Events.AssistantMessageAdded
struct = AssistantMessageAdded.new!(first_field: value1, second_field: value2, ...)
{:ok, _updated_struct} =
AssistantMessageAdded.ensure_type(%{struct | first_field: new_value})
{:ok, _updated_struct} =
struct
|> Map.put(:first_field, new_value1)
|> Map.put(:second_field, new_value2)
|> AssistantMessageAdded.ensure_type()
Ensures that struct conforms to its t()
type and all preconditions
are fulfilled.
Returns struct when it's valid. Raises an ArgumentError
otherwise.
Useful for struct validation when its fields changed with map syntax
or with Map
module functions.
Examples
alias GptAgent.Events.AssistantMessageAdded
struct = AssistantMessageAdded.new!(first_field: value1, second_field: value2, ...)
AssistantMessageAdded.ensure_type!(%{struct | first_field: new_value})
struct
|> Map.put(:first_field, new_value1)
|> Map.put(:second_field, new_value2)
|> AssistantMessageAdded.ensure_type!()
Creates a struct validating type conformance and preconditions.
The argument is any Enumerable
that emits two-element tuples
(key-value pairs) during enumeration.
Returns the instance of the struct built from the given enumerable
in the shape of {:ok, struct_value}
. Does so only if struct's
field values conform to its t()
type and all field's type and struct's
type precondition functions return ok.
If conditions described above are not fulfilled, the function
returns an appropriate error in the shape of {:error, message_by_field}
.
message_by_field
is a keyword list where the key is the name of
the field and value is the string with the error message.
Keys in the enumerable
that don't exist in the struct
are automatically discarded.
Options
maybe_filter_precond_errors
- when set totrue
, the values inmessage_by_field
instead of string become a list of error messages from precondition functions. If there are no error messages from precondition functions for a field's type, then all errors are returned unfiltered. Helpful in taking one of the custom errors after executing precondition functions in a deeply nested type to communicate back to the user. F.e. when the field's type is another struct. Default isfalse
.
Examples
alias GptAgent.Events.AssistantMessageAdded
AssistantMessageAdded.new(first_field: value1, second_field: value2, ...)
Creates a struct validating type conformance and preconditions.
The argument is any Enumerable
that emits two-element tuples
(key-value pairs) during enumeration.
Returns the instance of the struct built from the given enumerable
.
Does so only if struct's field values conform to its t()
type
and all field's type and struct's type precondition functions return ok.
Raises an ArgumentError
if conditions described above are not fulfilled.
This function will check if every given key-value belongs to the struct
and raise KeyError
otherwise.
Examples
alias GptAgent.Events.AssistantMessageAdded
AssistantMessageAdded.new!(first_field: value1, second_field: value2, ...)
Returns the list of struct's fields having type others then nil
or any()
.
Does not return meta fields with __underscored__
names.
Useful for validation of the required fields for emptiness.
F.e. with validate_required/2
call in the Ecto
changeset.
Options
:include_meta
- when set totrue
, adds fields with__underscored__
names to the return list. Default isfalse
.
Returns the list of struct's fields defined with explicit types in its t()
type spec.
Does not return meta fields with __underscored__
names and fields
having any()
type by default.
Includes fields that have nil
type into the return list.
Options
:include_any_typed
- when set totrue
, adds fields withany()
type to the return list. Default isfalse
.:include_meta
- when set totrue
, adds fields with__underscored__
names to the return list. Default isfalse
.