添加自定义代码
添加自定义代码
本页面介绍如何向您的 Python SDK 添加自定义逻辑、方法和依赖项。
Before getting started, read about how Fern SDKs use custom code and learn about the
.fernignore file.添加自定义逻辑
开始添加自定义代码:
添加自定义 SDK 方法
Fern also allows you to add custom methods to the SDK itself (e.g.
client.my_method() ) by inheriting the Fern generated client and then
extending it.
在 ElevenLabs 的 Python SDK 中查看使用此流程的示例。
更新 generators.yml 配置
将您的 Fern 生成的客户端命名为 BaseClient,以反映
该客户端将被扩展。配置生成器以在名为 base_client.py 的文件中输出
客户端。
generators.yml
导入并扩展生成的客户端
首先,从 .base_client.py 导入 Fern 生成的基础客户端并扩展它们以创建您的自定义客户端。然后,添加您想要的任何方法。
src/<package>/client.py
在 ElevenLabs 查看示例 client.py。
添加自定义依赖项
专业版和企业版功能
此功能仅适用于专业版和企业版计划。如需开始使用,请联系 support@buildwithfern.com。
要添加您的自定义代码所需的包,请更新您的 generators.yml。
generators.yml