gen_ai_hub.orchestration.models.message module¶
- class gen_ai_hub.orchestration.models.message.FunctionCall(name: str | None = None, arguments: str | None = None)¶
Bases:
objectThe function that the model called.
- name: str | None = None¶
- arguments: str | None = None¶
- parse_arguments() dict¶
Parses the arguments string as JSON.
- Returns:
A dictionary representing the parsed arguments.
- Return type:
dict
- __init__(name: str | None = None, arguments: str | None = None) None¶
- class gen_ai_hub.orchestration.models.message.MessageToolCall(id: str, type: Literal['function'], function: FunctionCall)¶
Bases:
objectRepresents a tool call within a message, specifically a function call.
- id: str¶
- type: Literal['function']¶
- function: FunctionCall¶
- to_dict()¶
Converts the MessageToolCall instance to a dictionary.
- Returns:
A dictionary representation of the MessageToolCall instance.
- Return type:
dict
- __init__(id: str, type: Literal['function'], function: FunctionCall) None¶
- class gen_ai_hub.orchestration.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.models.message.Message(role: Role | str, content: str | List[TextPart | ImagePart], refusal: str | None = None, tool_calls: List[MessageToolCall] | None = None)¶
Bases:
JSONSerializableRepresents a single message in a prompt or conversation template.
This base class defines the structure for all types of messages in a prompt, including content and role.
- 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.
- refusal: str | None = None¶
- tool_calls: List[MessageToolCall] | None = None¶
- to_dict()¶
Converts the Message instance to a dictionary.
- Returns:
A dictionary representation of the Message instance.
- Return type:
dict
- __init__(role: Role | str, content: str | List[TextPart | ImagePart], refusal: str | None = None, tool_calls: List[MessageToolCall] | None = None) None¶
- class gen_ai_hub.orchestration.models.message.SystemMessage(content: str)¶
Bases:
MessageRepresents a system message in a prompt or conversation template.
System messages typically provide context or instructions to the AI model.
- __init__(content: str)¶
Initializes a SystemMessage instance.
- Parameters:
content (str) – The text content of the system message.
- class gen_ai_hub.orchestration.models.message.UserMessage(content: str | List[str | ImageItem])¶
Bases:
MessageRepresents a user message in a prompt or conversation template.
User messages typically contain queries or inputs from the user.
- class gen_ai_hub.orchestration.models.message.AssistantMessage(content: str, refusal: str | None = None, tool_calls: List[MessageToolCall] | None = None)¶
Bases:
MessageRepresents an assistant message in a prompt or conversation template.
Assistant messages typically contain responses or outputs from the AI model.
- __init__(content: str, refusal: str | None = None, tool_calls: List[MessageToolCall] | None = None)¶
Initializes an AssistantMessage instance.
- Parameters:
content (str) – The text content of the assistant message.
refusal (Optional[str], optional) – A string indicating refusal reason, defaults to None
tool_calls (Optional[List[MessageToolCall]], optional) – A list of tool call objects, defaults to None
- class gen_ai_hub.orchestration.models.message.ToolMessage(content: str, tool_call_id: str)¶
Bases:
MessageRepresents a tool message in a prompt or conversation template.
- Parameters:
Message (str) – The text content of the tool message.
- __init__(content: str, tool_call_id: str)¶
Initializes a ToolMessage instance.
- Parameters:
content (str) – The text content of the tool message.
tool_call_id (str) – The ID of the tool call associated with this message.
- to_dict()¶
Converts the ToolMessage instance to a dictionary.
- Returns:
A dictionary representation of the ToolMessage instance.
- Return type:
dict