Skip to content

Commit af1dc12

Browse files
box-sdk-buildbox-sdk-build
and
box-sdk-build
authored
feat: add AI agents warnings; allow for more types of metadata value (box/box-openapi#520) (#435)
Co-authored-by: box-sdk-build <[email protected]>
1 parent a7bced8 commit af1dc12

18 files changed

+679
-58
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "42b7a5b", "specHash": "f737b7b", "version": "0.6.1" }
1+
{ "engineHash": "c2a365c", "specHash": "6a332e7", "version": "0.6.1" }

BoxSdkGen.xcodeproj/project.pbxproj

Lines changed: 176 additions & 0 deletions
Large diffs are not rendered by default.

Sources/Managers/FileMetadata/UpdateFileMetadataByIdRequestBody.swift

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@ public class UpdateFileMetadataByIdRequestBody: Codable {
2121
/// characters and must be escaped in the key.
2222
public let path: String?
2323

24-
/// The value to be set or tested.
25-
///
26-
/// Required for `add`, `replace`, and `test` operations. For `add`,
27-
/// if the value exists already the previous value will be overwritten
28-
/// by the new value. For `replace`, the value must exist before
29-
/// replacing.
30-
///
31-
/// For `test`, the existing value at the `path` location must match
32-
/// the specified value.
33-
public let value: String?
24+
public let value: MetadataInstanceValue?
3425

3526
/// The location in the metadata JSON object to move or copy a value
3627
/// from. Required for `move` or `copy` operations and must be in the
@@ -49,19 +40,11 @@ public class UpdateFileMetadataByIdRequestBody: Codable {
4940
/// The path must always be prefixed with a `/` to represent the root
5041
/// of the template. The characters `~` and `/` are reserved
5142
/// characters and must be escaped in the key.
52-
/// - value: The value to be set or tested.
53-
///
54-
/// Required for `add`, `replace`, and `test` operations. For `add`,
55-
/// if the value exists already the previous value will be overwritten
56-
/// by the new value. For `replace`, the value must exist before
57-
/// replacing.
58-
///
59-
/// For `test`, the existing value at the `path` location must match
60-
/// the specified value.
43+
/// - value:
6144
/// - from: The location in the metadata JSON object to move or copy a value
6245
/// from. Required for `move` or `copy` operations and must be in the
6346
/// format of a [JSON-Pointer](https://tools.ietf.org/html/rfc6901).
64-
public init(op: UpdateFileMetadataByIdRequestBodyOpField? = nil, path: String? = nil, value: String? = nil, from: String? = nil) {
47+
public init(op: UpdateFileMetadataByIdRequestBodyOpField? = nil, path: String? = nil, value: MetadataInstanceValue? = nil, from: String? = nil) {
6548
self.op = op
6649
self.path = path
6750
self.value = value
@@ -72,7 +55,7 @@ public class UpdateFileMetadataByIdRequestBody: Codable {
7255
let container = try decoder.container(keyedBy: CodingKeys.self)
7356
op = try container.decodeIfPresent(UpdateFileMetadataByIdRequestBodyOpField.self, forKey: .op)
7457
path = try container.decodeIfPresent(String.self, forKey: .path)
75-
value = try container.decodeIfPresent(String.self, forKey: .value)
58+
value = try container.decodeIfPresent(MetadataInstanceValue.self, forKey: .value)
7659
from = try container.decodeIfPresent(String.self, forKey: .from)
7760
}
7861

Sources/Managers/FolderMetadata/UpdateFolderMetadataByIdRequestBody.swift

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@ public class UpdateFolderMetadataByIdRequestBody: Codable {
2121
/// characters and must be escaped in the key.
2222
public let path: String?
2323

24-
/// The value to be set or tested.
25-
///
26-
/// Required for `add`, `replace`, and `test` operations. For `add`,
27-
/// if the value exists already the previous value will be overwritten
28-
/// by the new value. For `replace`, the value must exist before
29-
/// replacing.
30-
///
31-
/// For `test`, the existing value at the `path` location must match
32-
/// the specified value.
33-
public let value: String?
24+
public let value: MetadataInstanceValue?
3425

3526
/// The location in the metadata JSON object to move or copy a value
3627
/// from. Required for `move` or `copy` operations and must be in the
@@ -49,19 +40,11 @@ public class UpdateFolderMetadataByIdRequestBody: Codable {
4940
/// The path must always be prefixed with a `/` to represent the root
5041
/// of the template. The characters `~` and `/` are reserved
5142
/// characters and must be escaped in the key.
52-
/// - value: The value to be set or tested.
53-
///
54-
/// Required for `add`, `replace`, and `test` operations. For `add`,
55-
/// if the value exists already the previous value will be overwritten
56-
/// by the new value. For `replace`, the value must exist before
57-
/// replacing.
58-
///
59-
/// For `test`, the existing value at the `path` location must match
60-
/// the specified value.
43+
/// - value:
6144
/// - from: The location in the metadata JSON object to move or copy a value
6245
/// from. Required for `move` or `copy` operations and must be in the
6346
/// format of a [JSON-Pointer](https://tools.ietf.org/html/rfc6901).
64-
public init(op: UpdateFolderMetadataByIdRequestBodyOpField? = nil, path: String? = nil, value: String? = nil, from: String? = nil) {
47+
public init(op: UpdateFolderMetadataByIdRequestBodyOpField? = nil, path: String? = nil, value: MetadataInstanceValue? = nil, from: String? = nil) {
6548
self.op = op
6649
self.path = path
6750
self.value = value
@@ -72,7 +55,7 @@ public class UpdateFolderMetadataByIdRequestBody: Codable {
7255
let container = try decoder.container(keyedBy: CodingKeys.self)
7356
op = try container.decodeIfPresent(UpdateFolderMetadataByIdRequestBodyOpField.self, forKey: .op)
7457
path = try container.decodeIfPresent(String.self, forKey: .path)
75-
value = try container.decodeIfPresent(String.self, forKey: .value)
58+
value = try container.decodeIfPresent(MetadataInstanceValue.self, forKey: .value)
7659
from = try container.decodeIfPresent(String.self, forKey: .from)
7760
}
7861

Sources/Managers/Transfer/TransferManager.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public class TransferManager {
2323
/// file-level are transferred during the operation, the collaborations are
2424
/// deleted when the original user is deleted.
2525
///
26-
/// This call will be performed synchronously which might lead to a slow response
27-
/// when the source user has a large number of items in all of its folders.
26+
/// If the user has a large number of items across all folders, the call will
27+
/// be run asynchronously. If the operation is not completed within 10 minutes,
28+
/// the user will receive a 200 OK response, and the operation will continue running.
2829
///
2930
/// If the destination path has a metadata cascade policy attached to any of
3031
/// the parent folders, a metadata cascade operation will be kicked off

Sources/Schemas/AiSingleAgentResponseFull/AiSingleAgentResponseFull.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ public class AiSingleAgentResponseFull: AiSingleAgentResponse {
88
case extract
99
}
1010

11-
public let ask: AiStudioAgentAsk?
11+
public let ask: AiStudioAgentAskResponse?
1212

13-
public let textGen: AiStudioAgentTextGen?
13+
public let textGen: AiStudioAgentTextGenResponse?
1414

15-
public let extract: AiStudioAgentExtract?
15+
public let extract: AiStudioAgentExtractResponse?
1616

1717
/// Initializer for a AiSingleAgentResponseFull.
1818
///
@@ -31,7 +31,7 @@ public class AiSingleAgentResponseFull: AiSingleAgentResponse {
3131
/// - ask:
3232
/// - textGen:
3333
/// - extract:
34-
public init(id: String, origin: String, name: String, accessState: String, type: AiSingleAgentResponseTypeField? = nil, createdBy: UserBase? = nil, createdAt: Date? = nil, modifiedBy: UserBase? = nil, modifiedAt: Date? = nil, iconReference: String? = nil, allowedEntities: [AiAgentAllowedEntity]? = nil, ask: AiStudioAgentAsk? = nil, textGen: AiStudioAgentTextGen? = nil, extract: AiStudioAgentExtract? = nil) {
34+
public init(id: String, origin: String, name: String, accessState: String, type: AiSingleAgentResponseTypeField? = nil, createdBy: UserBase? = nil, createdAt: Date? = nil, modifiedBy: UserBase? = nil, modifiedAt: Date? = nil, iconReference: String? = nil, allowedEntities: [AiAgentAllowedEntity]? = nil, ask: AiStudioAgentAskResponse? = nil, textGen: AiStudioAgentTextGenResponse? = nil, extract: AiStudioAgentExtractResponse? = nil) {
3535
self.ask = ask
3636
self.textGen = textGen
3737
self.extract = extract
@@ -41,9 +41,9 @@ public class AiSingleAgentResponseFull: AiSingleAgentResponse {
4141

4242
required public init(from decoder: Decoder) throws {
4343
let container = try decoder.container(keyedBy: CodingKeys.self)
44-
ask = try container.decodeIfPresent(AiStudioAgentAsk.self, forKey: .ask)
45-
textGen = try container.decodeIfPresent(AiStudioAgentTextGen.self, forKey: .textGen)
46-
extract = try container.decodeIfPresent(AiStudioAgentExtract.self, forKey: .extract)
44+
ask = try container.decodeIfPresent(AiStudioAgentAskResponse.self, forKey: .ask)
45+
textGen = try container.decodeIfPresent(AiStudioAgentTextGenResponse.self, forKey: .textGen)
46+
extract = try container.decodeIfPresent(AiStudioAgentExtractResponse.self, forKey: .extract)
4747

4848
try super.init(from: decoder)
4949
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import Foundation
2+
3+
/// The AI Agent to be used for ask.
4+
public class AiStudioAgentAskResponse: Codable {
5+
private enum CodingKeys: String, CodingKey {
6+
case accessState = "access_state"
7+
case description
8+
case type
9+
case customInstructions = "custom_instructions"
10+
case longText = "long_text"
11+
case basicText = "basic_text"
12+
case longTextMulti = "long_text_multi"
13+
case basicTextMulti = "basic_text_multi"
14+
}
15+
16+
/// The state of the AI Agent capability. Possible values are: `enabled` and `disabled`.
17+
public let accessState: String
18+
19+
/// The description of the AI Agent.
20+
public let description: String
21+
22+
/// The type of AI agent used to handle queries.
23+
public let type: AiStudioAgentAskResponseTypeField
24+
25+
/// Custom instructions for the agent.
26+
@CodableTriState public private(set) var customInstructions: String?
27+
28+
public let longText: AiStudioAgentLongTextToolResponse?
29+
30+
public let basicText: AiStudioAgentBasicTextToolResponse?
31+
32+
public let longTextMulti: AiStudioAgentLongTextToolResponse?
33+
34+
public let basicTextMulti: AiStudioAgentBasicTextToolResponse?
35+
36+
/// Initializer for a AiStudioAgentAskResponse.
37+
///
38+
/// - Parameters:
39+
/// - accessState: The state of the AI Agent capability. Possible values are: `enabled` and `disabled`.
40+
/// - description: The description of the AI Agent.
41+
/// - type: The type of AI agent used to handle queries.
42+
/// - customInstructions: Custom instructions for the agent.
43+
/// - longText:
44+
/// - basicText:
45+
/// - longTextMulti:
46+
/// - basicTextMulti:
47+
public init(accessState: String, description: String, type: AiStudioAgentAskResponseTypeField = AiStudioAgentAskResponseTypeField.aiAgentAsk, customInstructions: TriStateField<String> = nil, longText: AiStudioAgentLongTextToolResponse? = nil, basicText: AiStudioAgentBasicTextToolResponse? = nil, longTextMulti: AiStudioAgentLongTextToolResponse? = nil, basicTextMulti: AiStudioAgentBasicTextToolResponse? = nil) {
48+
self.accessState = accessState
49+
self.description = description
50+
self.type = type
51+
self._customInstructions = CodableTriState(state: customInstructions)
52+
self.longText = longText
53+
self.basicText = basicText
54+
self.longTextMulti = longTextMulti
55+
self.basicTextMulti = basicTextMulti
56+
}
57+
58+
required public init(from decoder: Decoder) throws {
59+
let container = try decoder.container(keyedBy: CodingKeys.self)
60+
accessState = try container.decode(String.self, forKey: .accessState)
61+
description = try container.decode(String.self, forKey: .description)
62+
type = try container.decode(AiStudioAgentAskResponseTypeField.self, forKey: .type)
63+
customInstructions = try container.decodeIfPresent(String.self, forKey: .customInstructions)
64+
longText = try container.decodeIfPresent(AiStudioAgentLongTextToolResponse.self, forKey: .longText)
65+
basicText = try container.decodeIfPresent(AiStudioAgentBasicTextToolResponse.self, forKey: .basicText)
66+
longTextMulti = try container.decodeIfPresent(AiStudioAgentLongTextToolResponse.self, forKey: .longTextMulti)
67+
basicTextMulti = try container.decodeIfPresent(AiStudioAgentBasicTextToolResponse.self, forKey: .basicTextMulti)
68+
}
69+
70+
public func encode(to encoder: Encoder) throws {
71+
var container = encoder.container(keyedBy: CodingKeys.self)
72+
try container.encode(accessState, forKey: .accessState)
73+
try container.encode(description, forKey: .description)
74+
try container.encode(type, forKey: .type)
75+
try container.encode(field: _customInstructions.state, forKey: .customInstructions)
76+
try container.encodeIfPresent(longText, forKey: .longText)
77+
try container.encodeIfPresent(basicText, forKey: .basicText)
78+
try container.encodeIfPresent(longTextMulti, forKey: .longTextMulti)
79+
try container.encodeIfPresent(basicTextMulti, forKey: .basicTextMulti)
80+
}
81+
82+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Foundation
2+
3+
public enum AiStudioAgentAskResponseTypeField: CodableStringEnum {
4+
case aiAgentAsk
5+
case customValue(String)
6+
7+
public init(rawValue value: String) {
8+
switch value.lowercased() {
9+
case "ai_agent_ask".lowercased():
10+
self = .aiAgentAsk
11+
default:
12+
self = .customValue(value)
13+
}
14+
}
15+
16+
public var rawValue: String {
17+
switch self {
18+
case .aiAgentAsk:
19+
return "ai_agent_ask"
20+
case .customValue(let value):
21+
return value
22+
}
23+
}
24+
25+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Foundation
2+
3+
/// AI agent basic tool used to generate text.
4+
public class AiStudioAgentBasicGenToolResponse: AiStudioAgentBasicGenTool {
5+
private enum CodingKeys: String, CodingKey {
6+
case warnings
7+
}
8+
9+
/// Warnings concerning tool
10+
public let warnings: [String]?
11+
12+
/// Initializer for a AiStudioAgentBasicGenToolResponse.
13+
///
14+
/// - Parameters:
15+
/// - model: The model used for the AI agent for basic text. For specific model values, see the [available models list](g://box-ai/supported-models).
16+
/// - numTokensForCompletion: The number of tokens for completion.
17+
/// - llmEndpointParams: The parameters for the LLM endpoint specific to OpenAI / Google models.
18+
/// - systemMessage: System messages aim at helping the LLM understand its role and what it is supposed to do.
19+
/// The input for `{current_date}` is optional, depending on the use.
20+
/// - promptTemplate: The prompt template contains contextual information of the request and the user prompt.
21+
///
22+
/// When using the `prompt_template` parameter, you **must include** input for `{user_question}`.
23+
/// Inputs for `{current_date}` and `{content}` are optional, depending on the use.
24+
/// - embeddings:
25+
/// - contentTemplate: How the content should be included in a request to the LLM.
26+
/// Input for `{content}` is optional, depending on the use.
27+
/// - isCustomInstructionsIncluded: True if system message contains custom instructions placeholder, false otherwise
28+
/// - warnings: Warnings concerning tool
29+
public init(model: String? = nil, numTokensForCompletion: Int64? = nil, llmEndpointParams: AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi? = nil, systemMessage: String? = nil, promptTemplate: String? = nil, embeddings: AiAgentLongTextToolTextGenEmbeddingsField? = nil, contentTemplate: String? = nil, isCustomInstructionsIncluded: Bool? = nil, warnings: [String]? = nil) {
30+
self.warnings = warnings
31+
32+
super.init(model: model, numTokensForCompletion: numTokensForCompletion, llmEndpointParams: llmEndpointParams, systemMessage: systemMessage, promptTemplate: promptTemplate, embeddings: embeddings, contentTemplate: contentTemplate, isCustomInstructionsIncluded: isCustomInstructionsIncluded)
33+
}
34+
35+
required public init(from decoder: Decoder) throws {
36+
let container = try decoder.container(keyedBy: CodingKeys.self)
37+
warnings = try container.decodeIfPresent([String].self, forKey: .warnings)
38+
39+
try super.init(from: decoder)
40+
}
41+
42+
public override func encode(to encoder: Encoder) throws {
43+
var container = encoder.container(keyedBy: CodingKeys.self)
44+
try container.encodeIfPresent(warnings, forKey: .warnings)
45+
try super.encode(to: encoder)
46+
}
47+
48+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Foundation
2+
3+
/// AI agent processor used to handle basic text.
4+
public class AiStudioAgentBasicTextToolResponse: AiStudioAgentBasicTextTool {
5+
private enum CodingKeys: String, CodingKey {
6+
case warnings
7+
}
8+
9+
/// Warnings concerning tool
10+
public let warnings: [String]?
11+
12+
/// Initializer for a AiStudioAgentBasicTextToolResponse.
13+
///
14+
/// - Parameters:
15+
/// - model: The model used for the AI agent for basic text. For specific model values, see the [available models list](g://box-ai/supported-models).
16+
/// - numTokensForCompletion: The number of tokens for completion.
17+
/// - llmEndpointParams: The parameters for the LLM endpoint specific to OpenAI / Google models.
18+
/// - systemMessage: System messages try to help the LLM "understand" its role and what it is supposed to do.
19+
/// - promptTemplate: The prompt template contains contextual information of the request and the user prompt.
20+
/// When passing `prompt_template` parameters, you **must include** inputs for `{user_question}` and `{content}`.
21+
/// `{current_date}` is optional, depending on the use.
22+
/// - isCustomInstructionsIncluded: True if system message contains custom instructions placeholder, false otherwise
23+
/// - warnings: Warnings concerning tool
24+
public init(model: String? = nil, numTokensForCompletion: Int64? = nil, llmEndpointParams: AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi? = nil, systemMessage: String? = nil, promptTemplate: String? = nil, isCustomInstructionsIncluded: Bool? = nil, warnings: [String]? = nil) {
25+
self.warnings = warnings
26+
27+
super.init(model: model, numTokensForCompletion: numTokensForCompletion, llmEndpointParams: llmEndpointParams, systemMessage: systemMessage, promptTemplate: promptTemplate, isCustomInstructionsIncluded: isCustomInstructionsIncluded)
28+
}
29+
30+
required public init(from decoder: Decoder) throws {
31+
let container = try decoder.container(keyedBy: CodingKeys.self)
32+
warnings = try container.decodeIfPresent([String].self, forKey: .warnings)
33+
34+
try super.init(from: decoder)
35+
}
36+
37+
public override func encode(to encoder: Encoder) throws {
38+
var container = encoder.container(keyedBy: CodingKeys.self)
39+
try container.encodeIfPresent(warnings, forKey: .warnings)
40+
try super.encode(to: encoder)
41+
}
42+
43+
}

0 commit comments

Comments
 (0)