sotopia-lab / sotopia

Sotopia: an Open-ended Social Learning Environment (ICLR 2024 spotlight)
https://docs.sotopia.world
MIT License
166 stars 20 forks source link

doc: API endpoints for sotopia #242

Closed XuhuiZhou closed 4 days ago

XuhuiZhou commented 3 weeks ago

This is an initial design of the Sotopia API

Closes #

📑 Description

✅ Checks

ℹ Additional Information

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 72.88%. Comparing base (19d39e0) to head (80063cc). Report is 20 commits behind head on main.

@@           Coverage Diff           @@
##             main     #242   +/-   ##
=======================================
  Coverage   72.88%   72.88%           
=======================================
  Files          58       58           
  Lines        2972     2972           
=======================================
  Hits         2166     2166           
  Misses        806      806           

see 2 files with indirect coverage changes


🚨 Try these New Features:

ProKil commented 3 weeks ago

My high level question is whether we should allow agent and scenario design to be of a custom schema?

XuhuiZhou commented 3 weeks ago

Not for now? Imo the current schema is quite flexible. You can literally squeeze so much info into public information and secret. I do think we should re visit how we compose those schema tho

On Wed, Oct 30, 2024 at 6:13 PM Hao Zhu @.***> wrote:

My high level question is whether we should allow agent and scenario design to be of a custom schema?

— Reply to this email directly, view it on GitHub https://github.com/sotopia-lab/sotopia/pull/242#issuecomment-2448556106, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE35IXOYEDPGBW6VHIQHM73Z6FKXVAVCNFSM6AAAAABQ422FJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBYGU2TMMJQGY . You are receiving this because you authored the thread.Message ID: @.***>

ProKil commented 3 weeks ago

It would be great if we can allow people who use our apis to bring their own agent specifications, i.e. having a generic AgentProfile

XuhuiZhou commented 3 weeks ago

Please give a concrete example in terms of fastAPI

On Wed, Oct 30, 2024 at 11:55 PM Hao Zhu @.***> wrote:

It would be great if we can allow people who use our apis to bring their own agent specifications, i.e. having a generic AgentProfile

— Reply to this email directly, view it on GitHub https://github.com/sotopia-lab/sotopia/pull/242#issuecomment-2448964348, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE35IXI77J7B7DV73675N6DZ6GS3JAVCNFSM6AAAAABQ422FJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBYHE3DIMZUHA . You are receiving this because you authored the thread.Message ID: @.***>

ProKil commented 3 weeks ago

Sure, a new api "PUT add_agentprofile_schema" with parameters "schema_name" and "schema"

An example input:

{
    schema_name: "AI assistants",
    schema: "{'title': 'AIAssistant', 'type': 'object', 'properties': {'name': {'title': 'Name', 'type': 'string'}, 'role_description': {'title': 'Role Description', 'type': 'string'}, 'tools': {'title': 'Tools', 'type': 'array', 'items': {'type': 'string'}}}, 'required': ['name', 'role_description', 'tools']}"
}
XuhuiZhou commented 2 weeks ago

Let's merge this imo

XuhuiZhou commented 2 weeks ago

Cool It looks great. Just left some final request changes.

BTW, in all of endpoints /{get/post}/... seems to be not useful, i.e. we might just do GET /agents instead of GET /get/agents.

@ProKil why get is not useful? we want to disabiguiate from post right?

ProKil commented 2 weeks ago

Cool It looks great. Just left some final request changes. BTW, in all of endpoints /{get/post}/... seems to be not useful, i.e. we might just do GET /agents instead of GET /get/agents.

@ProKil why get is not useful? we want to disabiguiate from post right?

Since when you send an request, you will specify whether the method is GET/POST/PUT/DEL, have these method names in the end point is redundant.

For example,

import requests

# Make a GET request
response = requests.get('https://api.example.com/data')

# Make a POST request
data = ...
response = requests.post('https://api.example.com/data', json=data)

You don't need to use ' requests.get('https://api.example.com/get/data')'