agentsociety.webapi.api.agent_template

Module Contents

Classes

ParamOption

Param

Parameter edited at frontend

NameTypeDescription

Name, type and description of agent to describe context / status attribute

AgentParam

Agent parameter

BlockParam

Block parameter

Functions

list_agent_templates

List all agent templates

get_agent_template

Get agent template by ID

convert_agent_template_from_db_to_api

Convert agent template from DB format to API format

create_agent_template

Create a new agent template

update_agent_template

Update an existing agent template

delete_agent_template

Delete an agent template

get_agent_blocks

Get available block types

simplify_type

Convert type annotation to a simplified string format for human readable

parse_pydantic_to_table

解析pydantic model为适合前端表格呈现的JSON格式

parse_pydantic_to_antd_form

解析pydantic model为适合AntDesign表单的JSON格式

get_agent_param

Get agent’s parameters including ParamsType, BlockOutputType, Context and StatusAttributes based on agent type and class

get_block_param

Get Block’s parameters including ParamsType and Context for specified block type

get_agent_classes

Get available agent classes base on agent type

get_workflow_functions

Get available workflow function names

Data

API

agentsociety.webapi.api.agent_template.__all__

[‘router’]

agentsociety.webapi.api.agent_template.router

‘APIRouter(…)’

async agentsociety.webapi.api.agent_template.list_agent_templates(request: fastapi.Request) agentsociety.webapi.models.ApiResponseWrapper[List[agentsociety.webapi.models.agent_template.ApiAgentTemplate]]

List all agent templates

async agentsociety.webapi.api.agent_template.get_agent_template(request: fastapi.Request, template_id: str) agentsociety.webapi.models.ApiResponseWrapper[agentsociety.webapi.models.agent_template.ApiAgentTemplate]

Get agent template by ID

agentsociety.webapi.api.agent_template.convert_agent_template_from_db_to_api(template: agentsociety.webapi.models.agent_template.AgentTemplateDB) agentsociety.webapi.models.agent_template.ApiAgentTemplate

Convert agent template from DB format to API format

async agentsociety.webapi.api.agent_template.create_agent_template(request: fastapi.Request, template: agentsociety.webapi.models.agent_template.ApiAgentTemplate = Body(...)) agentsociety.webapi.models.ApiResponseWrapper[agentsociety.webapi.models.agent_template.ApiAgentTemplate]

Create a new agent template

async agentsociety.webapi.api.agent_template.update_agent_template(request: fastapi.Request, template_id: str, template: agentsociety.webapi.models.agent_template.ApiAgentTemplate = Body(...)) agentsociety.webapi.models.ApiResponseWrapper[agentsociety.webapi.models.agent_template.ApiAgentTemplate]

Update an existing agent template

async agentsociety.webapi.api.agent_template.delete_agent_template(request: fastapi.Request, template_id: str) agentsociety.webapi.models.ApiResponseWrapper[Dict[str, str]]

Delete an agent template

async agentsociety.webapi.api.agent_template.get_agent_blocks(request: fastapi.Request) agentsociety.webapi.models.ApiResponseWrapper[List[str]]

Get available block types

class agentsociety.webapi.api.agent_template.ParamOption

Bases: pydantic.BaseModel

label: str

None

value: Any

None

class agentsociety.webapi.api.agent_template.Param

Bases: pydantic.BaseModel

Parameter edited at frontend

name: str

None

required: bool

None

default: Optional[Any]

None

description: Optional[str]

None

type: Literal[str, int, float, bool, sqlalchemy.select, select_multiple]

None

options: List[agentsociety.webapi.api.agent_template.ParamOption]

[]

class agentsociety.webapi.api.agent_template.NameTypeDescription

Bases: pydantic.BaseModel

Name, type and description of agent to describe context / status attribute

name: str

None

type: str

None

description: Optional[str]

None

agentsociety.webapi.api.agent_template.simplify_type(type_annotation)

Convert type annotation to a simplified string format for human readable

agentsociety.webapi.api.agent_template.parse_pydantic_to_table(model_class: type[pydantic.BaseModel], exclude_fields: list[str] = []) list[agentsociety.webapi.api.agent_template.NameTypeDescription]

解析pydantic model为适合前端表格呈现的JSON格式

Args: model_class: Pydantic BaseModel子类

Returns: list: 包含表格配置的列表

agentsociety.webapi.api.agent_template.parse_pydantic_to_antd_form(model_class: type[pydantic.BaseModel], exclude_fields: list[str] = []) list[agentsociety.webapi.api.agent_template.Param]

解析pydantic model为适合AntDesign表单的JSON格式

Args: model_class: Pydantic BaseModel子类

Returns: list: 包含表格配置的列表

class agentsociety.webapi.api.agent_template.AgentParam

Bases: pydantic.BaseModel

Agent parameter

params_type: List[agentsociety.webapi.api.agent_template.Param]

None

context: List[agentsociety.webapi.api.agent_template.NameTypeDescription]

None

status_attributes: List[agentsociety.webapi.api.agent_template.NameTypeDescription]

None

async agentsociety.webapi.api.agent_template.get_agent_param(request: fastapi.Request, agent_type: str, agent_class: str) agentsociety.webapi.models.ApiResponseWrapper[agentsociety.webapi.api.agent_template.AgentParam]

Get agent’s parameters including ParamsType, BlockOutputType, Context and StatusAttributes based on agent type and class

class agentsociety.webapi.api.agent_template.BlockParam

Bases: pydantic.BaseModel

Block parameter

params_type: List[agentsociety.webapi.api.agent_template.Param]

None

context: List[agentsociety.webapi.api.agent_template.NameTypeDescription]

None

async agentsociety.webapi.api.agent_template.get_block_param(request: fastapi.Request, block_type: str) agentsociety.webapi.models.ApiResponseWrapper[agentsociety.webapi.api.agent_template.BlockParam]

Get Block’s parameters including ParamsType and Context for specified block type

async agentsociety.webapi.api.agent_template.get_agent_classes(request: fastapi.Request, agent_type: str) agentsociety.webapi.models.ApiResponseWrapper[List[Dict[str, str]]]

Get available agent classes base on agent type

async agentsociety.webapi.api.agent_template.get_workflow_functions(request: fastapi.Request) agentsociety.webapi.models.ApiResponseWrapper[List[str]]

Get available workflow function names