ums.utils.types

This represents the basic types used to interact with the management. The types are implemented using pydantic. It provides validation, allow JSON serialization and works well with FastAPI which is used internally for the http request between the agents and the management.

Example

        ex = AgentMessage(
                id="ex1",
                riddle={
                        "context":"Example 1",
                        "question":"Get the name of the person."
                },
                data=[
                        RiddleData(
                                type=RiddleDataType.TEXT,
                                file_plain="./cv.txt"
                        )
                ]
        )
        ex.status.extract.required = False
        {
                "id": "ex1",
                "sub_ids": [],
                "riddle": {
                        "context": "Example 1",
                        "question": "Get the name of the person.",
                        "solutions_before": []
                },
                "solution": null,
                "data": [
                        {
                                "type": "text",
                                "file_plain": "/ums-agenten/share/cv.txt",
                                "file_extracted": null,
                                "prompt": null
                        }
                ],
                "status": {
                        "extract": {
                                "required": false,
                                "finished": false
                        },
                        "solve": {
                                "required": true,
                                "finished": false
                        },
                        "validate": {
                                "required": true,
                                "finished": false
                        },
                        "trial": 0,
                        "solved": false
                },
                "contacts": 0
        }
        ex.solution = RiddleSolution(
                solution="Otto",
                explanation="Written in line 6 after 'Name:'"
        )
        {
                ...
                "solution": {
                        "solution": "Otto",
                        "explanation": "Written in line 6 after 'Name:'",
                        "used_data": [],
                        "accepted": false,
                        "review": null
                },
                ...
        }
  1# Agenten Plattform
  2#
  3# (c) 2024 Magnus Bender
  4# 	Institute of Humanities-Centered Artificial Intelligence (CHAI)
  5# 	Universitaet Hamburg
  6# 	https://www.chai.uni-hamburg.de/~bender
  7#  
  8# source code released under the terms of GNU Public License Version 3
  9# https://www.gnu.org/licenses/gpl-3.0.txt
 10
 11"""
 12	This represents the basic types used to interact with the management.
 13	The types are implemented using [pydantic](https://docs.pydantic.dev/).
 14	It provides validation, allow JSON serialization and works well with [FastAPI](https://fastapi.tiangolo.com/) which is used internally for the http request between the agents and the management.
 15
 16	### Example
 17
 18	```python
 19		ex = AgentMessage(
 20			id="ex1",
 21			riddle={
 22				"context":"Example 1",
 23				"question":"Get the name of the person."
 24			},
 25			data=[
 26				RiddleData(
 27					type=RiddleDataType.TEXT,
 28					file_plain="./cv.txt"
 29				)
 30			]
 31		)
 32		ex.status.extract.required = False
 33	```
 34	```json
 35		{
 36			"id": "ex1",
 37			"sub_ids": [],
 38			"riddle": {
 39				"context": "Example 1",
 40				"question": "Get the name of the person.",
 41				"solutions_before": []
 42			},
 43			"solution": null,
 44			"data": [
 45				{
 46					"type": "text",
 47					"file_plain": "/ums-agenten/share/cv.txt",
 48					"file_extracted": null,
 49					"prompt": null
 50				}
 51			],
 52			"status": {
 53				"extract": {
 54					"required": false,
 55					"finished": false
 56				},
 57				"solve": {
 58					"required": true,
 59					"finished": false
 60				},
 61				"validate": {
 62					"required": true,
 63					"finished": false
 64				},
 65				"trial": 0,
 66				"solved": false
 67			},
 68			"contacts": 0
 69		}
 70	```
 71	```python
 72		ex.solution = RiddleSolution(
 73			solution="Otto",
 74			explanation="Written in line 6 after 'Name:'"
 75		)
 76	```
 77	```json
 78		{
 79			...
 80			"solution": {
 81				"solution": "Otto",
 82				"explanation": "Written in line 6 after 'Name:'",
 83				"used_data": [],
 84				"accepted": false,
 85				"review": null
 86			},
 87			...
 88		}
 89	```
 90
 91"""
 92
 93import os, warnings
 94
 95from enum import Enum
 96
 97from typing import List, Any
 98from typing_extensions import Annotated
 99
