Skip to main content

定义通用数据结构和接口的 Python 包,适用于数据处理、算法、后端等模块间共享

Project description

fance_types模块

数据结构定义

fance_types/common.py

主要定义系统中的通用数据结构,包括数据处理、算法、后端等需要在模块间共享的数据结构。

定义为pydantic.BaseModel的子类。

接口定义

接口定义按照其业务逻辑写在对应名字的文件中,例如推荐逻辑的接口,可以写在fance_types/recommend.py中。

接口主要包含3部分:接口名称、输入和输出。可以通过两个数据结构来定义,分别为:请求对象(Request)和响应对象(Response)。其中接口名称可以包含在请求对象中。例如:

GetInfoRequest(Request):
    """相关注释说明"""
    
    # 如果继承自agent_types.common.Request基类,那么可以设置一个请求名称,相当于该接口的名称
    # 具体用法请参考agentcortex仓库中的examples
    __request_name__ = "get_info"
    
    field1: Optional[str] = Field(
        title="该字段的标题",
        description="该字段的描述(给人看的,也可以给LLM看)",
        default=None  # "默认值(如有)"
    )
    field2: List[int] = Field(
        title="该字段的标题",
        description="该字段的描述(给人看的,也可以给LLM看)",
        default_factory=list  # 默认值也可以是工厂函数
    )
    ......

Response类的定义类似。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fance_types-0.1.3.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fance_types-0.1.3-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file fance_types-0.1.3.tar.gz.

File metadata

  • Download URL: fance_types-0.1.3.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for fance_types-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5c5a97aa60f3d02868462d746de5abcf8265925f302b9eeaa763019082e1caa2
MD5 41d236b9bac93f66001bfc7d0782d752
BLAKE2b-256 6ec461969cb8ee79d1aaa581ee332329240a2480e90cf90a3ede52c2d05f5a4b

See more details on using hashes here.

File details

Details for the file fance_types-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fance_types-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for fance_types-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0d089b1a9e628c7d14b3c1dabba8712a3d2f681abedb45421882a08abb3ccd82
MD5 3e21eb9a407383b529901cb854b097e9
BLAKE2b-256 c99ff453814fc36776d01ac20dea4f208e389b2729d19701e4dd32d6cdafd1e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page