Skip to content

Commit

Permalink
feat: Add aiAgent info to AiResponse (box/box-openapi#485) (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build authored Dec 9, 2024
1 parent 11e3a31 commit cbf91fc
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "a839036", "specHash": "544d370", "version": "1.5.0" }
{ "engineHash": "a839036", "specHash": "d7dfe68", "version": "1.5.0" }
6 changes: 4 additions & 2 deletions Box.Sdk.Gen/Managers/Ai/AiManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public async System.Threading.Tasks.Task<AiAgentAskOrAiAgentExtractOrAiAgentExtr

/// <summary>
/// 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.
/// </summary>
/// <param name="requestBody">
/// Request body of createAiExtract method
Expand All @@ -93,7 +94,8 @@ public async System.Threading.Tasks.Task<AiResponse> CreateAiExtractAsync(AiExtr

/// <summary>
/// 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).
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions Box.Sdk.Gen/Managers/Ai/IAiManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public interface IAiManager {

/// <summary>
/// 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.
/// </summary>
/// <param name="requestBody">
/// Request body of createAiExtract method
Expand All @@ -65,7 +66,8 @@ public interface IAiManager {

/// <summary>
/// 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).
/// </summary>
Expand Down
43 changes: 43 additions & 0 deletions Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfo.cs
Original file line number Diff line number Diff line change
@@ -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 {
/// <summary>
/// The models used for the request
/// </summary>
[JsonPropertyName("models")]
public IReadOnlyList<AiAgentInfoModelsField>? Models { get; init; }

/// <summary>
/// The processor used for the request
/// </summary>
[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;
}

/// <summary>
/// Returns raw json response returned from the API.
/// </summary>
public Dictionary<string, object?>? GetRawData() {
return SimpleJsonSerializer.GetAllFields(this);
}

}
}
47 changes: 47 additions & 0 deletions Box.Sdk.Gen/Schemas/AiAgentInfo/AiAgentInfoModelsField.cs
Original file line number Diff line number Diff line change
@@ -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 {
/// <summary>
/// The name of the model used for the request
/// </summary>
[JsonPropertyName("name")]
public string? Name { get; init; }

/// <summary>
/// The provider that owns the model used for the request
/// </summary>
[JsonPropertyName("provider")]
public string? Provider { get; init; }

/// <summary>
/// The supported purpose utilized by the model used for the request
/// </summary>
[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;
}

/// <summary>
/// Returns raw json response returned from the API.
/// </summary>
public Dictionary<string, object?>? GetRawData() {
return SimpleJsonSerializer.GetAllFields(this);
}

}
}
4 changes: 4 additions & 0 deletions Box.Sdk.Gen/Schemas/AiResponse/AiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions docs/Ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down Expand Up @@ -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).

Expand Down

0 comments on commit cbf91fc

Please sign in to comment.