100from pydantic import (
101    BaseModel,
102    ValidationError, ValidationInfo,
103    ValidatorFunctionWrapHandler
104)
105from pydantic.functional_validators import WrapValidator, AfterValidator
106
107from ums.utils.const import SHARE_PATH
108from ums.utils.schema import ExtractionSchema
109
110class RiddleInformation(BaseModel):
111	# ignore:
112	#	/usr/local/lib/python3.12/dist-packages/pydantic/_internal/_fields.py:172:
113	# 		UserWarning: Field name "validate" in "RiddleStatus" shadows an attribute in parent 
114	# 				"RiddleInformation"
115	warnings.filterwarnings('ignore', category=UserWarning, lineno=172, module="pydantic")
116
117	"""
118		This is the basic class used as superclass for all message and infos
119		about a riddle.
120	"""
121
122class RiddleDataType(Enum):
123	"""
124		Enum for the three types of data used in a riddle.
125	"""
126	
127	TEXT = "text"
128	IMAGE = "image"
129	AUDIO = "audio"
130
131def _check_data_file(file_name:str) -> str:
132	if not file_name.startswith('/'):
133		file_name = os.path.join(SHARE_PATH, file_name)
134	
135	assert file_name.startswith(SHARE_PATH), "The data file needs to be in {}!".format(SHARE_PATH)
136
137	file_name = os.path.realpath(file_name, strict=False)
138
139	assert os.path.isfile(file_name), "The data file {} does not exist!".format(file_name)
140	
141	return file_name
142
143def _ignore_file_missing(
144		v: Any, handler: ValidatorFunctionWrapHandler, info: ValidationInfo
145	) -> str:
146	try:
147		return handler(v)
148	except ValidationError:
149		if not info.context is None and \
150			"require_file_exists" in info.context and \
151			info.context["require_file_exists"] == False and \
152			isinstance(v, str):
153				return "missing:{}".format(v)
154		else:
155			raise
156
157class RiddleData(RiddleInformation):
158
159	"""
160		A data item to be used to solve the riddle
161	"""
162
163	type: RiddleDataType
164	"""
165		The type of the data item.
166	"""
167
168	file_plain: Annotated[str, AfterValidator(_check_data_file), WrapValidator(_ignore_file_missing)] 
169	"""
170		The plain file (as path to file system) without any processing.
171
172		The path will be validated and must start with `SHARE_PATH` (or be relative to `SHARE_PATH`).
173		The file must exist.
174	"""
175
176	file_extracted: Annotated[str, AfterValidator(_check_data_file), WrapValidator(_ignore_file_missing)] | None = None
177	"""
178		The processed files (as path to file system), i.e., a schematic file containing all extracted informations.
179
180		The path will be validated and must start with `SHARE_PATH` (or be relative to `SHARE_PATH`).
181		The file must exist.
182	"""
183
184	prompt: str | ExtractionSchema | None = None 
185	"""
186		An optional prompt giving more details to the extraction agent, e.g., selecting a type of extraction/ task to do with the data.
187	"""
188
189
190class RiddleSolution(RiddleInformation):
191	"""
192		A solution of a riddle.
193	"""
194
195	solution: str
196	"""
197		The textual value of the solution.
198	"""
199
200	explanation: str
201	"""
202		An explanation of the solution.
203	"""
204
205	used_data: List[RiddleData] = []
206	"""
207		The data items used to create the solution (optional).
208	"""
209
210	accepted : bool = False
211	"""
212		If the solution is accepted by validator/ gatekeeper.
213	"""
214
215	review: str | None = None
216	"""
217		A review of the solution (if None: not tried to validate)
218	"""
219
220class Riddle(RiddleInformation):
221	"""
222		The riddle (the task description and possibly a solution)
223	"""
224	
225	context: str
226	"""
227		The context of the riddle (as textual string).
228	"""
229
230	question: str
231	"""
232		The actual main question of the riddle (as textual string).
233	"""
234
235	solutions_before: List[RiddleSolution] = []
236	"""
237		If already tried to solve this riddle before, the (not accepted) solutions are stored here
238	"""
239
240class RiddleSubStatus(RiddleInformation):
241	"""
242		The sub status for each possible step a riddle may go though.
243	"""
244	
245	required: bool = True
246	"""
247		Is this step required (i.e., requested)
248	"""
249
250	finished: bool = False
251	"""
252		Was this step already executed.
253	"""
254
255class RiddleStatus(RiddleInformation):
256	"""
257		The status of a riddle, will be mostly changed by Management when the riddle is sent to different agents while solving it.
258	"""
259	
260	extract: RiddleSubStatus = RiddleSubStatus()
261	"""
262		The first extract step (image, text, audio -> more sematic data)
263
264		The `RiddleData` items in `AgentMessage.data` shall have `file_extracted` afterwards. 
265	"""
266	
267	solve: RiddleSubStatus = RiddleSubStatus()
268	"""
269		The *main* solving step.
270
271		`AgentMessage.solution` shall be an `RiddleSolution` afterwards.
272	"""
273
274	validate: RiddleSubStatus = RiddleSubStatus()
275	"""
276		The validation step, i.e., does the gatekeeper accept the solution in `AgentMessage.solution`.
277	"""
278
279	trial: int = 0
280	"""
281		A counter for the number of trials.
282		Each time the gatekeeper does not accept a solution of this riddle, the value is incremented.
283	"""
284
285	solved: bool = False
286	"""
287		True, after the gatekeeper accepts the solution at `AgentMessage.solution`
288	"""
289
290class AgentMessage(RiddleInformation):
291	"""
292		The basic message, which is sent be the agent and the management.
293		The objects will be JSON en- and decoded.
294	"""
295
296	id: str
297	"""
298		The riddle id, e.g., ``ex1``
299		This is a unique string and identifies the riddle.
300	"""
301
302	sub_ids: List[str] = []
303	"""
304		There might be cases, when an agent decided to split in riddle in multiple *smaller* steps.
305		Each *sub* riddle will then get its own id (i.e., ``ex1-sub1``) while the sub id is added here as reference.
306	"""
307
308	riddle: Riddle
309	"""
310		The riddle to solve.
311	"""
312
313	solution: RiddleSolution | None = None
314	"""
315		The solution of the riddle (or empty if no solution available)
316	"""
317
318	data: List[RiddleData] = []
319	"""
320		The data to get the solution from.
321	"""
322
323	status: RiddleStatus = RiddleStatus()
324	"""
325		The status of the riddle.
326	"""
327
328	contacts : int = 0
329	"""
330		A counter representing the number of contacts the management had with this message.
331		Each time the management processes the message, this counter is incremented by 1.
332		Using this counter the management is able to detect cycles and stop them.
333	"""
334
335class AgentResponse(RiddleInformation):
336	"""
337		Returned by the management when receiving an `AgentMessage`.
338	"""
339
340	count : int
341	"""
342		The count of the message (overall numeric id).
343	"""
344
345	msg: str|None = None
346	"""
347		An additional message.
348	"""
349
350	error: bool = False
351	"""
352		If an error occurred.
353	"""
354
355	error_msg: str|None = None
356	"""
357		Error message (if `error` )
358	"""
359
360class MessageDbRow(BaseModel):
361	"""
362		Object representing a database row.
363	"""
364
365	count : int
366	"""
367		The count (primary key) of the item.
368	"""
369
370	sender : str
371	"""
372		The sender of the message.
373	""" 
374
375	recipient : str
376	"""
377		The recipient of the message
378	"""
379
380	time : int
381	"""
382		The time (unix timestamp) the message was received/ sent.
383	"""
384
385	message : AgentMessage
386	"""
387		The message  received/ sent.
388	"""
389
390	processed : bool
391	"""
392		Did the management process the message, i.e., did the tasks necessary for this message (mostly only relevant for received messages).
393	"""
394
395	solution : bool|None = None
396	"""
397		Does this message contain a valid solution?
398		True if contains valid solution, False if solution not valid, Null/None if not applicable
399	"""
class RiddleInformation(pydantic.main.BaseModel):
111class RiddleInformation(BaseModel):
112	# ignore:
113	#	/usr/local/lib/python3.12/dist-packages/pydantic/_internal/_fields.py:172:
114	# 		UserWarning: Field name "validate" in "RiddleStatus" shadows an attribute in parent 
115	# 				"RiddleInformation"
116	warnings.filterwarnings('ignore', category=UserWarning, lineno=172, module="pydantic")
117
118	"""
119		This is the basic class used as superclass for all message and infos
120		about a riddle.
121	"""

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes:
  • __class_vars__: The names of the class variables defined on the model.
  • __private_attributes__: Metadata about the private attributes of the model.
  • __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
  • __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
  • __pydantic_core_schema__: The core schema of the model.
  • __pydantic_custom_init__: Whether the model has a custom __init__ function.
  • __pydantic_decorators__: Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
  • __pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
  • __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
  • __pydantic_post_init__: The name of the post-init method for the model, if defined.
  • __pydantic_root_model__: Whether the model is a [RootModel][pydantic.root_model.RootModel].
  • __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.
  • __pydantic_extra__: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
  • __pydantic_fields_set__: The names of fields explicitly set during instantiation.
  • __pydantic_private__: Values of private attributes set on the model instance.
Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class RiddleDataType(enum.Enum):
123class RiddleDataType(Enum):
124	"""
125		Enum for the three types of data used in a riddle.
126	"""
127	
128	TEXT = "text"
129	IMAGE = "image"
130	AUDIO = "audio"

