cuery.prompt ============ .. py:module:: cuery.prompt .. autoapi-nested-parse:: Prompt base class. Encapsulates lists of messages with functionality for loading from configuration files, rendering to rich text, handling Jinja templating for dynamic content, and validating required variables Attributes ---------- .. autoapisummary:: cuery.prompt.ROLE_STYLES Classes ------- .. autoapisummary:: cuery.prompt.Message cuery.prompt.Prompt Module Contents --------------- .. py:data:: ROLE_STYLES .. py:class:: Message(/, **data) Bases: :py:obj:`pydantic.BaseModel` Message class for chat completions. .. py:attribute:: content :type: str .. py:attribute:: role :type: str :value: 'user' .. py:method:: __rich_console__(console, options) .. py:class:: Prompt(/, **data) Bases: :py:obj:`pydantic.BaseModel` Prompt class for chat completions. This class represents a chat prompt consisting of multiple messages. Each message can have a role (e.g., user, assistant) and content. It can be constructed manually or from a configuration file or a string. In the latter case, automatically detects the required variables used by the Jinja template, if any. .. py:attribute:: messages :type: list[Message] :value: None .. py:attribute:: required :type: list[str] :value: None .. py:method:: validate_messages(messages) :classmethod: Allow init from other types. .. py:method:: check_required() .. py:method:: validate_required() Validate that all required variables are present in the prompt. .. py:method:: __iter__() So `dict(model)` works. .. py:method:: from_config(source) :classmethod: .. py:method:: from_string(p) :classmethod: Create a Prompt from a string. .. py:method:: substitute(**kwds) .. py:method:: render(with_roles = False, **kwds) Render the prompt messages into single string with the given variables. Not usually needed as Task, Tools etc. will do this automatically. .. py:method:: __rich_console__(console, options)