role
¶
Role-related functionality for SilverLingua.
This module provides enums and utilities for handling different types of roles in conversations: - Chat roles (system, human, AI, etc.) - React roles (thought, observation, action, etc.)
ChatRole
¶
Bases: Enum
Standardized roles for chat messages.
Warning
Do not instantiate this enum directly. Use [create_chat_role()][silverlingua.core.atoms.role.chat.create_chat_role] instead.
TOOL_RESPONSE
class-attribute
instance-attribute
¶
TOOL_RESPONSE = RoleMember('TOOL_RESPONSE', 'TOOL_RESPONSE')
RoleMember
¶
Used in ChatRole and ReactRole.
Warning
Do not instantiate this class directly. See [ChatRole][silverlingua.core.atoms.role.chat.ChatRole] and [ReactRole][silverlingua.core.atoms.role.react.ReactRole] for more information.
Source code in src/SilverLingua/core/atoms/role/member.py
ReactRole
¶
Bases: Enum
Standardized roles for ReAct framework to help with chain-of-thought prompting.
See: https://www.promptingguide.ai/techniques/react
Warning
Do not instantiate this enum directly. Use [create_react_role()][silverlingua.core.atoms.role.react.create_react_role] instead.
OBSERVATION
class-attribute
instance-attribute
¶
OBSERVATION = RoleMember('OBSERVATION', 'OBSERVATION')
create_chat_role
¶
create_chat_role(name: str, SYSTEM: str, HUMAN: str, AI: str, TOOL_CALL: str, TOOL_RESPONSE: str) -> Type[ChatRole]
Create a new ChatRole enum with only the values of the RoleMembers changed.
This will ensure that the parent of each member is ChatRole, which means that the members will be equal to the members of ChatRole.
Example
Source code in src/SilverLingua/core/atoms/role/chat.py
create_react_role
¶
create_react_role(name: str, QUESTION: str, THOUGHT: str, ACTION: str, OBSERVATION: str, ANSWER: str) -> Type[ReactRole]