語言

AIFunctionDeclaration.JsonSchema 屬性

定義

會取得描述函式及其輸入參數的 JSON Schema。

public:
 virtual property System::Text::Json::JsonElement JsonSchema { System::Text::Json::JsonElement get(); };
public virtual System.Text.Json.JsonElement JsonSchema { get; }
member this.JsonSchema : System.Text.Json.JsonElement
Public Overridable ReadOnly Property JsonSchema As JsonElement

屬性值

備註

指定時,會宣告一份自包含的 JSON 架構文件,描述函式及其輸入參數。 以下是一個簡單的 JSON 結構範例,該函數將兩個數字相加:

{
  "type": "object",
  "properties": {
    "a" : { "type": "number" },
    "b" : { "type": ["number","null"], "default": 1 }
  },
  "required" : ["a"]
}

結構文件中的元資料在引導 AI 函式調用中扮演重要角色。

當 AIFunction 是透過 AIFunctionFactory建立時,這個結構會自動從方法的參數中,利用配置 JsonSerializerOptions 的 和 AIJsonSchemaCreateOptions推導出來。

若未指定結構,使用聊天用戶端應假設「{}」或「true」結構,表示任何 JSON 輸入皆可接受。

適用於