Enum for the three types of data used in a riddle.

TEXT = <RiddleDataType.TEXT: 'text'>
IMAGE = <RiddleDataType.IMAGE: 'image'>
AUDIO = <RiddleDataType.AUDIO: 'audio'>
Inherited Members
enum.Enum
name
value
class RiddleData(RiddleInformation):
158class RiddleData(RiddleInformation):
159
160	"""
161		A data item to be used to solve the riddle
162	"""
163
164	type: RiddleDataType
165	"""
166		The type of the data item.
167	"""
168
169	file_plain: Annotated[str, AfterValidator(_check_data_file), WrapValidator(_ignore_file_missing)] 
170	"""
171		The plain file (as path to file system) without any processing.
172
173		The path will be validated and must start with `SHARE_PATH` (or be relative to `SHARE_PATH`).
174		The file must exist.
175	"""
176
177	file_extracted: Annotated[str, AfterValidator(_check_data_file), WrapValidator(_ignore_file_missing)] | None = None
178	"""
179		The processed files (as path to file system), i.e., a schematic file containing all extracted informations.
180
181		The path will be validated and must start with `SHARE_PATH` (or be relative to `SHARE_PATH`).
182		The file must exist.
183	"""
184
185	prompt: str | ExtractionSchema | None = None 
186	"""
187		An optional prompt giving more details to the extraction agent, e.g., selecting a type of extraction/ task to do with the data.
188	"""

