gen_ai_hub.orchestration_v2.models.message module¶
Defines message-related models for LLM-based conversations, including system, user, assistant, tool, and developer messages.
- class gen_ai_hub.orchestration_v2.models.message.Role(*values)¶
Bases:
str,EnumEnumerates supported roles in LLM-based conversations.
This enum defines the standard roles used in interactions with Large Language Models (LLMs). These roles are generally used to structure the input and distinguish between different parts of the conversation.
- Values:
USER: Represents the human user’s input in the conversation.
SYSTEM: Represents system-level instructions or context setting for the LLM.
ASSISTANT: Represents the LLM’s responses in the conversation.
TOOL: Represents a tool or function that the LLM can call.
DEVELOPER: Represents the developer’s input or instructions in the conversation.
- USER = 'user'¶
- SYSTEM = 'system'¶
- ASSISTANT = 'assistant'¶
- TOOL = 'tool'¶
- DEVELOPER = 'developer'¶
- class gen_ai_hub.orchestration_v2.models.message.SystemMessage(*, role: Role = Role.SYSTEM, content: str | List[TextPart])¶
Bases:
ABCBaseModelRepresents a system message in a prompt or conversation template.
System messages typically provide context or instructions to the AI model.
- Parameters:
role – The role of the entity sending the message.
content – The text content of the system message.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.message.UserMessage(*, role: Role = Role.USER, content: str | TextPart | ImagePart | List[str | TextPart | ImagePart | ImageItem])¶
Bases:
ABCBaseModelRepresents a user message in a prompt or conversation template.
User messages typically contain queries or inputs from the user.
- Parameters:
role – The role of the entity sending the message.
content – The message content, which may be plain text or a sequence of text and images.
- classmethod content_validation(content)¶
Validates and maps the content field to the appropriate types.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.message.AssistantMessage(*, role: Role = Role.ASSISTANT, content: str | List[TextPart] | None = None, refusal: str | None = None, tool_calls: List[MessageToolCall] | None = None)¶
Bases:
ABCBaseModelRepresents an assistant message in a prompt or conversation template.
Assistant messages typically contain responses or outputs from the AI model.
- Parameters:
role – The role of the entity sending the message.
content – The text content of the assistant message.
refusal – A string indicating refusal reason.
tool_calls – A list of tool call objects.
- refusal: str | None¶
- tool_calls: List[MessageToolCall] | None¶
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.message.ToolChatMessage(*, role: Role = Role.TOOL, tool_call_id: str, content: str | List[TextPart])¶
Bases:
ABCBaseModel- tool_call_id: str¶
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.message.DeveloperChatMessage(*, role: Role = Role.DEVELOPER, content: str | List[TextPart])¶
Bases:
ABCBaseModel- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.message.ResponseChatMessage(*, role: Role = Role.ASSISTANT, content: str, refusal: str | None = None, tool_calls: List[MessageToolCall] | None = None)¶
Bases:
ABCBaseModelRepresents a response message in a conversation.
- Parameters:
role – The role of the entity sending the message.
content – The text content of the assistant message.
refusal – A string indicating refusal reason.
tool_calls – A list of tool call objects.
- content: str¶
- refusal: str | None¶
- tool_calls: List[MessageToolCall] | None¶
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.message.FunctionCall(*, name: str, arguments: str)¶
Bases:
ABCBaseModelRepresents a function call with its name and arguments.
- name¶
str The name of the function to call.
- Type:
str
- arguments¶
str The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
- Type:
str
- name: str¶
- arguments: str¶
- parse_arguments() dict¶
Parses the arguments string as JSON.
- Returns:
A dictionary representing the parsed arguments.
- Return type:
dict
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class gen_ai_hub.orchestration_v2.models.message.MessageToolCall(*, id: str, type: Literal['function'] = 'function', function: FunctionCall)¶
Bases:
ABCBaseModelThe tool calls generated by the model, such as function calls.
- id¶
The ID of the tool call.
- Type:
str
- type¶
The type of the tool. Currently, only function is supported.
- Type:
Literal[‘function’]
- function¶
The function that the model called.
- id: str¶
- type: Literal['function']¶
- function: FunctionCall¶
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].