Messages via Types with Validation etc.
This commit is contained in:
@ -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
|
@ -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}")
|
||||
|
Reference in New Issue
Block a user