Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "f9e2519", "specHash": "ccdb456", "version": "10.3.0" }
{ "engineHash": "b181eba", "specHash": "ccdb456", "version": "10.3.0" }
7 changes: 4 additions & 3 deletions BoxSdkGen/Tests/Ai/AiManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ class AiManagerTests: RetryableTestCase {
public func testAiExtractStructuredWithFields() async throws {
await runWithRetryAsync {
let aiAgentConfig: AiAgent = try await client.ai.getAiAgentDefaultConfig(queryParams: GetAiAgentDefaultConfigQueryParams(mode: GetAiAgentDefaultConfigQueryParamsModeField.extractStructured, language: "en-US"))
let uploadedFiles: Files = try await client.uploads.uploadFile(requestBody: UploadFileRequestBody(attributes: UploadFileRequestBodyAttributesField(name: "\(Utils.getUUID())\(".txt")", parent: UploadFileRequestBodyAttributesParentField(id: "0")), file: Utils.stringToByteStream(text: "My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar.")))
let uploadedFiles: Files = try await client.uploads.uploadFile(requestBody: UploadFileRequestBody(attributes: UploadFileRequestBodyAttributesField(name: "\(Utils.getUUID())\(".txt")", parent: UploadFileRequestBodyAttributesParentField(id: "0")), file: Utils.stringToByteStream(text: "\("My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar. My UUID is ")\(Utils.getUUID())")))
let file: FileFull = uploadedFiles.entries![0]
try await Utils.delayInSeconds(seconds: 5)
let response: AiExtractStructuredResponse = try await client.ai.createAiExtractStructured(requestBody: AiExtractStructured(items: [AiItemBase(id: file.id)], fields: [AiExtractStructuredFieldsField(key: "firstName", description: "Person first name", displayName: "First name", prompt: "What is the your first name?", type: "string"), AiExtractStructuredFieldsField(key: "lastName", description: "Person last name", displayName: "Last name", prompt: "What is the your last name?", type: "string"), AiExtractStructuredFieldsField(key: "dateOfBirth", description: "Person date of birth", displayName: "Birth date", prompt: "What is the date of your birth?", type: "date"), AiExtractStructuredFieldsField(key: "age", description: "Person age", displayName: "Age", prompt: "How old are you?", type: "float"), AiExtractStructuredFieldsField(key: "hobby", description: "Person hobby", displayName: "Hobby", prompt: "What is your hobby?", type: "multiSelect", options: [AiExtractStructuredFieldsOptionsField(key: "guitar"), AiExtractStructuredFieldsOptionsField(key: "books")])]))
let response: AiExtractStructuredResponse = try await client.ai.createAiExtractStructured(requestBody: AiExtractStructured(items: [AiItemBase(id: file.id)], fields: [AiExtractStructuredFieldsField(key: "firstName", description: "Person first name", displayName: "First name", prompt: "What is the your first name?", type: "string"), AiExtractStructuredFieldsField(key: "lastName", description: "Person last name", displayName: "Last name", prompt: "What is the your last name?", type: "string"), AiExtractStructuredFieldsField(key: "dateOfBirth", description: "Person date of birth", displayName: "Birth date", prompt: "What is the date of your birth?", type: "date"), AiExtractStructuredFieldsField(key: "age", description: "Person age", displayName: "Age", prompt: "How old are you?", type: "float"), AiExtractStructuredFieldsField(key: "hobby", description: "Person hobby", displayName: "Hobby", prompt: "What is your hobby?", type: "multiSelect", options: [AiExtractStructuredFieldsOptionsField(key: "guitar"), AiExtractStructuredFieldsOptionsField(key: "books")])], includeConfidenceScore: true))
XCTAssertTrue(response.confidenceScore != nil)
XCTAssertTrue(Utils.Strings.toString(value: response.answer["hobby"]) == Utils.Strings.toString(value: ["guitar"]))
XCTAssertTrue(Utils.Strings.toString(value: response.answer["firstName"]) == "John")
XCTAssertTrue(Utils.Strings.toString(value: response.answer["lastName"]) == "Doe")
Expand All @@ -87,7 +88,7 @@ class AiManagerTests: RetryableTestCase {

public func testAiExtractStructuredWithMetadataTemplate() async throws {
await runWithRetryAsync {
let uploadedFiles: Files = try await client.uploads.uploadFile(requestBody: UploadFileRequestBody(attributes: UploadFileRequestBodyAttributesField(name: "\(Utils.getUUID())\(".txt")", parent: UploadFileRequestBodyAttributesParentField(id: "0")), file: Utils.stringToByteStream(text: "My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar.")))
let uploadedFiles: Files = try await client.uploads.uploadFile(requestBody: UploadFileRequestBody(attributes: UploadFileRequestBodyAttributesField(name: "\(Utils.getUUID())\(".txt")", parent: UploadFileRequestBodyAttributesParentField(id: "0")), file: Utils.stringToByteStream(text: "\("My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar. My UUID is ")\(Utils.getUUID())")))
let file: FileFull = uploadedFiles.entries![0]
try await Utils.delayInSeconds(seconds: 5)
let templateKey: String = "\("key")\(Utils.getUUID())"
Expand Down
2 changes: 1 addition & 1 deletion docs/Ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ See the endpoint docs at

<!-- sample post_ai_extract_structured -->
```
try await client.ai.createAiExtractStructured(requestBody: AiExtractStructured(fields: [AiExtractStructuredFieldsField(key: "firstName", displayName: "First name", description: "Person first name", prompt: "What is the your first name?", type: "string"), AiExtractStructuredFieldsField(key: "lastName", displayName: "Last name", description: "Person last name", prompt: "What is the your last name?", type: "string"), AiExtractStructuredFieldsField(key: "dateOfBirth", displayName: "Birth date", description: "Person date of birth", prompt: "What is the date of your birth?", type: "date"), AiExtractStructuredFieldsField(key: "age", displayName: "Age", description: "Person age", prompt: "How old are you?", type: "float"), AiExtractStructuredFieldsField(key: "hobby", displayName: "Hobby", description: "Person hobby", prompt: "What is your hobby?", type: "multiSelect", options: [AiExtractStructuredFieldsOptionsField(key: "guitar"), AiExtractStructuredFieldsOptionsField(key: "books")])], items: [AiItemBase(id: file.id)]))
try await client.ai.createAiExtractStructured(requestBody: AiExtractStructured(fields: [AiExtractStructuredFieldsField(key: "firstName", displayName: "First name", description: "Person first name", prompt: "What is the your first name?", type: "string"), AiExtractStructuredFieldsField(key: "lastName", displayName: "Last name", description: "Person last name", prompt: "What is the your last name?", type: "string"), AiExtractStructuredFieldsField(key: "dateOfBirth", displayName: "Birth date", description: "Person date of birth", prompt: "What is the date of your birth?", type: "date"), AiExtractStructuredFieldsField(key: "age", displayName: "Age", description: "Person age", prompt: "How old are you?", type: "float"), AiExtractStructuredFieldsField(key: "hobby", displayName: "Hobby", description: "Person hobby", prompt: "What is your hobby?", type: "multiSelect", options: [AiExtractStructuredFieldsOptionsField(key: "guitar"), AiExtractStructuredFieldsOptionsField(key: "books")])], items: [AiItemBase(id: file.id)], includeConfidenceScore: true))
```

### Arguments
Expand Down