Implement #4
This commit is contained in:
@ -40,7 +40,7 @@
|
||||
"question": "Get the name of the person.",
|
||||
"solutions_before": []
|
||||
},
|
||||
"solution": null,
|
||||
"solution": [],
|
||||
"data": [
|
||||
{
|
||||
"type": "text",
|
||||
@ -77,13 +77,13 @@
|
||||
```json
|
||||
{
|
||||
...
|
||||
"solution": {
|
||||
"solution": [{
|
||||
"solution": "Otto",
|
||||
"explanation": "Written in line 6 after 'Name:'",
|
||||
"used_data": [],
|
||||
"accepted": false,
|
||||
"review": null
|
||||
},
|
||||
}],
|
||||
...
|
||||
}
|
||||
```
|
||||
@ -98,11 +98,11 @@ from typing import List, Any
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import (
|
||||
BaseModel,
|
||||
ValidationError, ValidationInfo,
|
||||
ValidatorFunctionWrapHandler
|
||||
BaseModel,
|
||||
ValidationError, ValidationInfo,
|
||||
ValidatorFunctionWrapHandler,
|
||||
WrapValidator, AfterValidator, BeforeValidator
|
||||
)
|
||||
from pydantic.functional_validators import WrapValidator, AfterValidator
|
||||
|
||||
from ums.utils.const import SHARE_PATH
|
||||
from ums.utils.schema import ExtractionSchema
|
||||
@ -268,12 +268,12 @@ class RiddleStatus(RiddleInformation):
|
||||
"""
|
||||
The *main* solving step.
|
||||
|
||||
`AgentMessage.solution` shall be an `RiddleSolution` afterwards.
|
||||
`AgentMessage.solution` shall contain an `RiddleSolution` afterwards.
|
||||
"""
|
||||
|
||||
validate: RiddleSubStatus = RiddleSubStatus()
|
||||
"""
|
||||
The validation step, i.e., does the gatekeeper accept the solution in `AgentMessage.solution`.
|
||||
The validation step, i.e., does the gatekeeper accept the solution(s) in `AgentMessage.solution`.
|
||||
"""
|
||||
|
||||
trial: int = 0
|
||||
@ -284,9 +284,13 @@ class RiddleStatus(RiddleInformation):
|
||||
|
||||
solved: bool = False
|
||||
"""
|
||||
True, after the gatekeeper accepts the solution at `AgentMessage.solution`
|
||||
True, after the gatekeeper accepts the solution(s) at `AgentMessage.solution`
|
||||
"""
|
||||
|
||||
def _transform_to_list(value : Any) -> List[Any]:
|
||||
# type check of items is done next by pydantic
|
||||
return value if isinstance(value, list) else [value]
|
||||
|
||||
class AgentMessage(RiddleInformation):
|
||||
"""
|
||||
The basic message, which is sent be the agent and the management.
|
||||
@ -310,9 +314,10 @@ class AgentMessage(RiddleInformation):
|
||||
The riddle to solve.
|
||||
"""
|
||||
|
||||
solution: RiddleSolution | None = None
|
||||
solution: Annotated[List[RiddleSolution], BeforeValidator(_transform_to_list)] = []
|
||||
"""
|
||||
The solution of the riddle (or empty if no solution available)
|
||||
The solutions of the riddle (or empty list if no solutions available)
|
||||
(When assigning a single object of `RiddleSolution` will be convert to list with this single object.)
|
||||
"""
|
||||
|
||||
data: List[RiddleData] = []
|
||||
|
Reference in New Issue
Block a user