mellea.stdlib.funcs
Functions for Mellea operations like Instruct, Chat, etc…
Functions
act
action
: the Component from which to generate.context
: the context being used as a history from which to generate the response.backend
: the backend used to generate the response.requirements
: used as additional requirements when a sampling strategy is provided.strategy
: a SamplingStrategy that describes the strategy for validating and repairing/retrying for the instruct-validate-repair pattern. None means that no particular sampling strategy is used.return_sampling_results
: attach the (successful and failed) sampling attempts to the results.format
: if set, the BaseModel to use for constrained decoding.model_options
: additional model options, which will upsert into the model/backend’s defaults.tool_calls
: if true, tool calling is enabled.
- A ModelOutputThunk if
return_sampling_results
isFalse
, else returns aSamplingResult
.
instruct
description
: The description of the instruction.context
: the context being used as a history from which to generate the response.backend
: the backend used to generate the response.requirements
: A list of requirements that the instruction can be validated against.icl_examples
: A list of in-context-learning examples that the instruction can be validated against.grounding_context
: A list of grounding contexts that the instruction can use. They can bind as variables using a (key: str, value: str | ContentBlock) tuple.user_variables
: A dict of user-defined variables used to fill in Jinja placeholders in other parameters. This requires that all other provided parameters are provided as strings.prefix
: A prefix string or ContentBlock to use when generating the instruction.output_prefix
: A string or ContentBlock that defines a prefix for the output generation. Usually you do not need this.strategy
: A SamplingStrategy that describes the strategy for validating and repairing/retrying for the instruct-validate-repair pattern. None means that no particular sampling strategy is used.return_sampling_results
: attach the (successful and failed) sampling attempts to the results.format
: If set, the BaseModel to use for constrained decoding.model_options
: Additional model options, which will upsert into the model/backend’s defaults.tool_calls
: If true, tool calling is enabled.images
: A list of images to be used in the instruction or None if none.
chat
validate
query
obj
: The object to be queried. It should be an instance of MObject or can be converted to one if necessary.query
: The string representing the query to be executed against the object.context
: the context being used as a history from which to generate the response.backend
: the backend used to generate the response.format
: format for output parsing.model_options
: Model options to pass to the backend.tool_calls
: If true, the model may make tool calls. Defaults to False.
- The result of the query as processed by the backend.
transform
obj
: The object to be queried. It should be an instance of MObject or can be converted to one if necessary.transformation
: The string representing the query to be executed against the object.context
: the context being used as a history from which to generate the response.backend
: the backend used to generate the response.format
: format for output parsing; usually not needed with transform.model_options
: Model options to pass to the backend.
- ModelOutputThunk|Any: The result of the transformation as processed by the backend. If no tools were called,
- the return type will be always be ModelOutputThunk. If a tool was called, the return type will be the return type
- of the function called, usually the type of the object passed in.