Skip to content

AI Extract Structured response always returns empty object for answer. #619

Closed
@mtucker

Description

@mtucker
  • I have checked that the SDK documentation doesn't solve my issue.
  • I have checked that the API documentation doesn't solve my issue.
  • I have searched the [Box Developer Forums][dev-forums] and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
  • I have searched [Issues in this repo][github-repo] and my issue isn't already reported.

Description of the Issue

I'm having trouble with the type returned from a createAiExtractStructured call. I see that answer is only returned in the rawData property:

{
    "createdAt": {
      "value": "2025-05-24T15:38:03.551Z"
    },
    "completionReason": "done",
    "rawData": {
      "created_at": "2025-05-24T08:38:03.551-07:00",
      "completion_reason": "done",
      "answer": {
        "document_type": "Investment Tax Credit Eligibility Legal Opinion"
      },
      "ai_agent_info": {
        "processor": "basic_text",
        "models": [
          {
            "name": "google__gemini_2_0_flash_001",
            "provider": "google"
          }
        ]
      }
    },
    "aiAgentInfo": {
      "processor": "basic_text",
      "models": [
        {
          "name": "google__gemini_2_0_flash_001",
          "provider": "google"
        }
      ]
    }
  }

It looks like the deserializeAiExtractResponse method always returns an empty object - is this intentional?

export function serializeAiExtractResponse(
  val: AiExtractResponse,
): SerializedData {
  return {};
}
export function deserializeAiExtractResponse(
  val: SerializedData,
): AiExtractResponse {
  if (!sdIsMap(val)) {
    throw new BoxSdkError({
      message: 'Expecting a map for "AiExtractResponse"',
    });
  }
  return {} satisfies AiExtractResponse;
}

The top-level answer property of the response is always an empty object. I'm unsure how I'm meant to access answer in a type-safe way.

Steps to Reproduce

  1. Perform an API call using ``.
  2. Inspect the deserialized response.
  3. Observe that answer is only included in the rawData property.

Expected Behavior

answer is included as a top-level attribute of the deserialized response, contains the answer result of the call and can be accessed it in a type-safe way.

Something like:

// Extracting an author metadata in this example
const author = response.answer.author;
// or
const author - response.answer["author"];

Versions Used

Typescript SDK: 1.15.1
Platform: NodeJS
Node.js (if applicable): v18.20.0

[dev-forums]: https://community.box.com/t5/Platform-and-Development-Forum/bd-p/DeveloperForum **<-- btw this 404s **
[github-repo]: https://github.com/box/box-typescript-sdk-gen/search?type=Issues

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions