Derive Macro openai_func_enums::FunctionCallResponse
source · #[derive(FunctionCallResponse)]
{
// Attributes available to this derive:
#[func_description]
}
Expand description
This procedural macro derives the FunctionCallResponse
trait for an enum.
The derive macro expects an enum and it generates a new struct for each variant of the enum.
The generated struct is named by appending “Response” to the variant’s name. Each struct has the same fields as the variant.
Also, a name
, to_function_call
and get_function_json
method is implemented for each struct.
In the get_function_json
method, any description provided through the func_description
attribute is used.
§Usage
#[derive(FunctionCallResponse)]
#[func_description]
enum MyEnum {
Variant1,
Variant2,
}
Note: This macro can only be applied to enums and it requires the func_description
attribute to be applied to the enum.