A data item to be used to solve the riddle

The type of the data item.

file_plain: Annotated[str, AfterValidator(func=<function _check_data_file at 0x101d893a0>), WrapValidator(func=<function _ignore_file_missing at 0x1020ad800>, json_schema_input_type=PydanticUndefined)]

The plain file (as path to file system) without any processing.

The path will be validated and must start with SHARE_PATH (or be relative to SHARE_PATH). The file must exist.

file_extracted: Optional[Annotated[str, AfterValidator(func=<function _check_data_file at 0x101d893a0>), WrapValidator(func=<function _ignore_file_missing at 0x1020ad800>, json_schema_input_type=PydanticUndefined)]]

The processed files (as path to file system), i.e., a schematic file containing all extracted informations.

The path will be validated and must start with SHARE_PATH (or be relative to SHARE_PATH). The file must exist.

prompt: str | ums.utils.schema.ExtractionSchema | None

An optional prompt giving more details to the extraction agent, e.g., selecting a type of extraction/ task to do with the data.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class RiddleSolution(RiddleInformation):
191class RiddleSolution(RiddleInformation):
192	"""
193		A solution of a riddle.
194	"""
195
196	solution: str
197	"""
198		The textual value of the solution.
199	"""
200
201	explanation: str
202	"""
203		An explanation of the solution.
204	"""
205
206	used_data: List[RiddleData] = []
207	"""
208		The data items used to create the solution (optional).
209	"""
210
211	accepted : bool = False
212	"""
213		If the solution is accepted by validator/ gatekeeper.
214	"""
215
216	review: str | None = None
217	"""
218		A review of the solution (if None: not tried to validate)
219	"""

