Skip to content

Commit 7935d63

Browse files
committed
feat: add ai_agent info (box/box-openapi#485)
1 parent 11e3a31 commit 7935d63

File tree

7 files changed

+107
-7
lines changed

7 files changed

+107
-7
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "a839036", "specHash": "544d370", "version": "1.5.0" }
1+
{ "engineHash": "a839036", "specHash": "d7dfe68", "version": "1.5.0" }

Box.Sdk.Gen/Managers/Ai/AiManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public async System.Threading.Tasks.Task<AiAgentAskOrAiAgentExtractOrAiAgentExtr
7373

7474
/// <summary>
7575
/// Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs.
76-
/// Freeform metadata extraction does not require any metadata template setup before sending the request.
76+
/// In this request, both the prompt and the output can be freeform.
77+
/// Metadata template setup before sending the request is not required.
7778
/// </summary>
7879
/// <param name="requestBody">
7980
/// Request body of createAiExtract method
@@ -93,7 +94,8 @@ public async System.Threading.Tasks.Task<AiResponse> CreateAiExtractAsync(AiExtr
9394

9495
/// <summary>
9596
/// Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
96-
/// For this request, you need to use an already defined metadata template or a define a schema yourself.
97+
/// For this request, you either need a metadata template or a list of fields you want to extract.
98+
/// Input is **either** a metadata template or a list of fields to ensure the structure.
9799
/// 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)
98100
/// or use the [metadata template API](g://metadata/templates/create).
99101
/// </summary>

Box.Sdk.Gen/Managers/Ai/IAiManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public interface IAiManager {
5050

5151
/// <summary>
5252
/// Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs.
53-
/// Freeform metadata extraction does not require any metadata template setup before sending the request.
53+
/// In this request, both the prompt and the output can be freeform.
54+
/// Metadata template setup before sending the request is not required.
5455
/// </summary>
5556
/// <param name="requestBody">
5657
/// Request body of createAiExtract method
@@ -65,7 +66,8 @@ public interface IAiManager {
6566

6667
/// <summary>
6768
/// Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
68-
/// For this request, you need to use an already defined metadata template or a define a schema yourself.
69+
/// For this request, you either need a metadata template or a list of fields you want to extract.
70+
/// Input is **either** a metadata template or a list of fields to ensure the structure.
6971
/// 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)
7072
/// or use the [metadata template API](g://metadata/templates/create).
7173
/// </summary>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Box.Sdk.Gen;
2+
using System.Text.Json.Serialization;
3+
using System.Collections.Generic;
4+
using Box.Sdk.Gen.Internal;
5+
using System;
6+
using System.Collections.ObjectModel;
7+
8+
namespace Box.Sdk.Gen.Schemas {
9+
public class AiAgentInfo : ISerializable {
10+
/// <summary>
11+
/// The models used for the request
12+
/// </summary>
13+
[JsonPropertyName("models")]
14+
public IReadOnlyList<AiAgentInfoModelsField>? Models { get; init; }
15+
16+
/// <summary>
17+
/// The processor used for the request
18+
/// </summary>
19+
[JsonPropertyName("processor")]
20+
public string? Processor { get; init; }
21+
22+
public AiAgentInfo() {
23+
24+
}
25+
internal string? RawJson { get; set; } = default;
26+
27+
void ISerializable.SetJson(string json) {
28+
RawJson = json;
29+
}
30+
31+
string? ISerializable.GetJson() {
32+
return RawJson;
33+
}
34+
35+
/// <summary>
36+
/// Returns raw json response returned from the API.
37+
/// </summary>
38+
public Dictionary<string, object?>? GetRawData() {
39+
return SimpleJsonSerializer.GetAllFields(this);
40+
}
41+
42+
}
43+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Box.Sdk.Gen;
2+
using System.Text.Json.Serialization;
3+
using System.Collections.Generic;
4+
using Box.Sdk.Gen.Internal;
5+
6+
namespace Box.Sdk.Gen.Schemas {
7+
public class AiAgentInfoModelsField : ISerializable {
8+
/// <summary>
9+
/// The name of the model used for the request
10+
/// </summary>
11+
[JsonPropertyName("name")]
12+
public string? Name { get; init; }
13+
14+
/// <summary>
15+
/// The provider that owns the model used for the request
16+
/// </summary>
17+
[JsonPropertyName("provider")]
18+
public string? Provider { get; init; }
19+
20+
/// <summary>
21+
/// The supported purpose utilized by the model used for the request
22+
/// </summary>
23+
[JsonPropertyName("supported_purpose")]
24+
public string? SupportedPurpose { get; init; }
25+
26+
public AiAgentInfoModelsField() {
27+
28+
}
29+
internal string? RawJson { get; set; } = default;
30+
31+
void ISerializable.SetJson(string json) {
32+
RawJson = json;
33+
}
34+
35+
string? ISerializable.GetJson() {
36+
return RawJson;
37+
}
38+
39+
/// <summary>
40+
/// Returns raw json response returned from the API.
41+
/// </summary>
42+
public Dictionary<string, object?>? GetRawData() {
43+
return SimpleJsonSerializer.GetAllFields(this);
44+
}
45+
46+
}
47+
}

Box.Sdk.Gen/Schemas/AiResponse/AiResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Text.Json.Serialization;
33
using System.Collections.Generic;
44
using Box.Sdk.Gen.Internal;
5+
using Box.Sdk.Gen.Schemas;
56

67
namespace Box.Sdk.Gen.Schemas {
78
public class AiResponse : ISerializable {
@@ -23,6 +24,9 @@ public class AiResponse : ISerializable {
2324
[JsonPropertyName("completion_reason")]
2425
public string? CompletionReason { get; init; }
2526

27+
[JsonPropertyName("ai_agent_info")]
28+
public AiAgentInfo? AiAgentInfo { get; init; }
29+
2630
public AiResponse(string answer, System.DateTimeOffset createdAt) {
2731
Answer = answer;
2832
CreatedAt = createdAt;

docs/Ai.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ The response depends on the agent configuration requested in this endpoint.
109109
## Extract metadata (freeform)
110110

111111
Sends an AI request to supported Large Language Models (LLMs) and extracts metadata in form of key-value pairs.
112-
Freeform metadata extraction does not require any metadata template setup before sending the request.
112+
In this request, both the prompt and the output can be freeform.
113+
Metadata template setup before sending the request is not required.
113114

114115
This operation is performed by calling function `CreateAiExtract`.
115116

@@ -141,7 +142,8 @@ A response including the answer from the LLM.
141142
## Extract metadata (structured)
142143

143144
Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
144-
For this request, you need to use an already defined metadata template or a define a schema yourself.
145+
For this request, you either need a metadata template or a list of fields you want to extract.
146+
Input is **either** a metadata template or a list of fields to ensure the structure.
145147
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)
146148
or use the [metadata template API](g://metadata/templates/create).
147149

0 commit comments

Comments
 (0)