定义通用数据结构和接口的 Python 包,适用于数据处理、算法、后端等模块间共享
Project description
fanceai_types模块
数据结构定义
fanceai_types/common.py
主要定义系统中的通用数据结构,包括数据处理、算法、后端等需要在模块间共享的数据结构。
定义为pydantic.BaseModel的子类。
接口定义
接口定义按照其业务逻辑写在对应名字的文件中,例如推荐逻辑的接口,可以写在fanceai_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fanceai_types-0.1.0.tar.gz
(7.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fanceai_types-0.1.0.tar.gz.
File metadata
- Download URL: fanceai_types-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ad1b087cb1414453ba7a075256d6da9a731b0fa0ad9982cd9f2bef75c3a4726
|
|
| MD5 |
d3b281c33829fb3f5eec3f2faf28e531
|
|
| BLAKE2b-256 |
80829b55b96514e8c48fd15f293d7fdea6e0f9b93175b584b2c3c9af398e0759
|
File details
Details for the file fanceai_types-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fanceai_types-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f683483b9cffa44dbbcf0363eeca362c4274a48d46a0af9c913988d5b6ac0df
|
|
| MD5 |
51b429de8375dc987d26e7b67af490d2
|
|
| BLAKE2b-256 |
5fc8940efdcddc5551d60b795d12fa5f9f01fba05df5309e8b6b89e15bfb67f1
|