Module: Entities
- class diskurs.entities.AccessMode
Bases:
EnumEnumeration representing different access modes or states for fields.
- INPUT = 'input'
- LOCKED = 'locked'
- OUTPUT = 'output'
- PER_TURN = 'per_turn'
- class diskurs.entities.ChatMessage
Bases:
JsonSerializableChatMessage(role: ‘Role’, content: ‘Optional[str]’ = ‘’, name: ‘Optional[str]’ = ‘’, tool_call_id: ‘Optional[str]’ = ‘’, tool_calls: ‘Optional[list[ToolCall]]’ = None, type: ‘MessageType’ = <MessageType.CONVERSATION: ‘conversation’>)
- __init__(role, content='', name='', tool_call_id='', tool_calls=None, type=MessageType.CONVERSATION)
- Parameters:
role (Role)
content (str | None)
name (str | None)
tool_call_id (str | None)
tool_calls (list[ToolCall] | None)
type (MessageType)
- Return type:
None
- content: str | None = ''
- classmethod from_dict(data)
- name: str | None = ''
- to_dict()
- tool_call_id: str | None = ''
- type: MessageType = 'conversation'
- class diskurs.entities.DiskursInput
Bases:
JsonSerializableDiskursInput(metadata: ‘Optional[dict[str, Any]]’ = <factory>, user_query: ‘Optional[str]’ = ‘’, conversation_id: ‘Optional[str]’ = ‘’)
- __init__(metadata=<factory>, user_query='', conversation_id='')
- Parameters:
metadata (dict[str, Any] | None)
user_query (str | None)
conversation_id (str | None)
- Return type:
None
- conversation_id: str | None = ''
- classmethod from_dict(data)
- metadata: dict[str, Any] | None
- to_dict()
- user_query: str | None = ''
- class diskurs.entities.InputField
Bases:
objectInput field type for dataclasses.
- static __new__(cls, value=None)
- class diskurs.entities.JsonSerializable
Bases:
objectJsonSerializable()
- __init__()
- Return type:
None
- classmethod from_dict(data)
- to_dict()
- class diskurs.entities.LockedField
Bases:
objectLocked field type for dataclasses.
- static __new__(cls, value=None)
- class diskurs.entities.LongtermMemory
Bases:
JsonSerializableLongtermMemory(user_query: ‘str’ = ‘’)
- __init__(user_query='')
- Parameters:
user_query (str)
- Return type:
None
- classmethod from_dict(data, reset_per_turn=True)
Create a new instance from a dictionary, applying special handling for per-turn fields.
- Parameters:
data – Dictionary containing serialized field values
reset_per_turn – Whether to reset per-turn fields during deserialization
- Returns:
A new instance with fields initialized from the dictionary
- reset_per_turn_fields()
Reset all fields marked with PerTurnField decorator to their default values.
- Returns:
A new LongtermMemory instance with per-turn fields reset
- Return type:
- to_dict()
- update(prompt_argument)
Update fields in the longterm memory using values from a PromptArgument. Only fields of type OutputField in the PromptArgument will be copied to the LongtermMemory if they have matching names.
- Parameters:
prompt_argument (PromptArgument | LongtermMemory) – The PromptArgument to copy fields from
- Returns:
A new LongtermMemory instance with updated fields
- Return type:
- user_query: str = ''
- class diskurs.entities.MessageType
Bases:
EnumEnum to represent the type of message
- CONDUCTOR = 'conductor'
- CONVERSATION = 'conversation'
- class diskurs.entities.OutputField
Bases:
objectOutput field type for dataclasses.
- static __new__(cls, value=None)
- class diskurs.entities.PerTurnField
Bases:
objectField that resets between conversation turns.
- static __new__(cls, value=None)
- class diskurs.entities.PromptArgument
Bases:
JsonSerializablePromptArgument()
- __init__()
- Return type:
None
- classmethod from_dict(data)
- get_output_fields()
Returns a dictionary containing only the fields that should be included in JSON output. This includes fields with OutputField annotation and fields with no specific annotation.
- Returns:
Dictionary of field names to values that should be included in output
- Return type:
dict[str, Any]
- init(source)
Initialize a new instance by reading the fields of another PromptArgument or LongtermMemory. Only fields of type InputField will be copied from the source.
- Parameters:
source (PromptArgument | LongtermMemory) – The source object to copy fields from
- Returns:
A new instance with InputField values copied from source
- Return type:
- to_dict()
- update(other)
Return a new instance with all non-locked/non-input fields taken from other.
- Parameters:
other (PromptArgument)
- Return type:
- class diskurs.entities.PromptField
Bases:
object- __init__(access_mode)
- Parameters:
access_mode (str)
- Return type:
None
- is_input()
Check if this field has INPUT access mode.
- Return type:
bool
- is_locked()
Check if this field has LOCKED access mode.
- Return type:
bool
- is_output()
Check if this field has OUTPUT access mode.
- Return type:
bool
- is_per_turn()
Check if this field should be reset between turns.
- Return type:
bool
- class diskurs.entities.ResultHolder
Bases:
JsonSerializableResultHolder(result: ‘Optional[dict[str, Any]]’ = None)
- __init__(result=None)
- Parameters:
result (dict[str, Any] | None)
- Return type:
None
- classmethod from_dict(data)
- result: dict[str, Any] | None = None
- to_dict()
- class diskurs.entities.Role
Bases:
EnumEnumeration of roles in the conversation.
- ASSISTANT = 'assistant'
- SYSTEM = 'system'
- TOOL = 'tool'
- USER = 'user'
- class diskurs.entities.RoutingRule
Bases:
JsonSerializableA rule used for deterministic routing decisions
- __init__(name, description, condition, target_agent)
- Parameters:
name (str)
description (str)
condition (Callable[['Conversation'], bool])
target_agent (str)
- Return type:
None
- condition: Callable[['Conversation'], bool]
- description: str
- classmethod from_dict(data)
- name: str
- target_agent: str
- to_dict()
- class diskurs.entities.ToolCall
Bases:
JsonSerializableToolCall(tool_call_id: ‘str’, function_name: ‘str’, arguments: ‘dict[str, Any]’)
- __init__(tool_call_id, function_name, arguments)
- Parameters:
tool_call_id (str)
function_name (str)
arguments (dict[str, Any])
- Return type:
None
- arguments: dict[str, Any]
- classmethod from_dict(data)
- function_name: str
- to_dict()
- tool_call_id: str
- class diskurs.entities.ToolCallResult
Bases:
objectToolCallResult(tool_call_id: ‘str’, function_name: ‘str’, result: ‘Any’)
- __init__(tool_call_id, function_name, result)
- Parameters:
tool_call_id (str)
function_name (str)
result (Any)
- Return type:
None
- function_name: str
- result: Any
- tool_call_id: str
- class diskurs.entities.ToolDescription
Bases:
objectToolDescription(name: ‘str’, description: ‘str’, arguments: ‘dict[str, dict[str, str]]’)
- __init__(name, description, arguments)
- Parameters:
name (str)
description (str)
arguments (dict[str, dict[str, str]])
- Return type:
None
- arguments: dict[str, dict[str, str]]
- description: str
- classmethod from_function(function)
Create a ToolDescription instance from a decorated function. Assumes the function has been annotated with the @tool decorator.
- Parameters:
function (Callable)
- name: str