Messages via Types with Validation etc.

This commit is contained in:
2024-10-06 15:09:55 +02:00
parent 4ea424e0d1
commit b889b581f2
36 changed files with 4274 additions and 215 deletions

View File

@ -0,0 +1,9 @@
# 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

View File

@ -1,12 +1,20 @@
# 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
# TEST ONLY
from ums.messages import Message, Riddle
from ums.utils import AgentMessage, RiddleData, RiddleDataType, RiddleSolution
from typing import Union
from fastapi import FastAPI
from fastapi.responses import PlainTextResponse
app = FastAPI()
@ -14,13 +22,29 @@ app = FastAPI()
def read_root():
return {"Hello": "World"}
@app.get("/test", response_class=PlainTextResponse)
@app.get("/test")
def huhu():
a = Message(
id="hu", riddle="lala"
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
ex.solution = RiddleSolution(
solution="Otto",
explanation="Written in line 6 after 'Name:'"
)
a.status.steps["extract"] = False
return a.to_json()
return ex
@app.get("/items/{item_id}")