From 7935d631ee8bed0f3ef67a280649dd2192952f43 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 4 Dec 2024 11:37:43 -0800 Subject: [PATCH] feat: add ai_agent info (box/box-openapi#485) --- .codegen.json | 2 +- Box.Sdk.Gen/Managers/Ai/AiManager.cs | 6 ++- Box.Sdk.Gen/Managers/Ai/IAiManager.cs | 6 ++- .../Schemas/AiAgentInfo/AiAgentInfo.cs | 43 +++++++++++++++++ .../AiAgentInfo/AiAgentInfoModelsField.cs | 47 +++++++++++++++++++ Box.Sdk.Gen/Schemas/AiResponse/AiResponse.cs | 4 ++ docs/Ai.md | 6 ++- 7 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfo.cs create mode 100644 Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfoModelsField.cs diff --git a/.codegen.json b/.codegen.json index a93c0c4c..a72dcf1f 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "a839036", "specHash": "544d370", "version": "1.5.0" } +{ "engineHash": "a839036", "specHash": "d7dfe68", "version": "1.5.0" } diff --git a/Box.Sdk.Gen/Managers/Ai/AiManager.cs b/Box.Sdk.Gen/Managers/Ai/AiManager.cs index 26a31ff8..2e10258f 100644 --- a/Box.Sdk.Gen/Managers/Ai/AiManager.cs +++ b/Box.Sdk.Gen/Managers/Ai/AiManager.cs @@ -73,7 +73,8 @@ public async System.Threading.Tasks.Task /// Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs. - /// Freeform metadata extraction does not require any metadata template setup before sending the request. + /// In this request, both the prompt and the output can be freeform. + /// Metadata template setup before sending the request is not required. /// /// /// Request body of createAiExtract method @@ -93,7 +94,8 @@ public async System.Threading.Tasks.Task CreateAiExtractAsync(AiExtr /// /// Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs. - /// For this request, you need to use an already defined metadata template or a define a schema yourself. + /// For this request, you either need a metadata template or a list of fields you want to extract. + /// Input is **either** a metadata template or a list of fields to ensure the structure. /// To learn more about creating templates, see [Creating metadata templates in the Admin Console](https://support.box.com/hc/en-us/articles/360044194033-Customizing-Metadata-Templates) /// or use the [metadata template API](g://metadata/templates/create). /// diff --git a/Box.Sdk.Gen/Managers/Ai/IAiManager.cs b/Box.Sdk.Gen/Managers/Ai/IAiManager.cs index 95984312..8294487a 100644 --- a/Box.Sdk.Gen/Managers/Ai/IAiManager.cs +++ b/Box.Sdk.Gen/Managers/Ai/IAiManager.cs @@ -50,7 +50,8 @@ public interface IAiManager { /// /// Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs. - /// Freeform metadata extraction does not require any metadata template setup before sending the request. + /// In this request, both the prompt and the output can be freeform. + /// Metadata template setup before sending the request is not required. /// /// /// Request body of createAiExtract method @@ -65,7 +66,8 @@ public interface IAiManager { /// /// Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs. - /// For this request, you need to use an already defined metadata template or a define a schema yourself. + /// For this request, you either need a metadata template or a list of fields you want to extract. + /// Input is **either** a metadata template or a list of fields to ensure the structure. /// To learn more about creating templates, see [Creating metadata templates in the Admin Console](https://support.box.com/hc/en-us/articles/360044194033-Customizing-Metadata-Templates) /// or use the [metadata template API](g://metadata/templates/create). /// diff --git a/Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfo.cs b/Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfo.cs new file mode 100644 index 00000000..1dd86902 --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfo.cs @@ -0,0 +1,43 @@ +using Box.Sdk.Gen; +using System.Text.Json.Serialization; +using System.Collections.Generic; +using Box.Sdk.Gen.Internal; +using System; +using System.Collections.ObjectModel; + +namespace Box.Sdk.Gen.Schemas { + public class AiAgentInfo : ISerializable { + /// + /// The models used for the request + /// + [JsonPropertyName("models")] + public IReadOnlyList? Models { get; init; } + + /// + /// The processor used for the request + /// + [JsonPropertyName("processor")] + public string? Processor { get; init; } + + public AiAgentInfo() { + + } + internal string? RawJson { get; set; } = default; + + void ISerializable.SetJson(string json) { + RawJson = json; + } + + string? ISerializable.GetJson() { + return RawJson; + } + + /// + /// Returns raw json response returned from the API. + /// + public Dictionary? GetRawData() { + return SimpleJsonSerializer.GetAllFields(this); + } + + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfoModelsField.cs b/Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfoModelsField.cs new file mode 100644 index 00000000..4722cbbd --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfoModelsField.cs @@ -0,0 +1,47 @@ +using Box.Sdk.Gen; +using System.Text.Json.Serialization; +using System.Collections.Generic; +using Box.Sdk.Gen.Internal; + +namespace Box.Sdk.Gen.Schemas { + public class AiAgentInfoModelsField : ISerializable { + /// + /// The name of the model used for the request + /// + [JsonPropertyName("name")] + public string? Name { get; init; } + + /// + /// The provider that owns the model used for the request + /// + [JsonPropertyName("provider")] + public string? Provider { get; init; } + + /// + /// The supported purpose utilized by the model used for the request + /// + [JsonPropertyName("supported_purpose")] + public string? SupportedPurpose { get; init; } + + public AiAgentInfoModelsField() { + + } + internal string? RawJson { get; set; } = default; + + void ISerializable.SetJson(string json) { + RawJson = json; + } + + string? ISerializable.GetJson() { + return RawJson; + } + + /// + /// Returns raw json response returned from the API. + /// + public Dictionary? GetRawData() { + return SimpleJsonSerializer.GetAllFields(this); + } + + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AiResponse/AiResponse.cs b/Box.Sdk.Gen/Schemas/AiResponse/AiResponse.cs index 6bbaad17..b213aed6 100644 --- a/Box.Sdk.Gen/Schemas/AiResponse/AiResponse.cs +++ b/Box.Sdk.Gen/Schemas/AiResponse/AiResponse.cs @@ -2,6 +2,7 @@ using System.Text.Json.Serialization; using System.Collections.Generic; using Box.Sdk.Gen.Internal; +using Box.Sdk.Gen.Schemas; namespace Box.Sdk.Gen.Schemas { public class AiResponse : ISerializable { @@ -23,6 +24,9 @@ public class AiResponse : ISerializable { [JsonPropertyName("completion_reason")] public string? CompletionReason { get; init; } + [JsonPropertyName("ai_agent_info")] + public AiAgentInfo? AiAgentInfo { get; init; } + public AiResponse(string answer, System.DateTimeOffset createdAt) { Answer = answer; CreatedAt = createdAt; diff --git a/docs/Ai.md b/docs/Ai.md index 1983d35f..0f5dff38 100644 --- a/docs/Ai.md +++ b/docs/Ai.md @@ -109,7 +109,8 @@ The response depends on the agent configuration requested in this endpoint. ## Extract metadata (freeform) Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs. -Freeform metadata extraction does not require any metadata template setup before sending the request. +In this request, both the prompt and the output can be freeform. +Metadata template setup before sending the request is not required. This operation is performed by calling function `CreateAiExtract`. @@ -141,7 +142,8 @@ A response including the answer from the LLM. ## Extract metadata (structured) Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs. -For this request, you need to use an already defined metadata template or a define a schema yourself. +For this request, you either need a metadata template or a list of fields you want to extract. +Input is **either** a metadata template or a list of fields to ensure the structure. To learn more about creating templates, see [Creating metadata templates in the Admin Console](https://support.box.com/hc/en-us/articles/360044194033-Customizing-Metadata-Templates) or use the [metadata template API](g://metadata/templates/create).