A solution of a riddle.

solution: str

The textual value of the solution.

explanation: str

An explanation of the solution.

used_data: List[RiddleData]

The data items used to create the solution (optional).

accepted: bool

If the solution is accepted by validator/ gatekeeper.

review: str | None

A review of the solution (if None: not tried to validate)

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class Riddle(RiddleInformation):
221class Riddle(RiddleInformation):
222	"""
223		The riddle (the task description and possibly a solution)
224	"""
225	
226	context: str
227	"""
228		The context of the riddle (as textual string).
229	"""
230
231	question: str
232	"""
233		The actual main question of the riddle (as textual string).
234	"""
235
236	solutions_before: List[RiddleSolution] = []
237	"""
238		If already tried to solve this riddle before, the (not accepted) solutions are stored here
239	"""

The riddle (the task description and possibly a solution)

context: str

The context of the riddle (as textual string).

question: str

The actual main question of the riddle (as textual string).

solutions_before: List[RiddleSolution]

If already tried to solve this riddle before, the (not accepted) solutions are stored here

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class RiddleSubStatus(RiddleInformation):
241class RiddleSubStatus(RiddleInformation):
242	"""
243		The sub status for each possible step a riddle may go though.
244	"""
245	
246	required: bool = True
247	"""
248		Is this step required (i.e., requested)
249	"""
250
251	finished: bool = False
252	"""
253		Was this step already executed.
254	"""

The sub status for each possible step a riddle may go though.

required: bool

Is this step required (i.e., requested)

finished: bool

Was this step already executed.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class RiddleStatus(RiddleInformation):
256class RiddleStatus(RiddleInformation):
257	"""
258		The status of a riddle, will be mostly changed by Management when the riddle is sent to different agents while solving it.
259	"""
260	
261	extract: RiddleSubStatus = RiddleSubStatus()
262	"""
263		The first extract step (image, text, audio -> more sematic data)
264
265		The `RiddleData` items in `AgentMessage.data` shall have `file_extracted` afterwards. 
266	"""
267	
268	solve: RiddleSubStatus = RiddleSubStatus()
269	"""
270		The *main* solving step.
271
272		`AgentMessage.solution` shall be an `RiddleSolution` afterwards.
273	"""
274
275	validate: RiddleSubStatus = RiddleSubStatus()
276	"""
277		The validation step, i.e., does the gatekeeper accept the solution in `AgentMessage.solution`.
278	"""
279
280	trial: int = 0
281	"""
282		A counter for the number of trials.
283		Each time the gatekeeper does not accept a solution of this riddle, the value is incremented.
284	"""
285
286	solved: bool = False
287	"""
288		True, after the gatekeeper accepts the solution at `AgentMessage.solution`
289	"""

The status of a riddle, will be mostly changed by Management when the riddle is sent to different agents while solving it.

extract: RiddleSubStatus

The first extract step (image, text, audio -> more sematic data)

The RiddleData items in AgentMessage.data shall have file_extracted afterwards.

The main solving step.

AgentMessage.solution shall be an RiddleSolution afterwards.

@classmethod
@typing_extensions.deprecated('The `validate` method is deprecated; use `model_validate` instead.', category=None)
def validate(cls, value: Any) -> Self:
1383    @classmethod
1384    @typing_extensions.deprecated('The `validate` method is deprecated; use `model_validate` instead.', category=None)
1385    def validate(cls, value: Any) -> Self:  # noqa: D102
1386        warnings.warn(
1387            'The `validate` method is deprecated; use `model_validate` instead.', category=PydanticDeprecatedSince20
1388        )
1389        return cls.model_validate(value)

The validation step, i.e., does the gatekeeper accept the solution in AgentMessage.solution.

trial: int

A counter for the number of trials. Each time the gatekeeper does not accept a solution of this riddle, the value is incremented.

solved: bool

