More Optim.
This commit is contained in:
27
ums/utils/schema.py
Normal file
27
ums/utils/schema.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Agenten Plattform
|
||||
#
|
||||
# (c) 2024 Magnus Bender
|
||||
# Institute of Humanities-Centered Artificial Intelligence (CHAI)
|
||||
# Universitaet Hamburg
|
||||
# https://www.chai.uni-hamburg.de/~bender
|
||||
#
|
||||
# source code released under the terms of GNU Public License Version 3
|
||||
# https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
"""
|
||||
This represents the basic types used for representing extracted information from the data.
|
||||
The types are implemented using [pydantic](https://docs.pydantic.dev/).
|
||||
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.
|
||||
|
||||
"""
|
||||
|
||||
from enum import Enum
|
||||
|
||||
from typing import List, Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
class ExtractionSchema(BaseModel):
|
||||
"""
|
||||
This is the basic class used as superclass for all extracted information from data items.
|
||||
"""
|
@ -45,7 +45,8 @@
|
||||
{
|
||||
"type": "text",
|
||||
"file_plain": "/ums-agenten/share/cv.txt",
|
||||
"file_extracted": null
|
||||
"file_extracted": null,
|
||||
"prompt": null
|
||||
}
|
||||
],
|
||||
"status": {
|
||||
@ -63,7 +64,8 @@
|
||||
},
|
||||
"trial": 0,
|
||||
"solved": false
|
||||
}
|
||||
},
|
||||
"contacts": 0
|
||||
}
|
||||
```
|
||||
```python
|
||||
@ -103,6 +105,7 @@ from pydantic import (
|
||||
from pydantic.functional_validators import WrapValidator, AfterValidator
|
||||
|
||||
from ums.utils.const import SHARE_PATH
|
||||
from ums.utils.schema import ExtractionSchema
|
||||
|
||||
class RiddleInformation(BaseModel):
|
||||
"""
|
||||
@ -172,6 +175,10 @@ class RiddleData(RiddleInformation):
|
||||
The file must exist.
|
||||
"""
|
||||
|
||||
prompt: str | ExtractionSchema | None = None
|
||||
"""
|
||||
An optional prompt giving more details to the extraction agent, e.g., selecting a type of extraction/ task to do with the data.
|
||||
"""
|
||||
|
||||
|
||||
class RiddleSolution(RiddleInformation):
|
||||
@ -312,6 +319,13 @@ class AgentMessage(RiddleInformation):
|
||||
The status of the riddle.
|
||||
"""
|
||||
|
||||
contacts : int = 0
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
|
||||
class AgentResponse(RiddleInformation):
|
||||
"""
|
||||
Returned by the management when receiving an `AgentMessage`.
|
||||
|
Reference in New Issue
Block a user