Skip to content

Commit

Permalink
update api of get messages and runs
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed May 21, 2024
1 parent e06a0ec commit 271c8e4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/agentscope/web/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,31 @@ class Message(db.Model): # type: ignore[name-defined]

def get_history_messages(run_id: str) -> list:
"""Interface to get history messages. (Query from database for now)"""
return Message.query.filter_by(run_id=run_id).all()
messages = Message.query.filter_by(run_id=run_id).all()
return [
{
"name": message.name,
"content": message.content,
"url": message.url,
}
for message in messages
]


def get_runs() -> list:
"""Interface to get all runs. (Query from database for now)"""
return Run.all()
runs = Run.query.all()
return [
{
"id": run.id,
"project": run.project,
"name": run.name,
"script_path": run.script_path,
"run_dir": run.run_dir,
"create_time": run.create_time.isoformat(),
}
for run in runs
]


@app.route("/api/register/run", methods=["POST"])
Expand Down

0 comments on commit 271c8e4

Please sign in to comment.