True, after the gatekeeper accepts the solution at AgentMessage.solution

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
update_forward_refs
class AgentMessage(RiddleInformation):
291class AgentMessage(RiddleInformation):
292	"""
293		The basic message, which is sent be the agent and the management.
294		The objects will be JSON en- and decoded.
295	"""
296
297	id: str
298	"""
299		The riddle id, e.g., ``ex1``
300		This is a unique string and identifies the riddle.
301	"""
302
303	sub_ids: List[str] = []
304	"""
305		There might be cases, when an agent decided to split in riddle in multiple *smaller* steps.
306		Each *sub* riddle will then get its own id (i.e., ``ex1-sub1``) while the sub id is added here as reference.
307	"""
308
309	riddle: Riddle
310	"""
311		The riddle to solve.
312	"""
313
314	solution: RiddleSolution | None = None
315	"""
316		The solution of the riddle (or empty if no solution available)
317	"""
318
319	data: List[RiddleData] = []
320	"""
321		The data to get the solution from.
322	"""
323
324	status: RiddleStatus = RiddleStatus()
325	"""
326		The status of the riddle.
327	"""
328
329	contacts : int = 0
330	"""
331		A counter representing the number of contacts the management had with this message.
332		Each time the management processes the message, this counter is incremented by 1.
333		Using this counter the management is able to detect cycles and stop them.
334	"""

The basic message, which is sent be the agent and the management. The objects will be JSON en- and decoded.

id: str

The riddle id, e.g., ex1 This is a unique string and identifies the riddle.

sub_ids: List[str]

There might be cases, when an agent decided to split in riddle in multiple smaller steps. Each sub riddle will then get its own id (i.e., ex1-sub1) while the sub id is added here as reference.

riddle: Riddle

The riddle to solve.

solution: RiddleSolution | None

The solution of the riddle (or empty if no solution available)

data: List[RiddleData]

The data to get the solution from.

status: RiddleStatus

The status of the riddle.

contacts: int

A counter representing the number of contacts the management had with this message. Each time the management processes the message, this counter is incremented by 1. Using this counter the management is able to detect cycles and stop them.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class AgentResponse(RiddleInformation):
336class AgentResponse(RiddleInformation):
337	"""
338		Returned by the management when receiving an `AgentMessage`.
339	"""
340
341	count : int
342	"""
343		The count of the message (overall numeric id).
344	"""
345
346	msg: str|None = None
347	"""
348		An additional message.
349	"""
350
351	error: bool = False
352	"""
353		If an error occurred.
354	"""
355
356	error_msg: str|None = None
357	"""
358		Error message (if `error` )
359	"""

Returned by the management when receiving an AgentMessage.

count: int

The count of the message (overall numeric id).

msg: str | None

An additional message.

error: bool

If an error occurred.

error_msg: str | None

Error message (if error )

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
class MessageDbRow(pydantic.main.BaseModel):
361class MessageDbRow(BaseModel):
362	"""
363		Object representing a database row.
364	"""
365
366	count : int
367	"""
368		The count (primary key) of the item.
369	"""
370
371	sender : str
372	"""
373		The sender of the message.
374	""" 
375
376	recipient : str
377	"""
378		The recipient of the message
379	"""
380
381	time : int
382	"""
383		The time (unix timestamp) the message was received/ sent.
384	"""
385
386	message : AgentMessage
387	"""
388		The message  received/ sent.
389	"""
390
391	processed : bool
392	"""
393		Did the management process the message, i.e., did the tasks necessary for this message (mostly only relevant for received messages).
394	"""
395
396	solution : bool|None = None
397	"""
398		Does this message contain a valid solution?
399		True if contains valid solution, False if solution not valid, Null/None if not applicable
400	"""

Object representing a database row.

count: int

The count (primary key) of the item.

sender: str

The sender of the message.

recipient: str

The recipient of the message

time: int

The time (unix timestamp) the message was received/ sent.

message: AgentMessage

The message received/ sent.

processed: bool

Did the management process the message, i.e., did the tasks necessary for this message (mostly only relevant for received messages).

solution: bool | None

Does this message contain a valid solution? True if contains valid solution, False if solution not valid, Null/None if not applicable

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs