gen_ai_hub.orchestration.models.message module

class gen_ai_hub.orchestration.models.message.FunctionCall(name: str | None = None, arguments: str | None = None)

Bases: object

The 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: object

Represents 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, Enum

Enumerates 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: JSONSerializable

Represents 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.

role: Role | str
content: str | List[TextPart | ImagePart]
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: Message

Represents 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: Message

Represents a user message in a prompt or conversation template.

User messages typically contain queries or inputs from the user.

__init__(content: str | List[str | ImageItem])

Initializes a UserMessage instance.

Parameters:

content (Union[str, List[Union[str, ImageItem]]]) – The message content, which may be plain text or a sequence of text and images.

Raises:

TypeError – If the content list contains unsupported types.

class gen_ai_hub.orchestration.models.message.AssistantMessage(content: str, refusal: str | None = None, tool_calls: List[MessageToolCall] | None = None)

Bases: Message

Represents 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: Message

Represents 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