跳转至

Feature support by language(按语言划分的功能支持)

Not all features are supported by all languages. Refer to the chart below for feature support by language.

Functions capability by language AIP Logic TypeScript v1 TypeScript v2 Python Description
Ontology object support Yes Yes Yes Yes The ability to access Ontology objects in your function.
Ontology interfaces support No No Yes No The ability to access and edit Ontology interfaces in your function.
Ontology edits support Yes Yes Yes Yes The ability to edit Ontology objects in your function.
Queryable in Workshop Yes Yes Yes Yes Invoking a function from a Workshop application.
Usable in Pipeline Builder No No No Yes Calling a function from Pipeline Builder pipelines.
Functions on models support Yes Yes No No Executing live deployment models from a function.
Semantic search support Yes Yes Yes Yes Use functions to create vectors for semantic search.
Webhook support No Yes No No The ability to call webhooks from functions.
External API call support No Yes Yes Yes Querying external services from within functions.
Serverless execution support Yes Yes Yes Yes A serverless function will be spun up on demand when invoked. Refer to serverless functions below for more information.
Deployed execution support No No Yes Yes A deployed function will have dedicated resources allocated to it, ready to serve requests.
Call function from API gateway Yes Yes Yes Yes The ability to hit a query function from the API gateway.
Marketplace support Yes Yes Yes Yes The ability to package and ship functions in Marketplace.
Bring-your-own-model Yes Yes No No The ability to register a function as a model. The function interface method is a legacy approach that applies to TypeScript v1 only.

Ontology SDK support

Python and TypeScript v2 functions support the Ontology SDK (OSDK). The OSDK allows you to leverage the Ontology directly from your development environment and provides benefits such as compatibility with Developer Console and OSDK versioning. We recommend using Python or TypeScript v2 to access these benefits in your functions repository.

TypeScript v1 vs. TypeScript v2

Both TypeScript v1 and TypeScript v2 allow users to leverage TypeScript's core language features, but there are differences in supported platform features, as shown in the feature support table above. We recommend building workflows using TypeScript v2 functions to take advantage of several key improvements over TypeScript v1:

  • Serverless execution in a full Node.js runtime: TypeScript v2 functions run in a Node.js environment, supporting core modules like fs, child_process, and crypto. This enables greater compatibility with NPM libraries that interact with the file system, perform CPU-intensive tasks in parallel, or require other system-level operations.
  • First-class OSDK support: The OSDK can now be used seamlessly in TypeScript v2 functions, making it easy to reuse code, both in and out of the platform. It also provides more efficient APIs for working with large-scale Ontology data.
  • Configurable resource requests: TypeScript v2 functions allow you to request up to 8 vCPUs and 5GB of memory, offering greater control over performance and scalability.

Serverless functions

If serverless functions are enabled for your enrollment, new repositories will use serverless functions by default. We recommend using serverless functions instead of deployed functions for most use cases. With serverless functions, you can have multiple versions of a single function available on demand, making upgrades safer.

When using Python or TypeScript v2 functions, there are also some cases where deployed functions are preferred or must be used instead of serverless, but these are not common. If available, serverless functions are preferred for several reasons:

  • Serverless functions enable different versions of a single function to be executed on demand, making upgrades safer. With deployed functions, you can only run a single function version at a time.
  • Serverless functions only incur costs when executed, while deployed functions incur costs as long as the deployment is running.
  • Serverless functions require less upfront setup and long-term maintenance, as the infrastructure is managed automatically.

中文翻译


按语言划分的功能支持

并非所有语言都支持全部功能。请参阅下表了解各语言的功能支持情况。

按语言划分的函数能力 AIP Logic TypeScript v1 TypeScript v2 Python 说明
本体对象支持 在函数中访问本体对象的能力。
本体接口支持 在函数中访问和编辑本体接口的能力。
本体编辑支持 在函数中编辑本体对象的能力。
可在 Workshop 中查询 Workshop 应用中调用函数。
可在 Pipeline Builder 中使用 Pipeline Builder 管道中调用函数。
模型函数支持 通过函数执行实时部署模型。
语义搜索支持 使用函数为语义搜索创建向量。
Webhook 支持 从函数调用 webhook 的能力。
外部 API 调用支持 在函数内部查询外部服务。
无服务器执行支持 无服务器函数会在被调用时按需启动。更多信息请参见下文中的无服务器函数
部署执行支持 部署函数会分配专用资源,随时准备处理请求。
通过 API 网关调用函数 从 API 网关访问查询函数的能力。
Marketplace 支持 Marketplace 中打包和分发函数的能力。
自带模型 将函数注册为模型的能力。函数接口方法是仅适用于 TypeScript v1 的旧版方法。

本体 SDK 支持

Python 和 TypeScript v2 函数支持本体 SDK (OSDK)。OSDK 允许您直接在开发环境中利用本体,并提供与 Developer Console 兼容、OSDK 版本管理等优势。我们建议使用 Python 或 TypeScript v2 在函数仓库中享受这些优势。

TypeScript v1 与 TypeScript v2 对比

TypeScript v1 和 TypeScript v2 都允许用户利用 TypeScript 的核心语言特性,但在支持的平台功能上存在差异,如上表所示。我们建议使用 TypeScript v2 函数构建工作流,以利用相对于 TypeScript v1 的几项关键改进:

  • 在完整 Node.js 运行时中无服务器执行: TypeScript v2 函数在 Node.js 环境中运行,支持 fschild_processcrypto 等核心模块。这使得与文件系统交互、并行执行 CPU 密集型任务或需要其他系统级操作的 NPM 库具有更好的兼容性。
  • 一流的 OSDK 支持: OSDK 现在可以在 TypeScript v2 函数中无缝使用,便于在平台内外复用代码。它还提供了更高效的 API 来处理大规模本体数据。
  • 可配置的资源请求: TypeScript v2 函数允许您请求最多 8 个 vCPU 和 5GB 内存,从而更好地控制性能和可扩展性。

无服务器函数

如果您的组织启用了无服务器函数,新仓库将默认使用无服务器函数。我们建议在大多数用例中使用无服务器函数而非部署函数。使用无服务器函数,您可以按需提供单个函数的多个版本,使升级更安全。

使用 Python 或 TypeScript v2 函数时,也存在某些情况更推荐或必须使用部署函数而非无服务器函数,但这些情况并不常见。如果可用,无服务器函数因以下原因更受青睐:

  • 无服务器函数允许按需执行单个函数的不同版本,使升级更安全。使用部署函数时,一次只能运行一个函数版本。
  • 无服务器函数仅在执行时产生成本,而部署函数在部署运行期间持续产生成本。
  • 无服务器函数需要的前期设置和长期维护更少,因为基础设施是自动管理的。