跳转至

Functions(函数 (Functions))

After configuring your link type in the Ontology Manager to be many-to-many, you can use the .add() method on your link property type to add all instances of the linked object type that should be associated with the new object.

Timestamp: March 18, 2024

Why can't a 'searchAround' type ID be resolved for an object set when triggering function-backed Actions from a pipeline using the API and an OAuth token?

The third-party application token must be given access to all the object types and backing datasets used for 'searchArounds'. Additionally, the projects of the 'searchAround' object types should also be added to the application scope.

Timestamp: March 11, 2024

In functions, is Timestamp.now() always in UTC? Can it be in another (local) timezone?

It is always in UTC.

Timestamp: February 29, 2024

Is it possible to see all the places where a given function is being used to ensure it can be safely deleted?

There is no single way to ensure a function isn't used anywhere in the platform. The best available option is to check the usage history in Ontology Manager. However, dependencies that have not executed the function in a very long time, or at all, may not be revealed by checking usage history.

Timestamp: April 10, 2024

How can I handle a large number of Promises in parallel without causing timeouts in my function?

To handle a large number of Promises in parallel without causing timeouts, you should:

  1. Use asynchronous link traversal APIs (getAsync() and allAsync()) for parallel link loading.
  2. Analyze and identify performance issues using the Performance tab after a function is run.
  3. Avoid unnecessary nested loops.

Additionally, consider that there are enforced limits on function execution and a maximum of 10 concurrent fetches for limiting load on downstream services, except for link loading which is batched under the hood.

Timestamp: April 25, 2024

Is it possible to create an object and access its rid within the same function?

The rid is assigned to objects when they are created, either from indexing a backing dataset or as part of an action, but not immediately within the function where the object is created. The changes to objects and links, including the assignment of rid, are propagated after the function has finished executing.

Timestamp: April 16, 2024

Is there a way to access the executing user's ID in a function without passing it as a parameter?

No, there is no way to get the executing user's ID within a function without passing it as a parameter.

Timestamp: April 16, 2024

Can you write functions on objects that are created on an Ontology branch?

You can currently only write functions on objects on the master branch.

Timestamp: April 16, 2024

Is it possible to delete a function from Ontology Manager?

The following options are available to manage the visibility of functions:

  • Hide/unhide a function: Consumers of the function will not be broken
  • Hard delete all versions of a function: Consumers of any version will be broken.

To hide or delete a function, carry out the following steps in the code repository that contains the source of the function:

    1. Open the code repository.
    1. Go to the Functions tab at the bottom.
    1. Select the function you want to hard delete or hide.
    1. Open settings, located at the top right, and then either select the Hide function or Delete function option.

Timestamp: July 10, 2024

Is there support for streaming responses from LLM queries in Ontology functions?

No, there is currently no support for streaming responses from LLM queries in Ontology functions, but the feature is actively being worked on.

Timestamp: June 17, 2024

How can I filter an object type using a string array containing the object RIDs?

You can use the Objects.search().objectType([rid1, rid2,...]) method to directly filter the object type with object RIDs.

Timestamp: December 20, 2024


中文翻译


函数 (Functions)

在 Ontology Manager 中将链接类型配置为多对多后,可以在链接属性类型上使用 .add() 方法,添加所有应与新对象关联的链接对象类型实例。

时间戳: 2024 年 3 月 18 日

当使用 API 和 OAuth 令牌从管道触发基于函数的操作时,为什么无法解析对象集的 'searchAround' 类型 ID?

第三方应用令牌必须被授予访问所有用于 'searchAround' 的对象类型及支撑数据集 (backing datasets) 的权限。此外,'searchAround' 对象类型的项目也应添加到应用作用域 (application scope) 中。

时间戳: 2024 年 3 月 11 日

在函数中,Timestamp.now() 是否始终使用 UTC 时间?能否使用其他(本地)时区?

始终使用 UTC 时间。

时间戳: 2024 年 2 月 29 日

能否查看某个函数的所有使用位置,以确保可以安全删除?

目前没有单一方法能确保函数在平台中未被任何地方使用。最佳方案是检查 Ontology Manager 中的使用历史记录。但长时间未执行或从未执行过该函数的依赖项,可能无法通过检查使用历史记录发现。

时间戳: 2024 年 4 月 10 日

如何在函数中并行处理大量 Promises 而不导致超时?

要并行处理大量 Promises 而不导致超时,应:

  1. 使用异步链接遍历 API(getAsync()allAsync())实现并行链接加载。
  2. 运行函数后,通过性能 (Performance) 选项卡分析并识别性能问题。
  3. 避免不必要的嵌套循环。

此外,请注意函数执行存在强制限制,且为限制下游服务负载,最多支持 10 个并发获取请求,但链接加载会在底层进行批处理。

时间戳: 2024 年 4 月 25 日

能否在同一个函数中创建对象并访问其 rid

rid 在对象创建时分配(无论是通过索引支撑数据集还是作为操作的一部分),但不会在创建对象的函数中立即生效。对象和链接的变更(包括 rid 的分配)会在函数执行完成后传播。

时间戳: 2024 年 4 月 16 日

能否在函数中直接获取执行用户的 ID,而无需将其作为参数传递?

不能,目前无法在函数中获取执行用户的 ID,除非将其作为参数传递。

时间戳: 2024 年 4 月 16 日

能否在 Ontology 分支 (branch) 上创建的对象上编写函数?

目前只能在主分支 (master branch) 上的对象上编写函数。

时间戳: 2024 年 4 月 16 日

能否从 Ontology Manager 中删除函数?

可通过以下选项管理函数的可见性:

  • 隐藏/取消隐藏函数:不会影响函数的使用者。
  • 硬删除函数的所有版本:会破坏所有版本的使用者。

要隐藏或删除函数,请在包含函数源代码的代码仓库中执行以下步骤:

    1. 打开代码仓库。
    1. 进入底部的函数 (Functions) 选项卡。
    1. 选择要硬删除或隐藏的函数。
    1. 打开右上角的设置,然后选择隐藏函数 (Hide function)删除函数 (Delete function) 选项。

时间戳: 2024 年 7 月 10 日

Ontology 函数是否支持 LLM 查询的流式响应 (streaming responses)?

不支持,目前 Ontology 函数不支持 LLM 查询的流式响应,但该功能正在积极开发中。

时间戳: 2024 年 6 月 17 日

如何使用包含对象 RID 的字符串数组过滤对象类型?

可以使用 Objects.search().objectType([rid1, rid2,...]) 方法直接通过对象 RID 过滤对象类型。

时间戳: 2024 年 12 月 20 日