diff --git a/.castiron.stats.yml b/.castiron.stats.yml index e137eac45..8642bf6d7 100644 --- a/.castiron.stats.yml +++ b/.castiron.stats.yml @@ -1,6 +1,6 @@ schema_version: 1 -generation_id: a68d69bb-f8a7-4e0c-8eea-a2c0215d752b -openapi_spec_hash: 143aa2ed6323d61a1834c74044e29d30 -openapi_transformed_spec_hash: 5af6fa4fd590fcc79ba2fdd69b9f7b82 -config_hash: fcda4ecfe265daddba6fad25a8504a3f -codegen_sha: fb74fa30832d64dc32800aa4f537b047086fffd9 +generation_id: 5126717b-0864-4f05-b50e-f34598693b47 +openapi_spec_hash: cc58e691f33751629ca4de3100082edb +openapi_transformed_spec_hash: 6e9129151e5404deb042f722a97bb2a9 +config_hash: a356ac9fd5606025cdc3db3f68432996 +codegen_sha: 63b4f1b5a50d66c72658989062be3f5549f927cb diff --git a/api_reference/openapi.transformed.yml b/api_reference/openapi.transformed.yml index 4aed002d0..0bc670a31 100644 --- a/api_reference/openapi.transformed.yml +++ b/api_reference/openapi.transformed.yml @@ -93,6 +93,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListAssistantsResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List assistants group: assistants @@ -201,6 +203,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AssistantObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create assistant group: assistants @@ -360,6 +364,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AssistantObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve assistant group: assistants @@ -436,6 +442,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AssistantObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Modify assistant group: assistants @@ -530,6 +538,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteAssistantResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete assistant group: assistants @@ -593,6 +603,8 @@ paths: text/event-stream: schema: $ref: '#/components/schemas/CreateSpeechResponseStreamEvent' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create speech group: audio @@ -703,6 +715,8 @@ paths: text/event-stream: schema: $ref: '#/components/schemas/CreateTranscriptionResponseStreamEvent' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create transcription group: audio @@ -1257,6 +1271,8 @@ paths: - $ref: '#/components/schemas/CreateTranslationResponseVerboseJson' x-stainless-skip: - go + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create translation group: audio @@ -1988,6 +2004,8 @@ paths: text/event-stream: schema: $ref: '#/components/schemas/CreateChatCompletionStreamResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create chat completion group: chat @@ -3120,6 +3138,8 @@ paths: application/json: schema: $ref: '#/components/schemas/CreateCompletionResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create completion group: completions @@ -3289,6 +3309,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ContainerListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List containers group: containers @@ -3337,6 +3359,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ContainerResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create container group: containers @@ -3402,6 +3426,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ContainerResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve container group: containers @@ -3439,6 +3465,8 @@ paths: responses: '200': description: OK + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete a container group: containers @@ -3484,6 +3512,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ContainerFileResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create container file group: containers @@ -3545,6 +3575,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ContainerFileListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List container files group: containers @@ -3595,6 +3627,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ContainerFileResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve container file group: containers @@ -3632,6 +3666,8 @@ paths: responses: '200': description: OK + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete a container file group: containers @@ -3666,6 +3702,8 @@ paths: responses: '200': description: Success + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve container file content group: containers @@ -3723,6 +3761,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ConversationItemList' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create items group: conversations @@ -3918,6 +3958,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ConversationItemList' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List items group: conversations @@ -4009,6 +4051,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ConversationItem' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve an item group: conversations @@ -4084,6 +4128,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ConversationResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete an item group: conversations @@ -4148,6 +4194,8 @@ paths: application/json: schema: $ref: '#/components/schemas/CreateEmbeddingResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create embeddings group: embeddings @@ -4275,6 +4323,8 @@ paths: application/json: schema: $ref: '#/components/schemas/EvalList' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List evals group: evals @@ -4391,6 +4441,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Eval' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create eval group: evals @@ -4573,6 +4625,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Eval' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get an eval group: evals @@ -4674,6 +4728,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Eval' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Update an eval group: evals @@ -4793,6 +4849,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete an eval group: evals @@ -4878,6 +4936,8 @@ paths: application/json: schema: $ref: '#/components/schemas/EvalRunList' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get eval runs group: evals @@ -5014,6 +5074,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create eval run group: evals @@ -5205,6 +5267,8 @@ paths: application/json: schema: $ref: '#/components/schemas/EvalRun' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get an eval run group: evals @@ -5408,6 +5472,8 @@ paths: application/json: schema: $ref: '#/components/schemas/EvalRun' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Cancel eval run group: evals @@ -5628,6 +5694,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete eval run group: evals @@ -5726,6 +5794,8 @@ paths: application/json: schema: $ref: '#/components/schemas/EvalRunOutputItemList' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get eval run output items group: evals @@ -5859,6 +5929,8 @@ paths: application/json: schema: $ref: '#/components/schemas/EvalRunOutputItem' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get an output item of an eval run group: evals @@ -6302,13 +6374,14 @@ paths: const openai = new OpenAI(); async function main() { - const file = await openai.files.content("file-abc123"); + const response = await openai.files.content("file-abc123"); + const content = await response.text(); - console.log(file); + console.log(content); } main(); - description: Returns the contents of the specified file. + description: Returns a response containing the contents of the specified file. /fine_tuning/alpha/graders/run: post: operationId: runGrader @@ -8163,19 +8236,22 @@ paths: "id": "model-id-0", "object": "model", "created": 1686935002, - "owned_by": "organization-owner" + "owned_by": "organization-owner", + "shutdown_date": null }, { "id": "model-id-1", "object": "model", "created": 1686935002, "owned_by": "organization-owner", + "shutdown_date": null }, { "id": "model-id-2", "object": "model", "created": 1686935002, - "owned_by": "openai" + "owned_by": "openai", + "shutdown_date": "2026-10-23" }, ] } @@ -8243,7 +8319,8 @@ paths: "id": "VAR_chat_model_id", "object": "model", "created": 1686935002, - "owned_by": "openai" + "owned_by": "openai", + "shutdown_date": "2026-10-23" } description: Retrieves a model instance, providing basic information about the model such as the owner and permissioning. delete: @@ -8884,6 +8961,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListAuditLogsResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List audit logs group: audit-logs @@ -8995,6 +9074,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListCertificatesResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List organization certificates group: administration @@ -9045,6 +9126,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Certificate' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Upload certificate group: administration @@ -9095,6 +9178,8 @@ paths: application/json: schema: $ref: '#/components/schemas/OrganizationCertificateActivationResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Activate certificates for organization group: administration @@ -9161,6 +9246,8 @@ paths: application/json: schema: $ref: '#/components/schemas/OrganizationCertificateDeactivationResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Deactivate certificates for organization group: administration @@ -9237,6 +9324,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Certificate' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get certificate group: administration @@ -9289,6 +9378,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Certificate' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Modify certificate group: administration @@ -9335,6 +9426,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteCertificateResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete certificate group: administration @@ -9430,6 +9523,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Costs group: usage-costs @@ -9578,6 +9673,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List groups group: administration @@ -9624,6 +9721,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create group group: administration @@ -9667,6 +9766,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve group group: administration @@ -9713,6 +9814,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupResourceWithSuccess' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Update group group: administration @@ -9754,6 +9857,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupDeletedResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete group group: administration @@ -9815,6 +9920,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RoleListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List group organization role assignments group: administration @@ -9881,6 +9988,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupRoleAssignment' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Assign organization role to group group: administration @@ -9945,6 +10054,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AssignedRoleDetails' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve group organization role group: administration @@ -10000,6 +10111,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeletedRoleAssignmentResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Unassign organization role from group group: administration @@ -10064,6 +10177,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UserListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List group users group: administration @@ -10115,6 +10230,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupUserAssignment' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Add group user group: administration @@ -10162,6 +10279,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupMemberUser' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve group user group: administration @@ -10208,6 +10327,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupUserDeletedResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Remove group user group: administration @@ -10910,6 +11031,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListProjectCertificatesResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List project certificates group: administration @@ -10968,6 +11091,8 @@ paths: application/json: schema: $ref: '#/components/schemas/OrganizationProjectCertificateActivationResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Activate certificates for project group: administration @@ -11041,6 +11166,8 @@ paths: application/json: schema: $ref: '#/components/schemas/OrganizationProjectCertificateDeactivationResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Deactivate certificates for project group: administration @@ -11212,6 +11339,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ProjectGroupListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List project groups group: administration @@ -11265,6 +11394,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ProjectGroup' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Add project group group: administration @@ -11325,6 +11456,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ProjectGroup' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve project group group: administration @@ -11371,6 +11504,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ProjectGroupDeletedResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Remove project group group: administration @@ -12687,6 +12822,8 @@ paths: application/json: schema: $ref: '#/components/schemas/PublicRoleListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List organization roles group: administration @@ -12738,6 +12875,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Role' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create organization role group: administration @@ -12791,6 +12930,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Role' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve organization role group: administration @@ -12842,6 +12983,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Role' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Update organization role group: administration @@ -12894,6 +13037,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RoleDeletedResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete organization role group: administration @@ -13283,6 +13428,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Audio speeches group: usage-audio-speeches @@ -13416,6 +13563,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Audio transcriptions group: usage-audio-transcriptions @@ -13522,6 +13671,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Code interpreter sessions group: usage-code-interpreter-sessions @@ -13660,6 +13811,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Completions group: usage-completions @@ -13808,6 +13961,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Embeddings group: usage-embeddings @@ -13941,6 +14096,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: File search calls group: usage-file-search-calls @@ -14101,6 +14258,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Images group: usage-images @@ -14236,6 +14395,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Moderations group: usage-moderations @@ -14342,6 +14503,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Vector stores group: usage-vector-stores @@ -14484,6 +14647,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UsageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Web search calls group: usage-web-search-calls @@ -14758,6 +14923,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RoleListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List user organization role assignments group: administration @@ -14824,6 +14991,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UserRoleAssignment' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Assign organization role to user group: administration @@ -14889,6 +15058,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AssignedRoleDetails' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve user organization role group: administration @@ -14944,6 +15115,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeletedRoleAssignmentResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Unassign organization role from user group: administration @@ -15010,6 +15183,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RoleListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List project group role assignments group: administration @@ -15082,6 +15257,8 @@ paths: application/json: schema: $ref: '#/components/schemas/GroupRoleAssignment' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Assign project role to group group: administration @@ -15152,6 +15329,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AssignedRoleDetails' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve project group role group: administration @@ -15213,6 +15392,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeletedRoleAssignmentResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Unassign project role from group group: administration @@ -15275,6 +15456,8 @@ paths: application/json: schema: $ref: '#/components/schemas/PublicRoleListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List project roles group: administration @@ -15333,6 +15516,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Role' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create project role group: administration @@ -15392,6 +15577,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Role' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve project role group: administration @@ -15449,6 +15636,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Role' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Update project role group: administration @@ -15507,6 +15696,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RoleDeletedResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete project role group: administration @@ -15574,6 +15765,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RoleListResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List project user role assignments group: administration @@ -15646,6 +15839,8 @@ paths: application/json: schema: $ref: '#/components/schemas/UserRoleAssignment' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Assign project role to user group: administration @@ -15717,6 +15912,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AssignedRoleDetails' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve project user role group: administration @@ -15778,6 +15975,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeletedRoleAssignmentResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Unassign project role from user group: administration @@ -16321,6 +16520,8 @@ paths: text/event-stream: schema: $ref: '#/components/schemas/ResponseStreamEvent' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create a model response group: responses @@ -17566,6 +17767,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Response' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get a model response group: responses @@ -17670,6 +17873,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete a model response group: responses @@ -17726,6 +17931,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Cancel a response group: responses @@ -17852,6 +18059,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ResponseItemList' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List input items group: responses @@ -17912,6 +18121,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ThreadObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create thread group: threads @@ -18036,6 +18247,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RunObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create thread and run group: threads @@ -18407,6 +18620,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ThreadObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve thread group: threads @@ -18476,6 +18691,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ThreadObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Modify thread group: threads @@ -18553,6 +18770,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteThreadResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete thread group: threads @@ -18645,6 +18864,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListMessagesResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List messages group: threads @@ -18751,6 +18972,8 @@ paths: application/json: schema: $ref: '#/components/schemas/MessageObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create message group: threads @@ -18839,6 +19062,8 @@ paths: application/json: schema: $ref: '#/components/schemas/MessageObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve message group: threads @@ -18927,6 +19152,8 @@ paths: application/json: schema: $ref: '#/components/schemas/MessageObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Modify message group: threads @@ -19023,6 +19250,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteMessageResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete message group: threads @@ -19113,6 +19342,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListRunsResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List runs group: threads @@ -19288,6 +19519,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RunObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create run group: threads @@ -19629,6 +19862,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RunObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve run group: threads @@ -19736,6 +19971,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RunObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Modify run group: threads @@ -19860,6 +20097,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RunObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Cancel a run group: threads @@ -19999,6 +20238,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListRunStepsResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List run steps group: threads @@ -20113,6 +20354,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RunStepObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve run step group: threads @@ -20208,6 +20451,8 @@ paths: application/json: schema: $ref: '#/components/schemas/RunObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Submit tool outputs to run group: threads @@ -20671,6 +20916,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListVectorStoresResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List vector stores group: vector_stores @@ -20755,6 +21002,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create vector store group: vector_stores @@ -20825,6 +21074,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve vector store group: vector_stores @@ -20887,6 +21138,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Modify vector store group: vector_stores @@ -20960,6 +21213,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteVectorStoreResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete vector store group: vector_stores @@ -21027,6 +21282,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreFileBatchObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create vector store file batch group: vector_stores @@ -21148,6 +21405,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreFileBatchObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve vector store file batch group: vector_stores @@ -21222,6 +21481,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreFileBatchObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Cancel vector store file batch group: vector_stores @@ -21337,6 +21598,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListVectorStoreFilesResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List vector store files in a batch group: vector_stores @@ -21451,6 +21714,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ListVectorStoreFilesResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List vector store files group: vector_stores @@ -21531,6 +21796,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreFileObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create vector store file group: vector_stores @@ -21608,6 +21875,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreFileObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve vector store file group: vector_stores @@ -21675,6 +21944,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeleteVectorStoreFileResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete vector store file group: vector_stores @@ -21748,6 +22019,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreFileObject' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Update vector store file attributes group: vector_stores @@ -21799,6 +22072,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreFileContentResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve vector store file content group: vector_stores @@ -21846,6 +22121,8 @@ paths: application/json: schema: $ref: '#/components/schemas/VectorStoreSearchResultsPage' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Search vector store group: vector_stores @@ -21916,6 +22193,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ConversationResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create a conversation group: conversations @@ -22014,6 +22293,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ConversationResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Retrieve a conversation group: conversations @@ -22073,6 +22354,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeletedConversationResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete a conversation group: conversations @@ -22136,6 +22419,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ConversationResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Update a conversation group: conversations @@ -22503,6 +22788,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ProvenanceResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create content provenance check group: content_provenance_checks @@ -23259,6 +23546,8 @@ paths: application/json: schema: $ref: '#/components/schemas/TokenCountsResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get input token counts group: responses @@ -23371,6 +23660,8 @@ paths: application/json: schema: $ref: '#/components/schemas/CompactResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Compact a response group: responses @@ -23530,6 +23821,8 @@ paths: application/json: schema: $ref: '#/components/schemas/SkillResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: Create a new skill. get: tags: @@ -23565,6 +23858,8 @@ paths: application/json: schema: $ref: '#/components/schemas/SkillListResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: List all skills for the current project. /skills/{skill_id}: delete: @@ -23587,6 +23882,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeletedSkillResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: Delete a skill by its ID. get: tags: @@ -23608,6 +23905,8 @@ paths: application/json: schema: $ref: '#/components/schemas/SkillResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: Get a skill by its ID. post: tags: @@ -23634,6 +23933,8 @@ paths: application/json: schema: $ref: '#/components/schemas/SkillResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: Update the default version pointer for a skill. /skills/{skill_id}/content: get: @@ -23660,6 +23961,8 @@ paths: application/json: schema: type: string + '429': + $ref: '#/components/responses/TooManyRequests' description: Download a skill zip bundle by its ID. /skills/{skill_id}/versions: post: @@ -23690,6 +23993,8 @@ paths: application/json: schema: $ref: '#/components/schemas/SkillVersionResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: Create a new immutable skill version. get: tags: @@ -23732,6 +24037,8 @@ paths: application/json: schema: $ref: '#/components/schemas/SkillVersionListResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: List skill versions for a skill. /skills/{skill_id}/versions/{version}: get: @@ -23761,6 +24068,8 @@ paths: application/json: schema: $ref: '#/components/schemas/SkillVersionResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: Get a specific skill version. delete: tags: @@ -23789,6 +24098,8 @@ paths: application/json: schema: $ref: '#/components/schemas/DeletedSkillVersionResource' + '429': + $ref: '#/components/responses/TooManyRequests' description: Delete a skill version. /skills/{skill_id}/versions/{version}/content: get: @@ -23822,6 +24133,8 @@ paths: application/json: schema: type: string + '429': + $ref: '#/components/responses/TooManyRequests' description: Download a skill version zip bundle. /chatkit/sessions/{session_id}/cancel: post: @@ -24596,6 +24909,8 @@ paths: text/event-stream: schema: $ref: '#/components/schemas/BetaResponseStreamEvent' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Create a model response group: responses @@ -25868,6 +26183,8 @@ paths: application/json: schema: $ref: '#/components/schemas/BetaResponse' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get a model response group: responses @@ -25985,6 +26302,8 @@ paths: application/json: schema: $ref: '#/components/schemas/BetaError' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Delete a model response group: responses @@ -26054,6 +26373,8 @@ paths: application/json: schema: $ref: '#/components/schemas/BetaError' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Cancel a response group: responses @@ -26155,6 +26476,8 @@ paths: application/json: schema: $ref: '#/components/schemas/BetaCompactResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Compact a response group: responses @@ -26360,6 +26683,8 @@ paths: application/json: schema: $ref: '#/components/schemas/BetaResponseItemList' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: List input items group: responses @@ -26432,6 +26757,8 @@ paths: application/json: schema: $ref: '#/components/schemas/BetaTokenCountsResource' + '429': + $ref: '#/components/responses/TooManyRequests' x-oaiMeta: name: Get input token counts group: responses @@ -30154,6 +30481,9 @@ components: type: integer default: 0 description: Tokens generated by the model for reasoning. + text_tokens: + type: integer + description: Text output tokens generated by the model. rejected_prediction_tokens: type: integer default: 0 @@ -30175,6 +30505,12 @@ components: type: integer default: 0 description: Cached tokens present in the prompt. + text_tokens: + type: integer + description: Text input tokens present in the prompt. + image_tokens: + type: integer + description: Image input tokens present in the prompt. cache_write_tokens: type: integer default: 0 @@ -30920,6 +31256,8 @@ components: characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models) to browse and compare available models. $ref: '#/components/schemas/ModelIdsShared' + service_tier: + $ref: '#/components/schemas/ServiceTier' modalities: $ref: '#/components/schemas/ResponseModalities' verbosity: @@ -33527,6 +33865,8 @@ components: - $ref: '#/components/schemas/ResponseProperties' - type: object properties: + service_tier: + $ref: '#/components/schemas/ServiceTierResponses' truncation: deprecated: true anyOf: @@ -40330,10 +40670,9 @@ components: The output from the tool call. - type: 'null' error: + description: The error from the tool call, if any. anyOf: - - type: string - description: | - The error from the tool call, if any. + - $ref: '#/components/schemas/MCPToolCallError' - type: 'null' status: $ref: '#/components/schemas/MCPToolCallStatus' @@ -40352,6 +40691,13 @@ components: - server_label - name - arguments + MCPToolCallError: + discriminator: + propertyName: type + anyOf: + - $ref: '#/components/schemas/MCPProtocolError' + - $ref: '#/components/schemas/MCPToolExecutionError' + - $ref: '#/components/schemas/HTTPError' MCPToolFilter: type: object title: MCP tool filter @@ -41047,6 +41393,12 @@ components: owned_by: type: string description: The organization that owns the model. + shutdown_date: + anyOf: + - type: string + format: date + - type: 'null' + description: The date when the model will shut down, or null if not announced. required: - id - object @@ -41059,7 +41411,8 @@ components: "id": "VAR_chat_model_id", "object": "model", "created": 1686935002, - "owned_by": "openai" + "owned_by": "openai", + "shutdown_date": "2026-10-23" } ModelIds: anyOf: @@ -41088,6 +41441,8 @@ components: - o4-mini-deep-research-2025-06-26 - computer-use-preview - computer-use-preview-2025-03-11 + - gpt-5.5-pro + - gpt-5.5-pro-2026-04-23 - gpt-5-codex - gpt-5-pro - gpt-5-pro-2025-10-06 @@ -41166,8 +41521,6 @@ components: description: | Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](https://platform.openai.com/docs/guides/prompt-caching). - type: 'null' - service_tier: - $ref: '#/components/schemas/ServiceTier' prompt_cache_retention: deprecated: true anyOf: @@ -51648,6 +52001,12 @@ components: The encrypted content of the reasoning item. This is populated by default for reasoning items returned by `POST /v1/responses` and WebSocket `response.create` requests. + + When streaming, use the completed reasoning item and its + `encrypted_content` from the `response.output_item.done` event in + subsequent requests. The `encrypted_content` in + `response.output_item.added` may be incomplete. This is especially + important when `store` is `false` or when using Zero Data Retention. - type: 'null' summary: type: array @@ -51681,6 +52040,8 @@ components: - $ref: '#/components/schemas/ResponseProperties' - type: object properties: + service_tier: + $ref: '#/components/schemas/ServiceTierResponses' truncation: anyOf: - type: string @@ -53633,7 +53994,10 @@ components: item: $ref: '#/components/schemas/OutputItem' description: | - The output item that was added. + The output item that was added. For reasoning items, `encrypted_content` + may be incomplete while the item is in progress. Use the reasoning item + from the corresponding `response.output_item.done` event when passing it + as input to a subsequent request. required: - type - output_index @@ -53733,7 +54097,9 @@ components: type: integer description: The sequence number of this event. annotation: - type: object + anyOf: + - $ref: '#/components/schemas/Annotation' + - type: 'null' description: The annotation object being added. (See annotation schema for details.) required: - type @@ -53754,10 +54120,10 @@ components: "content_index": 0, "annotation_index": 0, "annotation": { - "type": "text_annotation", - "text": "This is a test annotation", - "start": 0, - "end": 10 + "type": "file_citation", + "file_id": "file-abc", + "index": 0, + "filename": "example.txt" }, "sequence_number": 1 } @@ -54648,6 +55014,49 @@ components: "item_id": "ws_123", "sequence_number": 0 } + ResponseWsError: + type: object + title: ResponseWsError + description: Emitted when an error occurs while processing a Responses WebSocket request. + properties: + type: + type: string + description: The type of the event. Always `error`. + enum: + - error + x-stainless-const: true + status: + type: integer + description: The HTTP status code associated with a WebSocket protocol error. + sequence_number: + type: integer + description: The sequence number of an error emitted by the response stream. + error: + $ref: '#/components/schemas/ErrorPayload' + description: Details about the error. + stream_id: + type: string + description: | + The WebSocket lane that emitted this event. This field is present when the + originating `response.create` event supplied a `stream_id`. + required: + - type + - error + x-oaiMeta: + name: error + group: responses + example: | + { + "type": "error", + "status": 400, + "stream_id": "agent_1", + "error": { + "type": "invalid_request_error", + "code": "websocket_stream_limit_reached", + "message": "This WebSocket connection has reached its stream limit.", + "param": "stream_id" + } + } ResponsesClientEvent: discriminator: propertyName: type @@ -54862,18 +55271,6 @@ components: The WebSocket lane that emitted this event. This field is present when the originating `response.create` event supplied a `stream_id`. - - title: ResponseWsError - description: Emitted when an error occurs. - allOf: - - $ref: '#/components/schemas/ResponseErrorEvent' - - type: object - properties: - stream_id: - type: string - description: | - The WebSocket lane that emitted this event. This field is present - when the originating `response.create` event supplied a - `stream_id`. - title: ResponseFileSearchCallWsCompleted description: Emitted when a file search call is completed (results found). allOf: @@ -55360,9 +55757,62 @@ components: The WebSocket lane that emitted this event. This field is present when the originating `response.create` event supplied a `stream_id`. + - $ref: '#/components/schemas/ResponseWsError' ResponsesWebSocketStreamEvent: allOf: - - $ref: '#/components/schemas/ResponseStreamEvent' + - anyOf: + - $ref: '#/components/schemas/ResponseAudioDeltaEvent' + - $ref: '#/components/schemas/ResponseAudioDoneEvent' + - $ref: '#/components/schemas/ResponseAudioTranscriptDeltaEvent' + - $ref: '#/components/schemas/ResponseAudioTranscriptDoneEvent' + - $ref: '#/components/schemas/ResponseCodeInterpreterCallCodeDeltaEvent' + - $ref: '#/components/schemas/ResponseCodeInterpreterCallCodeDoneEvent' + - $ref: '#/components/schemas/ResponseCodeInterpreterCallCompletedEvent' + - $ref: '#/components/schemas/ResponseCodeInterpreterCallInProgressEvent' + - $ref: '#/components/schemas/ResponseCodeInterpreterCallInterpretingEvent' + - $ref: '#/components/schemas/ResponseCompletedEvent' + - $ref: '#/components/schemas/ResponseContentPartAddedEvent' + - $ref: '#/components/schemas/ResponseContentPartDoneEvent' + - $ref: '#/components/schemas/ResponseCreatedEvent' + - $ref: '#/components/schemas/ResponseFileSearchCallCompletedEvent' + - $ref: '#/components/schemas/ResponseFileSearchCallInProgressEvent' + - $ref: '#/components/schemas/ResponseFileSearchCallSearchingEvent' + - $ref: '#/components/schemas/ResponseFunctionCallArgumentsDeltaEvent' + - $ref: '#/components/schemas/ResponseFunctionCallArgumentsDoneEvent' + - $ref: '#/components/schemas/ResponseInProgressEvent' + - $ref: '#/components/schemas/ResponseFailedEvent' + - $ref: '#/components/schemas/ResponseIncompleteEvent' + - $ref: '#/components/schemas/ResponseOutputItemAddedEvent' + - $ref: '#/components/schemas/ResponseOutputItemDoneEvent' + - $ref: '#/components/schemas/ResponseReasoningSummaryPartAddedEvent' + - $ref: '#/components/schemas/ResponseReasoningSummaryPartDoneEvent' + - $ref: '#/components/schemas/ResponseReasoningSummaryTextDeltaEvent' + - $ref: '#/components/schemas/ResponseReasoningSummaryTextDoneEvent' + - $ref: '#/components/schemas/ResponseReasoningTextDeltaEvent' + - $ref: '#/components/schemas/ResponseReasoningTextDoneEvent' + - $ref: '#/components/schemas/ResponseRefusalDeltaEvent' + - $ref: '#/components/schemas/ResponseRefusalDoneEvent' + - $ref: '#/components/schemas/ResponseTextDeltaEvent' + - $ref: '#/components/schemas/ResponseTextDoneEvent' + - $ref: '#/components/schemas/ResponseWebSearchCallCompletedEvent' + - $ref: '#/components/schemas/ResponseWebSearchCallInProgressEvent' + - $ref: '#/components/schemas/ResponseWebSearchCallSearchingEvent' + - $ref: '#/components/schemas/ResponseImageGenCallCompletedEvent' + - $ref: '#/components/schemas/ResponseImageGenCallGeneratingEvent' + - $ref: '#/components/schemas/ResponseImageGenCallInProgressEvent' + - $ref: '#/components/schemas/ResponseImageGenCallPartialImageEvent' + - $ref: '#/components/schemas/ResponseMCPCallArgumentsDeltaEvent' + - $ref: '#/components/schemas/ResponseMCPCallArgumentsDoneEvent' + - $ref: '#/components/schemas/ResponseMCPCallCompletedEvent' + - $ref: '#/components/schemas/ResponseMCPCallFailedEvent' + - $ref: '#/components/schemas/ResponseMCPCallInProgressEvent' + - $ref: '#/components/schemas/ResponseMCPListToolsCompletedEvent' + - $ref: '#/components/schemas/ResponseMCPListToolsFailedEvent' + - $ref: '#/components/schemas/ResponseMCPListToolsInProgressEvent' + - $ref: '#/components/schemas/ResponseOutputTextAnnotationAddedEvent' + - $ref: '#/components/schemas/ResponseQueuedEvent' + - $ref: '#/components/schemas/ResponseCustomToolCallInputDeltaEvent' + - $ref: '#/components/schemas/ResponseCustomToolCallInputDoneEvent' - type: object properties: stream_id: @@ -56811,6 +57261,29 @@ components: - fast default: auto - type: 'null' + ServiceTierResponses: + anyOf: + - type: string + description: | + Specifies the processing type used for serving the request. + - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'. + - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model. + - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier. + - To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. + - If set to 'ultrafast', then the request will be processed with the access-controlled Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a response served through it will show `service_tier=ultrafast`. + - When not set, the default behavior is 'auto'. + + When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter. + enum: + - auto + - default + - flex + - scale + - priority + - fast + - ultrafast + default: auto + - type: 'null' SpeechAudioDeltaEvent: type: object description: Emitted for each chunk of audio data generated during speech synthesis. @@ -59743,6 +60216,10 @@ components: - web_search_2025_08_26 description: The type of the web search tool. One of `web_search` or `web_search_2025_08_26`. default: web_search + external_web_access: + type: boolean + default: true + description: Allow live internet access for web search. Defaults to true when omitted. When false, the web search tool runs in offline/cache-only mode and will not fetch new external content. filters: anyOf: - type: object @@ -63113,6 +63590,53 @@ components: - status title: Apply patch tool call output description: The output emitted by an apply patch tool call. + MCPProtocolError: + properties: + type: + type: string + enum: + - mcp_protocol_error + default: mcp_protocol_error + x-stainless-const: true + code: + type: integer + message: + type: string + type: object + required: + - type + - code + - message + MCPToolExecutionError: + properties: + type: + type: string + enum: + - mcp_tool_execution_error + default: mcp_tool_execution_error + x-stainless-const: true + content: {} + type: object + required: + - type + - content + HTTPError: + properties: + type: + type: string + enum: + - http_error + default: http_error + x-stainless-const: true + code: + type: integer + message: + type: string + type: object + required: + - type + - code + - message MCPToolCallStatus: type: string enum: @@ -66532,6 +67056,39 @@ components: - y title: Coordinate description: 'An x/y coordinate pair, e.g. `{ x: 100, y: 200 }`.' + ErrorPayload: + properties: + type: + type: string + description: The error type that was emitted. + code: + anyOf: + - type: string + description: The error code that was emitted, if any. + - type: 'null' + message: + type: string + description: The human-readable error message that was emitted. + param: + anyOf: + - type: string + description: The parameter name that was associated with the error, if any. + - type: 'null' + headers: + additionalProperties: + type: string + description: The header value that was emitted. + type: object + description: The response headers that were emitted with the error, if any. + x-oaiTypeLabel: map + type: object + required: + - type + - code + - message + - param + title: Error payload + description: An error payload that was emitted for a streaming error event. BetaTokenCountsResource: properties: object: @@ -68039,6 +68596,10 @@ components: - web_search_2025_08_26 description: The type of the web search tool. One of `web_search` or `web_search_2025_08_26`. default: web_search + external_web_access: + type: boolean + default: true + description: Allow live internet access for web search. Defaults to true when omitted. When false, the web search tool runs in offline/cache-only mode and will not fetch new external content. filters: anyOf: - type: object @@ -68870,10 +69431,9 @@ components: The output from the tool call. - type: 'null' error: + description: The error from the tool call, if any. anyOf: - - type: string - description: | - The error from the tool call, if any. + - $ref: '#/components/schemas/BetaMCPToolCallError' - type: 'null' status: $ref: '#/components/schemas/BetaMCPToolCallStatus' @@ -68900,6 +69460,60 @@ components: - incomplete - calling - failed + BetaMCPToolCallError: + discriminator: + propertyName: type + anyOf: + - $ref: '#/components/schemas/BetaMCPProtocolError' + - $ref: '#/components/schemas/BetaMCPToolExecutionError' + - $ref: '#/components/schemas/BetaHTTPError' + BetaHTTPError: + properties: + type: + type: string + enum: + - http_error + default: http_error + x-stainless-const: true + code: + type: integer + message: + type: string + type: object + required: + - type + - code + - message + BetaMCPToolExecutionError: + properties: + type: + type: string + enum: + - mcp_tool_execution_error + default: mcp_tool_execution_error + x-stainless-const: true + content: {} + type: object + required: + - type + - content + BetaMCPProtocolError: + properties: + type: + type: string + enum: + - mcp_protocol_error + default: mcp_protocol_error + x-stainless-const: true + code: + type: integer + message: + type: string + type: object + required: + - type + - code + - message BetaMCPApprovalResponse: type: object title: MCP approval response @@ -69762,6 +70376,12 @@ components: The encrypted content of the reasoning item. This is populated by default for reasoning items returned by `POST /v1/responses` and WebSocket `response.create` requests. + + When streaming, use the completed reasoning item and its + `encrypted_content` from the `response.output_item.done` event in + subsequent requests. The `encrypted_content` in + `response.output_item.added` may be incomplete. This is especially + important when `store` is `false` or when using Zero Data Retention. - type: 'null' summary: type: array @@ -71629,6 +72249,8 @@ components: - o4-mini-deep-research-2025-06-26 - computer-use-preview - computer-use-preview-2025-03-11 + - gpt-5.5-pro + - gpt-5.5-pro-2026-04-23 - gpt-5-codex - gpt-5-pro - gpt-5-pro-2025-10-06 @@ -73151,6 +73773,8 @@ components: - $ref: '#/components/schemas/BetaResponseProperties' - type: object properties: + service_tier: + $ref: '#/components/schemas/BetaServiceTierResponses' truncation: anyOf: - type: string @@ -73501,6 +74125,29 @@ components: - empty_image_file - failed_to_download_image - image_file_not_found + BetaServiceTierResponses: + anyOf: + - type: string + description: | + Specifies the processing type used for serving the request. + - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'. + - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model. + - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier. + - To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. + - If set to 'ultrafast', then the request will be processed with the access-controlled Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a response served through it will show `service_tier=ultrafast`. + - When not set, the default behavior is 'auto'. + + When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter. + enum: + - auto + - default + - flex + - scale + - priority + - fast + - ultrafast + default: auto + - type: 'null' BetaResponseProperties: type: object properties: @@ -73667,8 +74314,6 @@ components: description: | Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](https://platform.openai.com/docs/guides/prompt-caching). - type: 'null' - service_tier: - $ref: '#/components/schemas/BetaServiceTier' prompt_cache_retention: deprecated: true anyOf: @@ -73689,27 +74334,6 @@ components: - Organizations without ZDR enabled default to `24h`. - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified. - type: 'null' - BetaServiceTier: - anyOf: - - type: string - description: | - Specifies the processing type used for serving the request. - - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'. - - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model. - - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier. - - To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. - - When not set, the default behavior is 'auto'. - - When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter. - enum: - - auto - - default - - flex - - scale - - priority - - fast - default: auto - - type: 'null' BetaMetadata: anyOf: - type: object @@ -73757,7 +74381,9 @@ components: type: integer description: The sequence number of this event. annotation: - type: object + anyOf: + - $ref: '#/components/schemas/BetaAnnotation' + - type: 'null' description: The annotation object being added. (See annotation schema for details.) required: - type @@ -73778,10 +74404,10 @@ components: "content_index": 0, "annotation_index": 0, "annotation": { - "type": "text_annotation", - "text": "This is a test annotation", - "start": 0, - "end": 10 + "type": "file_citation", + "file_id": "file-abc", + "index": 0, + "filename": "example.txt" }, "sequence_number": 1 } @@ -75009,7 +75635,10 @@ components: item: $ref: '#/components/schemas/BetaOutputItem' description: | - The output item that was added. + The output item that was added. For reasoning items, `encrypted_content` + may be incomplete while the item is in progress. Use the reasoning item + from the corresponding `response.output_item.done` event when passing it + as input to a subsequent request. required: - type - output_index @@ -76530,18 +77159,6 @@ components: The WebSocket lane that emitted this event. This field is present when the originating `response.create` event supplied a `stream_id`. - - title: BetaResponseWsError - description: Emitted when an error occurs. - allOf: - - $ref: '#/components/schemas/BetaResponseErrorEvent' - - type: object - properties: - stream_id: - type: string - description: | - The WebSocket lane that emitted this event. This field is present - when the originating `response.create` event supplied a - `stream_id`. - title: BetaResponseFileSearchCallWsCompleted description: Emitted when a file search call is completed (results found). allOf: @@ -77028,6 +77645,7 @@ components: The WebSocket lane that emitted this event. This field is present when the originating `response.create` event supplied a `stream_id`. + - $ref: '#/components/schemas/BetaResponseWsError' - $ref: '#/components/schemas/BetaResponseInjectCreatedEvent' - $ref: '#/components/schemas/BetaResponseInjectFailedEvent' BetaResponseInjectFailedEvent: @@ -77137,9 +77755,142 @@ components: "response_id": "resp_123", "sequence_number": 8 } + BetaResponseWsError: + type: object + title: ResponseWsError + description: Emitted when an error occurs while processing a Responses WebSocket request. + properties: + agent: + anyOf: + - $ref: '#/components/schemas/BetaAgentTag' + - type: 'null' + description: The agent that owns this multi-agent streaming event. + type: + type: string + description: The type of the event. Always `error`. + enum: + - error + x-stainless-const: true + status: + type: integer + description: The HTTP status code associated with a WebSocket protocol error. + sequence_number: + type: integer + description: The sequence number of an error emitted by the response stream. + error: + $ref: '#/components/schemas/BetaErrorPayload' + description: Details about the error. + stream_id: + type: string + description: | + The WebSocket lane that emitted this event. This field is present when the + originating `response.create` event supplied a `stream_id`. + required: + - type + - error + x-oaiMeta: + name: error + group: responses + example: | + { + "type": "error", + "status": 400, + "stream_id": "agent_1", + "error": { + "type": "invalid_request_error", + "code": "websocket_stream_limit_reached", + "message": "This WebSocket connection has reached its stream limit.", + "param": "stream_id" + } + } + BetaErrorPayload: + properties: + type: + type: string + description: The error type that was emitted. + code: + anyOf: + - type: string + description: The error code that was emitted, if any. + - type: 'null' + message: + type: string + description: The human-readable error message that was emitted. + param: + anyOf: + - type: string + description: The parameter name that was associated with the error, if any. + - type: 'null' + headers: + additionalProperties: + type: string + description: The header value that was emitted. + type: object + description: The response headers that were emitted with the error, if any. + x-oaiTypeLabel: map + type: object + required: + - type + - code + - message + - param + title: Error payload + description: An error payload that was emitted for a streaming error event. BetaResponsesWebSocketStreamEvent: allOf: - - $ref: '#/components/schemas/BetaResponseStreamEvent' + - anyOf: + - $ref: '#/components/schemas/BetaResponseAudioDeltaEvent' + - $ref: '#/components/schemas/BetaResponseAudioDoneEvent' + - $ref: '#/components/schemas/BetaResponseAudioTranscriptDeltaEvent' + - $ref: '#/components/schemas/BetaResponseAudioTranscriptDoneEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCodeDeltaEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCodeDoneEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallInterpretingEvent' + - $ref: '#/components/schemas/BetaResponseCompletedEvent' + - $ref: '#/components/schemas/BetaResponseContentPartAddedEvent' + - $ref: '#/components/schemas/BetaResponseContentPartDoneEvent' + - $ref: '#/components/schemas/BetaResponseCreatedEvent' + - $ref: '#/components/schemas/BetaResponseFileSearchCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseFileSearchCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseFileSearchCallSearchingEvent' + - $ref: '#/components/schemas/BetaResponseFunctionCallArgumentsDeltaEvent' + - $ref: '#/components/schemas/BetaResponseFunctionCallArgumentsDoneEvent' + - $ref: '#/components/schemas/BetaResponseInProgressEvent' + - $ref: '#/components/schemas/BetaResponseFailedEvent' + - $ref: '#/components/schemas/BetaResponseIncompleteEvent' + - $ref: '#/components/schemas/BetaResponseOutputItemAddedEvent' + - $ref: '#/components/schemas/BetaResponseOutputItemDoneEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryPartAddedEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryPartDoneEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryTextDeltaEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryTextDoneEvent' + - $ref: '#/components/schemas/BetaResponseReasoningTextDeltaEvent' + - $ref: '#/components/schemas/BetaResponseReasoningTextDoneEvent' + - $ref: '#/components/schemas/BetaResponseRefusalDeltaEvent' + - $ref: '#/components/schemas/BetaResponseRefusalDoneEvent' + - $ref: '#/components/schemas/BetaResponseTextDeltaEvent' + - $ref: '#/components/schemas/BetaResponseTextDoneEvent' + - $ref: '#/components/schemas/BetaResponseWebSearchCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseWebSearchCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseWebSearchCallSearchingEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallGeneratingEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallPartialImageEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallArgumentsDeltaEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallArgumentsDoneEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallFailedEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseMCPListToolsCompletedEvent' + - $ref: '#/components/schemas/BetaResponseMCPListToolsFailedEvent' + - $ref: '#/components/schemas/BetaResponseMCPListToolsInProgressEvent' + - $ref: '#/components/schemas/BetaResponseOutputTextAnnotationAddedEvent' + - $ref: '#/components/schemas/BetaResponseQueuedEvent' + - $ref: '#/components/schemas/BetaResponseCustomToolCallInputDeltaEvent' + - $ref: '#/components/schemas/BetaResponseCustomToolCallInputDoneEvent' - type: object properties: stream_id: @@ -77148,64 +77899,6 @@ components: The WebSocket lane that emitted this event. This field is present when the originating `response.create` event supplied a `stream_id`. - BetaResponseStreamEvent: - description: Event emitted while a response is streamed. - anyOf: - - $ref: '#/components/schemas/BetaResponseAudioDeltaEvent' - - $ref: '#/components/schemas/BetaResponseAudioDoneEvent' - - $ref: '#/components/schemas/BetaResponseAudioTranscriptDeltaEvent' - - $ref: '#/components/schemas/BetaResponseAudioTranscriptDoneEvent' - - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCodeDeltaEvent' - - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCodeDoneEvent' - - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCompletedEvent' - - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallInProgressEvent' - - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallInterpretingEvent' - - $ref: '#/components/schemas/BetaResponseCompletedEvent' - - $ref: '#/components/schemas/BetaResponseContentPartAddedEvent' - - $ref: '#/components/schemas/BetaResponseContentPartDoneEvent' - - $ref: '#/components/schemas/BetaResponseCreatedEvent' - - $ref: '#/components/schemas/BetaResponseErrorEvent' - - $ref: '#/components/schemas/BetaResponseFileSearchCallCompletedEvent' - - $ref: '#/components/schemas/BetaResponseFileSearchCallInProgressEvent' - - $ref: '#/components/schemas/BetaResponseFileSearchCallSearchingEvent' - - $ref: '#/components/schemas/BetaResponseFunctionCallArgumentsDeltaEvent' - - $ref: '#/components/schemas/BetaResponseFunctionCallArgumentsDoneEvent' - - $ref: '#/components/schemas/BetaResponseInProgressEvent' - - $ref: '#/components/schemas/BetaResponseFailedEvent' - - $ref: '#/components/schemas/BetaResponseIncompleteEvent' - - $ref: '#/components/schemas/BetaResponseOutputItemAddedEvent' - - $ref: '#/components/schemas/BetaResponseOutputItemDoneEvent' - - $ref: '#/components/schemas/BetaResponseReasoningSummaryPartAddedEvent' - - $ref: '#/components/schemas/BetaResponseReasoningSummaryPartDoneEvent' - - $ref: '#/components/schemas/BetaResponseReasoningSummaryTextDeltaEvent' - - $ref: '#/components/schemas/BetaResponseReasoningSummaryTextDoneEvent' - - $ref: '#/components/schemas/BetaResponseReasoningTextDeltaEvent' - - $ref: '#/components/schemas/BetaResponseReasoningTextDoneEvent' - - $ref: '#/components/schemas/BetaResponseRefusalDeltaEvent' - - $ref: '#/components/schemas/BetaResponseRefusalDoneEvent' - - $ref: '#/components/schemas/BetaResponseTextDeltaEvent' - - $ref: '#/components/schemas/BetaResponseTextDoneEvent' - - $ref: '#/components/schemas/BetaResponseWebSearchCallCompletedEvent' - - $ref: '#/components/schemas/BetaResponseWebSearchCallInProgressEvent' - - $ref: '#/components/schemas/BetaResponseWebSearchCallSearchingEvent' - - $ref: '#/components/schemas/BetaResponseImageGenCallCompletedEvent' - - $ref: '#/components/schemas/BetaResponseImageGenCallGeneratingEvent' - - $ref: '#/components/schemas/BetaResponseImageGenCallInProgressEvent' - - $ref: '#/components/schemas/BetaResponseImageGenCallPartialImageEvent' - - $ref: '#/components/schemas/BetaResponseMCPCallArgumentsDeltaEvent' - - $ref: '#/components/schemas/BetaResponseMCPCallArgumentsDoneEvent' - - $ref: '#/components/schemas/BetaResponseMCPCallCompletedEvent' - - $ref: '#/components/schemas/BetaResponseMCPCallFailedEvent' - - $ref: '#/components/schemas/BetaResponseMCPCallInProgressEvent' - - $ref: '#/components/schemas/BetaResponseMCPListToolsCompletedEvent' - - $ref: '#/components/schemas/BetaResponseMCPListToolsFailedEvent' - - $ref: '#/components/schemas/BetaResponseMCPListToolsInProgressEvent' - - $ref: '#/components/schemas/BetaResponseOutputTextAnnotationAddedEvent' - - $ref: '#/components/schemas/BetaResponseQueuedEvent' - - $ref: '#/components/schemas/BetaResponseCustomToolCallInputDeltaEvent' - - $ref: '#/components/schemas/BetaResponseCustomToolCallInputDoneEvent' - discriminator: - propertyName: type BetaResponsesClientEvent: discriminator: propertyName: type @@ -77305,6 +77998,8 @@ components: - $ref: '#/components/schemas/BetaResponseProperties' - type: object properties: + service_tier: + $ref: '#/components/schemas/BetaServiceTierResponses' truncation: deprecated: true anyOf: @@ -77515,6 +78210,64 @@ components: type: integer minimum: 0 maximum: 20 + BetaResponseStreamEvent: + description: Event emitted while a response is streamed. + anyOf: + - $ref: '#/components/schemas/BetaResponseAudioDeltaEvent' + - $ref: '#/components/schemas/BetaResponseAudioDoneEvent' + - $ref: '#/components/schemas/BetaResponseAudioTranscriptDeltaEvent' + - $ref: '#/components/schemas/BetaResponseAudioTranscriptDoneEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCodeDeltaEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCodeDoneEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseCodeInterpreterCallInterpretingEvent' + - $ref: '#/components/schemas/BetaResponseCompletedEvent' + - $ref: '#/components/schemas/BetaResponseContentPartAddedEvent' + - $ref: '#/components/schemas/BetaResponseContentPartDoneEvent' + - $ref: '#/components/schemas/BetaResponseCreatedEvent' + - $ref: '#/components/schemas/BetaResponseErrorEvent' + - $ref: '#/components/schemas/BetaResponseFileSearchCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseFileSearchCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseFileSearchCallSearchingEvent' + - $ref: '#/components/schemas/BetaResponseFunctionCallArgumentsDeltaEvent' + - $ref: '#/components/schemas/BetaResponseFunctionCallArgumentsDoneEvent' + - $ref: '#/components/schemas/BetaResponseInProgressEvent' + - $ref: '#/components/schemas/BetaResponseFailedEvent' + - $ref: '#/components/schemas/BetaResponseIncompleteEvent' + - $ref: '#/components/schemas/BetaResponseOutputItemAddedEvent' + - $ref: '#/components/schemas/BetaResponseOutputItemDoneEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryPartAddedEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryPartDoneEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryTextDeltaEvent' + - $ref: '#/components/schemas/BetaResponseReasoningSummaryTextDoneEvent' + - $ref: '#/components/schemas/BetaResponseReasoningTextDeltaEvent' + - $ref: '#/components/schemas/BetaResponseReasoningTextDoneEvent' + - $ref: '#/components/schemas/BetaResponseRefusalDeltaEvent' + - $ref: '#/components/schemas/BetaResponseRefusalDoneEvent' + - $ref: '#/components/schemas/BetaResponseTextDeltaEvent' + - $ref: '#/components/schemas/BetaResponseTextDoneEvent' + - $ref: '#/components/schemas/BetaResponseWebSearchCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseWebSearchCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseWebSearchCallSearchingEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallGeneratingEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseImageGenCallPartialImageEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallArgumentsDeltaEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallArgumentsDoneEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallCompletedEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallFailedEvent' + - $ref: '#/components/schemas/BetaResponseMCPCallInProgressEvent' + - $ref: '#/components/schemas/BetaResponseMCPListToolsCompletedEvent' + - $ref: '#/components/schemas/BetaResponseMCPListToolsFailedEvent' + - $ref: '#/components/schemas/BetaResponseMCPListToolsInProgressEvent' + - $ref: '#/components/schemas/BetaResponseOutputTextAnnotationAddedEvent' + - $ref: '#/components/schemas/BetaResponseQueuedEvent' + - $ref: '#/components/schemas/BetaResponseCustomToolCallInputDeltaEvent' + - $ref: '#/components/schemas/BetaResponseCustomToolCallInputDoneEvent' + discriminator: + propertyName: type OAuthErrorCode: anyOf: - enum: @@ -77654,6 +78407,7 @@ components: - gpt-5.6-terra - gpt-5.6-luna - gpt-5.5 + - gpt-5.5-2026-04-23 - gpt-5.4 - gpt-5.4-mini - gpt-5.4-nano @@ -78059,6 +78813,19 @@ components: - $ref: '#/components/schemas/ScrollParam' - $ref: '#/components/schemas/TypeParam' - $ref: '#/components/schemas/WaitParam' + responses: + TooManyRequests: + description: The request was rejected because a rate limit was exceeded. + headers: + Retry-After: + description: The minimum number of seconds to wait before retrying. This header is returned when the server has computed a retry delay and may be omitted for 429 responses that require user action. + schema: + type: integer + minimum: 1 + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' securitySchemes: ApiKeyAuth: type: http diff --git a/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt b/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt index 8235aa1f9..d1a4bacd6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt @@ -289,6 +289,10 @@ private constructor( @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + @JvmField val GPT_5_5_PRO = of("gpt-5.5-pro") + + @JvmField val GPT_5_5_PRO_2026_04_23 = of("gpt-5.5-pro-2026-04-23") + @JvmField val GPT_5_CODEX = of("gpt-5-codex") @JvmField val GPT_5_PRO = of("gpt-5-pro") @@ -318,6 +322,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -347,6 +353,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -380,6 +388,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Value.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Value.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 @@ -411,6 +421,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Known.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Known.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt index 57c2ed127..e583c563a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt @@ -28,6 +28,8 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField Value.GPT_5_6_TERRA GPT_5_6_LUNA -> Value.GPT_5_6_LUNA GPT_5_5 -> Value.GPT_5_5 + GPT_5_5_2026_04_23 -> Value.GPT_5_5_2026_04_23 GPT_5_4 -> Value.GPT_5_4 GPT_5_4_MINI -> Value.GPT_5_4_MINI GPT_5_4_NANO -> Value.GPT_5_4_NANO @@ -479,6 +484,7 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField Known.GPT_5_6_TERRA GPT_5_6_LUNA -> Known.GPT_5_6_LUNA GPT_5_5 -> Known.GPT_5_5 + GPT_5_5_2026_04_23 -> Known.GPT_5_5_2026_04_23 GPT_5_4 -> Known.GPT_5_4 GPT_5_4_MINI -> Known.GPT_5_4_MINI GPT_5_4_NANO -> Known.GPT_5_4_NANO diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt index 566aadcd9..0dc483699 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt @@ -288,6 +288,10 @@ private constructor( @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + @JvmField val GPT_5_5_PRO = of("gpt-5.5-pro") + + @JvmField val GPT_5_5_PRO_2026_04_23 = of("gpt-5.5-pro-2026-04-23") + @JvmField val GPT_5_CODEX = of("gpt-5-codex") @JvmField val GPT_5_PRO = of("gpt-5-pro") @@ -317,6 +321,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -346,6 +352,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -379,6 +387,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Value.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Value.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 @@ -410,6 +420,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Known.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Known.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaMcpToolCallError.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaMcpToolCallError.kt new file mode 100644 index 000000000..b2b84bf94 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaMcpToolCallError.kt @@ -0,0 +1,935 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.beta.responses + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.core.getOrThrow +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = BetaMcpToolCallError.Deserializer::class) +@JsonSerialize(using = BetaMcpToolCallError.Serializer::class) +class BetaMcpToolCallError +private constructor( + private val mcpProtocol: McpProtocolError? = null, + private val mcpToolExecution: McpToolExecutionError? = null, + private val http: HttpError? = null, + private val _json: JsonValue? = null, +) { + + fun mcpProtocol(): Optional = Optional.ofNullable(mcpProtocol) + + fun mcpToolExecution(): Optional = Optional.ofNullable(mcpToolExecution) + + fun http(): Optional = Optional.ofNullable(http) + + fun isMcpProtocol(): Boolean = mcpProtocol != null + + fun isMcpToolExecution(): Boolean = mcpToolExecution != null + + fun isHttp(): Boolean = http != null + + fun asMcpProtocol(): McpProtocolError = mcpProtocol.getOrThrow("mcpProtocol") + + fun asMcpToolExecution(): McpToolExecutionError = + mcpToolExecution.getOrThrow("mcpToolExecution") + + fun asHttp(): HttpError = http.getOrThrow("http") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = betaMcpToolCallError.accept(new BetaMcpToolCallError.Visitor>() { + * @Override + * public Optional visitMcpProtocol(McpProtocolError mcpProtocol) { + * return Optional.of(mcpProtocol.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + mcpProtocol != null -> visitor.visitMcpProtocol(mcpProtocol) + mcpToolExecution != null -> visitor.visitMcpToolExecution(mcpToolExecution) + http != null -> visitor.visitHttp(http) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaMcpToolCallError = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitMcpProtocol(mcpProtocol: McpProtocolError) { + mcpProtocol.validate() + } + + override fun visitMcpToolExecution(mcpToolExecution: McpToolExecutionError) { + mcpToolExecution.validate() + } + + override fun visitHttp(http: HttpError) { + http.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitMcpProtocol(mcpProtocol: McpProtocolError) = + mcpProtocol.validity() + + override fun visitMcpToolExecution(mcpToolExecution: McpToolExecutionError) = + mcpToolExecution.validity() + + override fun visitHttp(http: HttpError) = http.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaMcpToolCallError && + mcpProtocol == other.mcpProtocol && + mcpToolExecution == other.mcpToolExecution && + http == other.http + } + + override fun hashCode(): Int = Objects.hash(mcpProtocol, mcpToolExecution, http) + + override fun toString(): String = + when { + mcpProtocol != null -> "BetaMcpToolCallError{mcpProtocol=$mcpProtocol}" + mcpToolExecution != null -> "BetaMcpToolCallError{mcpToolExecution=$mcpToolExecution}" + http != null -> "BetaMcpToolCallError{http=$http}" + _json != null -> "BetaMcpToolCallError{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaMcpToolCallError") + } + + companion object { + + @JvmStatic + fun ofMcpProtocol(mcpProtocol: McpProtocolError) = + BetaMcpToolCallError(mcpProtocol = mcpProtocol) + + @JvmStatic + fun ofMcpToolExecution(mcpToolExecution: McpToolExecutionError) = + BetaMcpToolCallError(mcpToolExecution = mcpToolExecution) + + @JvmStatic fun ofHttp(http: HttpError) = BetaMcpToolCallError(http = http) + } + + /** + * An interface that defines how to map each variant of [BetaMcpToolCallError] to a value of + * type [T]. + */ + interface Visitor { + + fun visitMcpProtocol(mcpProtocol: McpProtocolError): T + + fun visitMcpToolExecution(mcpToolExecution: McpToolExecutionError): T + + fun visitHttp(http: HttpError): T + + /** + * Maps an unknown variant of [BetaMcpToolCallError] to a value of type [T]. + * + * An instance of [BetaMcpToolCallError] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown BetaMcpToolCallError: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BetaMcpToolCallError::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaMcpToolCallError { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "mcp_protocol_error" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BetaMcpToolCallError(mcpProtocol = it, _json = json) + } ?: BetaMcpToolCallError(_json = json) + } + "mcp_tool_execution_error" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BetaMcpToolCallError(mcpToolExecution = it, _json = json) + } ?: BetaMcpToolCallError(_json = json) + } + "http_error" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BetaMcpToolCallError(http = it, _json = json) + } ?: BetaMcpToolCallError(_json = json) + } + } + + return BetaMcpToolCallError(_json = json) + } + } + + internal class Serializer : BaseSerializer(BetaMcpToolCallError::class) { + + override fun serialize( + value: BetaMcpToolCallError, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.mcpProtocol != null -> generator.writeObject(value.mcpProtocol) + value.mcpToolExecution != null -> generator.writeObject(value.mcpToolExecution) + value.http != null -> generator.writeObject(value.http) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaMcpToolCallError") + } + } + } + + class McpProtocolError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val message: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(code, message, type, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mcp_protocol_error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpProtocolError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpProtocolError]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var type: JsonValue = JsonValue.from("mcp_protocol_error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpProtocolError: McpProtocolError) = apply { + code = mcpProtocolError.code + message = mcpProtocolError.message + type = mcpProtocolError.type + additionalProperties = mcpProtocolError.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mcp_protocol_error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpProtocolError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): McpProtocolError = + McpProtocolError( + checkRequired("code", code), + checkRequired("message", message), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): McpProtocolError = apply { + if (validated) { + return@apply + } + + code() + message() + _type().let { + if (it != JsonValue.from("mcp_protocol_error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("mcp_protocol_error")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpProtocolError && + code == other.code && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, message, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpProtocolError{code=$code, message=$message, type=$type, additionalProperties=$additionalProperties}" + } + + class McpToolExecutionError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") @ExcludeMissing content: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(content, type, mutableMapOf()) + + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = mcpToolExecutionError.content().convert(MyClass.class); + * ``` + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonValue = content + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mcp_tool_execution_error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpToolExecutionError]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolExecutionError]. */ + class Builder internal constructor() { + + private var content: JsonValue? = null + private var type: JsonValue = JsonValue.from("mcp_tool_execution_error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolExecutionError: McpToolExecutionError) = apply { + content = mcpToolExecutionError.content + type = mcpToolExecutionError.type + additionalProperties = mcpToolExecutionError.additionalProperties.toMutableMap() + } + + fun content(content: JsonValue) = apply { this.content = content } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mcp_tool_execution_error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolExecutionError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): McpToolExecutionError = + McpToolExecutionError( + checkRequired("content", content), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): McpToolExecutionError = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("mcp_tool_execution_error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("mcp_tool_execution_error")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolExecutionError && + content == other.content && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolExecutionError{content=$content, type=$type, additionalProperties=$additionalProperties}" + } + + class HttpError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val message: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(code, message, type, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("http_error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [HttpError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HttpError]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var type: JsonValue = JsonValue.from("http_error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(httpError: HttpError) = apply { + code = httpError.code + message = httpError.message + type = httpError.type + additionalProperties = httpError.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("http_error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [HttpError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HttpError = + HttpError( + checkRequired("code", code), + checkRequired("message", message), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): HttpError = apply { + if (validated) { + return@apply + } + + code() + message() + _type().let { + if (it != JsonValue.from("http_error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("http_error")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HttpError && + code == other.code && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, message, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HttpError{code=$code, message=$message, type=$type, additionalProperties=$additionalProperties}" + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponse.kt index 352293e62..57673b56a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponse.kt @@ -507,6 +507,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -1978,6 +1981,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -2972,6 +2978,8 @@ private constructor( @JvmField val GPT_5_5 = of("gpt-5.5") + @JvmField val GPT_5_5_2026_04_23 = of("gpt-5.5-2026-04-23") + @JvmField val GPT_5_4 = of("gpt-5.4") @JvmField val GPT_5_4_MINI = of("gpt-5.4-mini") @@ -3150,6 +3158,10 @@ private constructor( @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + @JvmField val GPT_5_5_PRO = of("gpt-5.5-pro") + + @JvmField val GPT_5_5_PRO_2026_04_23 = of("gpt-5.5-pro-2026-04-23") + @JvmField val GPT_5_CODEX = of("gpt-5-codex") @JvmField val GPT_5_PRO = of("gpt-5-pro") @@ -3173,6 +3185,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -3261,6 +3274,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -3284,6 +3299,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -3372,6 +3388,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -3396,6 +3414,7 @@ private constructor( GPT_5_6_TERRA -> Value.GPT_5_6_TERRA GPT_5_6_LUNA -> Value.GPT_5_6_LUNA GPT_5_5 -> Value.GPT_5_5 + GPT_5_5_2026_04_23 -> Value.GPT_5_5_2026_04_23 GPT_5_4 -> Value.GPT_5_4 GPT_5_4_MINI -> Value.GPT_5_4_MINI GPT_5_4_NANO -> Value.GPT_5_4_NANO @@ -3484,6 +3503,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Value.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Value.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 @@ -3509,6 +3530,7 @@ private constructor( GPT_5_6_TERRA -> Known.GPT_5_6_TERRA GPT_5_6_LUNA -> Known.GPT_5_6_LUNA GPT_5_5 -> Known.GPT_5_5 + GPT_5_5_2026_04_23 -> Known.GPT_5_5_2026_04_23 GPT_5_4 -> Known.GPT_5_4 GPT_5_4_MINI -> Known.GPT_5_4_MINI GPT_5_4_NANO -> Known.GPT_5_4_NANO @@ -3597,6 +3619,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Known.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Known.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 @@ -9050,6 +9074,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -9083,6 +9110,8 @@ private constructor( @JvmField val FAST = of("fast") + @JvmField val ULTRAFAST = of("ultrafast") + @JvmStatic fun of(value: String) = ServiceTier(JsonField.of(value)) } @@ -9094,6 +9123,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, } /** @@ -9112,6 +9142,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, /** * An enum member indicating that [ServiceTier] was instantiated with an unknown value. */ @@ -9133,6 +9164,7 @@ private constructor( SCALE -> Value.SCALE PRIORITY -> Value.PRIORITY FAST -> Value.FAST + ULTRAFAST -> Value.ULTRAFAST else -> Value._UNKNOWN } @@ -9153,6 +9185,7 @@ private constructor( SCALE -> Known.SCALE PRIORITY -> Known.PRIORITY FAST -> Known.FAST + ULTRAFAST -> Known.ULTRAFAST else -> throw OpenAIInvalidDataException("Unknown ServiceTier: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseInputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseInputItem.kt index a8fe37523..5f78e009d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseInputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseInputItem.kt @@ -21740,7 +21740,7 @@ private constructor( private val type: JsonValue, private val agent: JsonField, private val approvalRequestId: JsonField, - private val error: JsonField, + private val error: JsonField, private val output: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -21761,7 +21761,9 @@ private constructor( @JsonProperty("approval_request_id") @ExcludeMissing approvalRequestId: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), ) : this( @@ -21848,7 +21850,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = error.getOptional("error") + fun error(): Optional = error.getOptional("error") /** * The output from the tool call. @@ -21919,7 +21921,7 @@ private constructor( * * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error /** * Returns the raw JSON value of [output]. @@ -21973,7 +21975,7 @@ private constructor( private var type: JsonValue = JsonValue.from("mcp_call") private var agent: JsonField = JsonMissing.of() private var approvalRequestId: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() private var output: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -22098,19 +22100,45 @@ private constructor( } /** The error from the tool call, if any. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) + fun error(error: BetaMcpToolCallError?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) + fun error(error: Optional) = error(error.getOrNull()) /** * Sets [Builder.error] to an arbitrary JSON value. * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.error] with a well-typed [BetaMcpToolCallError] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun error(error: JsonField) = apply { this.error = error } + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `BetaMcpToolCallError.ofMcpProtocol(mcpProtocol)`. */ + fun error(mcpProtocol: BetaMcpToolCallError.McpProtocolError) = + error(BetaMcpToolCallError.ofMcpProtocol(mcpProtocol)) + + /** + * Alias for calling [error] with + * `BetaMcpToolCallError.ofMcpToolExecution(mcpToolExecution)`. + */ + fun error(mcpToolExecution: BetaMcpToolCallError.McpToolExecutionError) = + error(BetaMcpToolCallError.ofMcpToolExecution(mcpToolExecution)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaMcpToolCallError.McpToolExecutionError.builder() + * .content(content) + * .build() + * ``` + */ + fun mcpToolExecutionError(content: JsonValue) = + error(BetaMcpToolCallError.McpToolExecutionError.builder().content(content).build()) + + /** Alias for calling [error] with `BetaMcpToolCallError.ofHttp(http)`. */ + fun error(http: BetaMcpToolCallError.HttpError) = + error(BetaMcpToolCallError.ofHttp(http)) /** The output from the tool call. */ fun output(output: String?) = output(JsonField.ofNullable(output)) @@ -22219,7 +22247,7 @@ private constructor( } agent().ifPresent { it.validate() } approvalRequestId() - error() + error().ifPresent { it.validate() } output() status().ifPresent { it.validate() } validated = true @@ -22248,7 +22276,7 @@ private constructor( type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } + (agent.asKnown().getOrNull()?.validity() ?: 0) + (if (approvalRequestId.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseItem.kt index c712c94d2..c62dbc216 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseItem.kt @@ -12142,7 +12142,7 @@ private constructor( private val type: JsonValue, private val agent: JsonField, private val approvalRequestId: JsonField, - private val error: JsonField, + private val error: JsonField, private val output: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -12163,7 +12163,9 @@ private constructor( @JsonProperty("approval_request_id") @ExcludeMissing approvalRequestId: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), ) : this( @@ -12250,7 +12252,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = error.getOptional("error") + fun error(): Optional = error.getOptional("error") /** * The output from the tool call. @@ -12321,7 +12323,7 @@ private constructor( * * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error /** * Returns the raw JSON value of [output]. @@ -12375,7 +12377,7 @@ private constructor( private var type: JsonValue = JsonValue.from("mcp_call") private var agent: JsonField = JsonMissing.of() private var approvalRequestId: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() private var output: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12500,19 +12502,45 @@ private constructor( } /** The error from the tool call, if any. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) + fun error(error: BetaMcpToolCallError?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) + fun error(error: Optional) = error(error.getOrNull()) /** * Sets [Builder.error] to an arbitrary JSON value. * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.error] with a well-typed [BetaMcpToolCallError] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun error(error: JsonField) = apply { this.error = error } + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `BetaMcpToolCallError.ofMcpProtocol(mcpProtocol)`. */ + fun error(mcpProtocol: BetaMcpToolCallError.McpProtocolError) = + error(BetaMcpToolCallError.ofMcpProtocol(mcpProtocol)) + + /** + * Alias for calling [error] with + * `BetaMcpToolCallError.ofMcpToolExecution(mcpToolExecution)`. + */ + fun error(mcpToolExecution: BetaMcpToolCallError.McpToolExecutionError) = + error(BetaMcpToolCallError.ofMcpToolExecution(mcpToolExecution)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaMcpToolCallError.McpToolExecutionError.builder() + * .content(content) + * .build() + * ``` + */ + fun mcpToolExecutionError(content: JsonValue) = + error(BetaMcpToolCallError.McpToolExecutionError.builder().content(content).build()) + + /** Alias for calling [error] with `BetaMcpToolCallError.ofHttp(http)`. */ + fun error(http: BetaMcpToolCallError.HttpError) = + error(BetaMcpToolCallError.ofHttp(http)) /** The output from the tool call. */ fun output(output: String?) = output(JsonField.ofNullable(output)) @@ -12621,7 +12649,7 @@ private constructor( } agent().ifPresent { it.validate() } approvalRequestId() - error() + error().ifPresent { it.validate() } output() status().ifPresent { it.validate() } validated = true @@ -12650,7 +12678,7 @@ private constructor( type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } + (agent.asKnown().getOrNull()?.validity() ?: 0) + (if (approvalRequestId.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItem.kt index 111194521..53e95318f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItem.kt @@ -10137,7 +10137,7 @@ private constructor( private val type: JsonValue, private val agent: JsonField, private val approvalRequestId: JsonField, - private val error: JsonField, + private val error: JsonField, private val output: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -10158,7 +10158,9 @@ private constructor( @JsonProperty("approval_request_id") @ExcludeMissing approvalRequestId: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), ) : this( @@ -10245,7 +10247,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = error.getOptional("error") + fun error(): Optional = error.getOptional("error") /** * The output from the tool call. @@ -10316,7 +10318,7 @@ private constructor( * * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error /** * Returns the raw JSON value of [output]. @@ -10370,7 +10372,7 @@ private constructor( private var type: JsonValue = JsonValue.from("mcp_call") private var agent: JsonField = JsonMissing.of() private var approvalRequestId: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() private var output: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10495,19 +10497,45 @@ private constructor( } /** The error from the tool call, if any. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) + fun error(error: BetaMcpToolCallError?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) + fun error(error: Optional) = error(error.getOrNull()) /** * Sets [Builder.error] to an arbitrary JSON value. * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.error] with a well-typed [BetaMcpToolCallError] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun error(error: JsonField) = apply { this.error = error } + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `BetaMcpToolCallError.ofMcpProtocol(mcpProtocol)`. */ + fun error(mcpProtocol: BetaMcpToolCallError.McpProtocolError) = + error(BetaMcpToolCallError.ofMcpProtocol(mcpProtocol)) + + /** + * Alias for calling [error] with + * `BetaMcpToolCallError.ofMcpToolExecution(mcpToolExecution)`. + */ + fun error(mcpToolExecution: BetaMcpToolCallError.McpToolExecutionError) = + error(BetaMcpToolCallError.ofMcpToolExecution(mcpToolExecution)) + + /** + * Alias for calling [error] with the following: + * ```java + * BetaMcpToolCallError.McpToolExecutionError.builder() + * .content(content) + * .build() + * ``` + */ + fun mcpToolExecutionError(content: JsonValue) = + error(BetaMcpToolCallError.McpToolExecutionError.builder().content(content).build()) + + /** Alias for calling [error] with `BetaMcpToolCallError.ofHttp(http)`. */ + fun error(http: BetaMcpToolCallError.HttpError) = + error(BetaMcpToolCallError.ofHttp(http)) /** The output from the tool call. */ fun output(output: String?) = output(JsonField.ofNullable(output)) @@ -10616,7 +10644,7 @@ private constructor( } agent().ifPresent { it.validate() } approvalRequestId() - error() + error().ifPresent { it.validate() } output() status().ifPresent { it.validate() } validated = true @@ -10645,7 +10673,7 @@ private constructor( type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } + (agent.asKnown().getOrNull()?.validity() ?: 0) + (if (approvalRequestId.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemAddedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemAddedEvent.kt index 7f0a3bec3..bbad2ca0d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemAddedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemAddedEvent.kt @@ -45,7 +45,9 @@ private constructor( ) : this(item, outputIndex, sequenceNumber, type, agent, mutableMapOf()) /** - * The output item that was added. + * The output item that was added. For reasoning items, `encrypted_content` may be incomplete + * while the item is in progress. Use the reasoning item from the corresponding + * `response.output_item.done` event when passing it as input to a subsequent request. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -169,7 +171,11 @@ private constructor( betaResponseOutputItemAddedEvent.additionalProperties.toMutableMap() } - /** The output item that was added. */ + /** + * The output item that was added. For reasoning items, `encrypted_content` may be + * incomplete while the item is in progress. Use the reasoning item from the corresponding + * `response.output_item.done` event when passing it as input to a subsequent request. + */ fun item(item: BetaResponseOutputItem) = item(JsonField.of(item)) /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEvent.kt index 27cfa5877..4a8152c9f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEvent.kt @@ -6,11 +6,21 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired +import com.openai.core.getOrThrow import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects @@ -21,7 +31,7 @@ import kotlin.jvm.optionals.getOrNull class BetaResponseOutputTextAnnotationAddedEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val annotation: JsonValue, + private val annotation: JsonField, private val annotationIndex: JsonField, private val contentIndex: JsonField, private val itemId: JsonField, @@ -34,7 +44,9 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("annotation") @ExcludeMissing annotation: JsonValue = JsonMissing.of(), + @JsonProperty("annotation") + @ExcludeMissing + annotation: JsonField = JsonMissing.of(), @JsonProperty("annotation_index") @ExcludeMissing annotationIndex: JsonField = JsonMissing.of(), @@ -63,14 +75,12 @@ private constructor( ) /** - * The annotation object being added. (See annotation schema for details.) + * An annotation that applies to a span of output text. * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = betaResponseOutputTextAnnotationAddedEvent.annotation().convert(MyClass.class); - * ``` + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("annotation") @ExcludeMissing fun _annotation(): JsonValue = annotation + fun annotation(): Optional = annotation.getOptional("annotation") /** * The index of the annotation within the content part. @@ -133,6 +143,15 @@ private constructor( */ fun agent(): Optional = agent.getOptional("agent") + /** + * Returns the raw JSON value of [annotation]. + * + * Unlike [annotation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("annotation") + @ExcludeMissing + fun _annotation(): JsonField = annotation + /** * Returns the raw JSON value of [annotationIndex]. * @@ -215,7 +234,7 @@ private constructor( /** A builder for [BetaResponseOutputTextAnnotationAddedEvent]. */ class Builder internal constructor() { - private var annotation: JsonValue? = null + private var annotation: JsonField? = null private var annotationIndex: JsonField? = null private var contentIndex: JsonField? = null private var itemId: JsonField? = null @@ -241,8 +260,38 @@ private constructor( betaResponseOutputTextAnnotationAddedEvent.additionalProperties.toMutableMap() } - /** The annotation object being added. (See annotation schema for details.) */ - fun annotation(annotation: JsonValue) = apply { this.annotation = annotation } + /** An annotation that applies to a span of output text. */ + fun annotation(annotation: Annotation?) = annotation(JsonField.ofNullable(annotation)) + + /** Alias for calling [Builder.annotation] with `annotation.orElse(null)`. */ + fun annotation(annotation: Optional) = annotation(annotation.getOrNull()) + + /** + * Sets [Builder.annotation] to an arbitrary JSON value. + * + * You should usually call [Builder.annotation] with a well-typed [Annotation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun annotation(annotation: JsonField) = apply { this.annotation = annotation } + + /** Alias for calling [annotation] with `Annotation.ofFileCitation(fileCitation)`. */ + fun annotation(fileCitation: Annotation.FileCitation) = + annotation(Annotation.ofFileCitation(fileCitation)) + + /** Alias for calling [annotation] with `Annotation.ofUrlCitation(urlCitation)`. */ + fun annotation(urlCitation: Annotation.UrlCitation) = + annotation(Annotation.ofUrlCitation(urlCitation)) + + /** + * Alias for calling [annotation] with + * `Annotation.ofContainerFileCitation(containerFileCitation)`. + */ + fun annotation(containerFileCitation: Annotation.ContainerFileCitation) = + annotation(Annotation.ofContainerFileCitation(containerFileCitation)) + + /** Alias for calling [annotation] with `Annotation.ofFilePath(filePath)`. */ + fun annotation(filePath: Annotation.FilePath) = annotation(Annotation.ofFilePath(filePath)) /** The index of the annotation within the content part. */ fun annotationIndex(annotationIndex: Long) = annotationIndex(JsonField.of(annotationIndex)) @@ -400,6 +449,7 @@ private constructor( return@apply } + annotation().ifPresent { it.validate() } annotationIndex() contentIndex() itemId() @@ -429,7 +479,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (annotationIndex.asKnown().isPresent) 1 else 0) + + (annotation.asKnown().getOrNull()?.validity() ?: 0) + + (if (annotationIndex.asKnown().isPresent) 1 else 0) + (if (contentIndex.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (if (outputIndex.asKnown().isPresent) 1 else 0) + @@ -439,6 +490,1592 @@ private constructor( } + (agent.asKnown().getOrNull()?.validity() ?: 0) + /** An annotation that applies to a span of output text. */ + @JsonDeserialize(using = Annotation.Deserializer::class) + @JsonSerialize(using = Annotation.Serializer::class) + class Annotation + private constructor( + private val fileCitation: FileCitation? = null, + private val urlCitation: UrlCitation? = null, + private val containerFileCitation: ContainerFileCitation? = null, + private val filePath: FilePath? = null, + private val _json: JsonValue? = null, + ) { + + /** A citation to a file. */ + fun fileCitation(): Optional = Optional.ofNullable(fileCitation) + + /** A citation for a web resource used to generate a model response. */ + fun urlCitation(): Optional = Optional.ofNullable(urlCitation) + + /** A citation for a container file used to generate a model response. */ + fun containerFileCitation(): Optional = + Optional.ofNullable(containerFileCitation) + + /** A path to a file. */ + fun filePath(): Optional = Optional.ofNullable(filePath) + + fun isFileCitation(): Boolean = fileCitation != null + + fun isUrlCitation(): Boolean = urlCitation != null + + fun isContainerFileCitation(): Boolean = containerFileCitation != null + + fun isFilePath(): Boolean = filePath != null + + /** A citation to a file. */ + fun asFileCitation(): FileCitation = fileCitation.getOrThrow("fileCitation") + + /** A citation for a web resource used to generate a model response. */ + fun asUrlCitation(): UrlCitation = urlCitation.getOrThrow("urlCitation") + + /** A citation for a container file used to generate a model response. */ + fun asContainerFileCitation(): ContainerFileCitation = + containerFileCitation.getOrThrow("containerFileCitation") + + /** A path to a file. */ + fun asFilePath(): FilePath = filePath.getOrThrow("filePath") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = annotation.accept(new Annotation.Visitor>() { + * @Override + * public Optional visitFileCitation(FileCitation fileCitation) { + * return Optional.of(fileCitation.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + fileCitation != null -> visitor.visitFileCitation(fileCitation) + urlCitation != null -> visitor.visitUrlCitation(urlCitation) + containerFileCitation != null -> + visitor.visitContainerFileCitation(containerFileCitation) + filePath != null -> visitor.visitFilePath(filePath) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Annotation = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFileCitation(fileCitation: FileCitation) { + fileCitation.validate() + } + + override fun visitUrlCitation(urlCitation: UrlCitation) { + urlCitation.validate() + } + + override fun visitContainerFileCitation( + containerFileCitation: ContainerFileCitation + ) { + containerFileCitation.validate() + } + + override fun visitFilePath(filePath: FilePath) { + filePath.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitFileCitation(fileCitation: FileCitation) = + fileCitation.validity() + + override fun visitUrlCitation(urlCitation: UrlCitation) = urlCitation.validity() + + override fun visitContainerFileCitation( + containerFileCitation: ContainerFileCitation + ) = containerFileCitation.validity() + + override fun visitFilePath(filePath: FilePath) = filePath.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Annotation && + fileCitation == other.fileCitation && + urlCitation == other.urlCitation && + containerFileCitation == other.containerFileCitation && + filePath == other.filePath + } + + override fun hashCode(): Int = + Objects.hash(fileCitation, urlCitation, containerFileCitation, filePath) + + override fun toString(): String = + when { + fileCitation != null -> "Annotation{fileCitation=$fileCitation}" + urlCitation != null -> "Annotation{urlCitation=$urlCitation}" + containerFileCitation != null -> + "Annotation{containerFileCitation=$containerFileCitation}" + filePath != null -> "Annotation{filePath=$filePath}" + _json != null -> "Annotation{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Annotation") + } + + companion object { + + /** A citation to a file. */ + @JvmStatic + fun ofFileCitation(fileCitation: FileCitation) = Annotation(fileCitation = fileCitation) + + /** A citation for a web resource used to generate a model response. */ + @JvmStatic + fun ofUrlCitation(urlCitation: UrlCitation) = Annotation(urlCitation = urlCitation) + + /** A citation for a container file used to generate a model response. */ + @JvmStatic + fun ofContainerFileCitation(containerFileCitation: ContainerFileCitation) = + Annotation(containerFileCitation = containerFileCitation) + + /** A path to a file. */ + @JvmStatic fun ofFilePath(filePath: FilePath) = Annotation(filePath = filePath) + } + + /** + * An interface that defines how to map each variant of [Annotation] to a value of type [T]. + */ + interface Visitor { + + /** A citation to a file. */ + fun visitFileCitation(fileCitation: FileCitation): T + + /** A citation for a web resource used to generate a model response. */ + fun visitUrlCitation(urlCitation: UrlCitation): T + + /** A citation for a container file used to generate a model response. */ + fun visitContainerFileCitation(containerFileCitation: ContainerFileCitation): T + + /** A path to a file. */ + fun visitFilePath(filePath: FilePath): T + + /** + * Maps an unknown variant of [Annotation] to a value of type [T]. + * + * An instance of [Annotation] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown Annotation: $json") + } + } + + internal class Deserializer : BaseDeserializer(Annotation::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Annotation { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "file_citation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(fileCitation = it, _json = json) + } ?: Annotation(_json = json) + } + "url_citation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(urlCitation = it, _json = json) + } ?: Annotation(_json = json) + } + "container_file_citation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(containerFileCitation = it, _json = json) + } ?: Annotation(_json = json) + } + "file_path" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(filePath = it, _json = json) + } ?: Annotation(_json = json) + } + } + + return Annotation(_json = json) + } + } + + internal class Serializer : BaseSerializer(Annotation::class) { + + override fun serialize( + value: Annotation, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.fileCitation != null -> generator.writeObject(value.fileCitation) + value.urlCitation != null -> generator.writeObject(value.urlCitation) + value.containerFileCitation != null -> + generator.writeObject(value.containerFileCitation) + value.filePath != null -> generator.writeObject(value.filePath) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Annotation") + } + } + } + + /** A citation to a file. */ + class FileCitation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val filename: JsonField, + private val index: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(fileId, filename, index, type, mutableMapOf()) + + /** + * The ID of the file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * The filename of the file cited. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun filename(): String = filename.getRequired("filename") + + /** + * The index of the file in the list of files. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun index(): Long = index.getRequired("index") + + /** + * The type of the file citation. Always `file_citation`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("file_citation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FileCitation]. + * + * The following fields are required: + * ```java + * .fileId() + * .filename() + * .index() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileCitation]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var filename: JsonField? = null + private var index: JsonField? = null + private var type: JsonValue = JsonValue.from("file_citation") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileCitation: FileCitation) = apply { + fileId = fileCitation.fileId + filename = fileCitation.filename + index = fileCitation.index + type = fileCitation.type + additionalProperties = fileCitation.additionalProperties.toMutableMap() + } + + /** The ID of the file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** The filename of the file cited. */ + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filename(filename: JsonField) = apply { this.filename = filename } + + /** The index of the file in the list of files. */ + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun index(index: JsonField) = apply { this.index = index } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("file_citation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileCitation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .filename() + * .index() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileCitation = + FileCitation( + checkRequired("fileId", fileId), + checkRequired("filename", filename), + checkRequired("index", index), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FileCitation = apply { + if (validated) { + return@apply + } + + fileId() + filename() + index() + _type().let { + if (it != JsonValue.from("file_citation")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("file_citation")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileCitation && + fileId == other.fileId && + filename == other.filename && + index == other.index && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fileId, filename, index, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileCitation{fileId=$fileId, filename=$filename, index=$index, type=$type, additionalProperties=$additionalProperties}" + } + + /** A citation for a web resource used to generate a model response. */ + class UrlCitation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endIndex: JsonField, + private val startIndex: JsonField, + private val title: JsonField, + private val type: JsonValue, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_index") + @ExcludeMissing + endIndex: JsonField = JsonMissing.of(), + @JsonProperty("start_index") + @ExcludeMissing + startIndex: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(endIndex, startIndex, title, type, url, mutableMapOf()) + + /** + * The index of the last character of the URL citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun endIndex(): Long = endIndex.getRequired("end_index") + + /** + * The index of the first character of the URL citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startIndex(): Long = startIndex.getRequired("start_index") + + /** + * The title of the web resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun title(): String = title.getRequired("title") + + /** + * The type of the URL citation. Always `url_citation`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("url_citation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The URL of the web resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [endIndex]. + * + * Unlike [endIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_index") @ExcludeMissing fun _endIndex(): JsonField = endIndex + + /** + * Returns the raw JSON value of [startIndex]. + * + * Unlike [startIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_index") + @ExcludeMissing + fun _startIndex(): JsonField = startIndex + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UrlCitation]. + * + * The following fields are required: + * ```java + * .endIndex() + * .startIndex() + * .title() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlCitation]. */ + class Builder internal constructor() { + + private var endIndex: JsonField? = null + private var startIndex: JsonField? = null + private var title: JsonField? = null + private var type: JsonValue = JsonValue.from("url_citation") + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(urlCitation: UrlCitation) = apply { + endIndex = urlCitation.endIndex + startIndex = urlCitation.startIndex + title = urlCitation.title + type = urlCitation.type + url = urlCitation.url + additionalProperties = urlCitation.additionalProperties.toMutableMap() + } + + /** The index of the last character of the URL citation in the message. */ + fun endIndex(endIndex: Long) = endIndex(JsonField.of(endIndex)) + + /** + * Sets [Builder.endIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.endIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun endIndex(endIndex: JsonField) = apply { this.endIndex = endIndex } + + /** The index of the first character of the URL citation in the message. */ + fun startIndex(startIndex: Long) = startIndex(JsonField.of(startIndex)) + + /** + * Sets [Builder.startIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.startIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun startIndex(startIndex: JsonField) = apply { this.startIndex = startIndex } + + /** The title of the web resource. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("url_citation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** The URL of the web resource. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlCitation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endIndex() + * .startIndex() + * .title() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UrlCitation = + UrlCitation( + checkRequired("endIndex", endIndex), + checkRequired("startIndex", startIndex), + checkRequired("title", title), + type, + checkRequired("url", url), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UrlCitation = apply { + if (validated) { + return@apply + } + + endIndex() + startIndex() + title() + _type().let { + if (it != JsonValue.from("url_citation")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endIndex.asKnown().isPresent) 1 else 0) + + (if (startIndex.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("url_citation")) 1 else 0 } + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlCitation && + endIndex == other.endIndex && + startIndex == other.startIndex && + title == other.title && + type == other.type && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(endIndex, startIndex, title, type, url, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UrlCitation{endIndex=$endIndex, startIndex=$startIndex, title=$title, type=$type, url=$url, additionalProperties=$additionalProperties}" + } + + /** A citation for a container file used to generate a model response. */ + class ContainerFileCitation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val containerId: JsonField, + private val endIndex: JsonField, + private val fileId: JsonField, + private val filename: JsonField, + private val startIndex: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("container_id") + @ExcludeMissing + containerId: JsonField = JsonMissing.of(), + @JsonProperty("end_index") + @ExcludeMissing + endIndex: JsonField = JsonMissing.of(), + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("start_index") + @ExcludeMissing + startIndex: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(containerId, endIndex, fileId, filename, startIndex, type, mutableMapOf()) + + /** + * The ID of the container file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun containerId(): String = containerId.getRequired("container_id") + + /** + * The index of the last character of the container file citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun endIndex(): Long = endIndex.getRequired("end_index") + + /** + * The ID of the file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * The filename of the container file cited. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun filename(): String = filename.getRequired("filename") + + /** + * The index of the first character of the container file citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startIndex(): Long = startIndex.getRequired("start_index") + + /** + * The type of the container file citation. Always `container_file_citation`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("container_file_citation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [containerId]. + * + * Unlike [containerId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("container_id") + @ExcludeMissing + fun _containerId(): JsonField = containerId + + /** + * Returns the raw JSON value of [endIndex]. + * + * Unlike [endIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_index") @ExcludeMissing fun _endIndex(): JsonField = endIndex + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [startIndex]. + * + * Unlike [startIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_index") + @ExcludeMissing + fun _startIndex(): JsonField = startIndex + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContainerFileCitation]. + * + * The following fields are required: + * ```java + * .containerId() + * .endIndex() + * .fileId() + * .filename() + * .startIndex() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContainerFileCitation]. */ + class Builder internal constructor() { + + private var containerId: JsonField? = null + private var endIndex: JsonField? = null + private var fileId: JsonField? = null + private var filename: JsonField? = null + private var startIndex: JsonField? = null + private var type: JsonValue = JsonValue.from("container_file_citation") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(containerFileCitation: ContainerFileCitation) = apply { + containerId = containerFileCitation.containerId + endIndex = containerFileCitation.endIndex + fileId = containerFileCitation.fileId + filename = containerFileCitation.filename + startIndex = containerFileCitation.startIndex + type = containerFileCitation.type + additionalProperties = containerFileCitation.additionalProperties.toMutableMap() + } + + /** The ID of the container file. */ + fun containerId(containerId: String) = containerId(JsonField.of(containerId)) + + /** + * Sets [Builder.containerId] to an arbitrary JSON value. + * + * You should usually call [Builder.containerId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun containerId(containerId: JsonField) = apply { + this.containerId = containerId + } + + /** + * The index of the last character of the container file citation in the message. + */ + fun endIndex(endIndex: Long) = endIndex(JsonField.of(endIndex)) + + /** + * Sets [Builder.endIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.endIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun endIndex(endIndex: JsonField) = apply { this.endIndex = endIndex } + + /** The ID of the file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** The filename of the container file cited. */ + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filename(filename: JsonField) = apply { this.filename = filename } + + /** + * The index of the first character of the container file citation in the message. + */ + fun startIndex(startIndex: Long) = startIndex(JsonField.of(startIndex)) + + /** + * Sets [Builder.startIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.startIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun startIndex(startIndex: JsonField) = apply { this.startIndex = startIndex } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("container_file_citation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContainerFileCitation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .containerId() + * .endIndex() + * .fileId() + * .filename() + * .startIndex() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ContainerFileCitation = + ContainerFileCitation( + checkRequired("containerId", containerId), + checkRequired("endIndex", endIndex), + checkRequired("fileId", fileId), + checkRequired("filename", filename), + checkRequired("startIndex", startIndex), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ContainerFileCitation = apply { + if (validated) { + return@apply + } + + containerId() + endIndex() + fileId() + filename() + startIndex() + _type().let { + if (it != JsonValue.from("container_file_citation")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (containerId.asKnown().isPresent) 1 else 0) + + (if (endIndex.asKnown().isPresent) 1 else 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (startIndex.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("container_file_citation")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContainerFileCitation && + containerId == other.containerId && + endIndex == other.endIndex && + fileId == other.fileId && + filename == other.filename && + startIndex == other.startIndex && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + containerId, + endIndex, + fileId, + filename, + startIndex, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContainerFileCitation{containerId=$containerId, endIndex=$endIndex, fileId=$fileId, filename=$filename, startIndex=$startIndex, type=$type, additionalProperties=$additionalProperties}" + } + + /** A path to a file. */ + class FilePath + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val index: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(fileId, index, type, mutableMapOf()) + + /** + * The ID of the file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * The index of the file in the list of files. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun index(): Long = index.getRequired("index") + + /** + * The type of the file path. Always `file_path`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("file_path") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FilePath]. + * + * The following fields are required: + * ```java + * .fileId() + * .index() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FilePath]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var index: JsonField? = null + private var type: JsonValue = JsonValue.from("file_path") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filePath: FilePath) = apply { + fileId = filePath.fileId + index = filePath.index + type = filePath.type + additionalProperties = filePath.additionalProperties.toMutableMap() + } + + /** The ID of the file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** The index of the file in the list of files. */ + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun index(index: JsonField) = apply { this.index = index } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("file_path") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FilePath]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .index() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FilePath = + FilePath( + checkRequired("fileId", fileId), + checkRequired("index", index), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FilePath = apply { + if (validated) { + return@apply + } + + fileId() + index() + _type().let { + if (it != JsonValue.from("file_path")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("file_path")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FilePath && + fileId == other.fileId && + index == other.index && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fileId, index, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FilePath{fileId=$fileId, index=$index, type=$type, additionalProperties=$additionalProperties}" + } + } + /** The agent that owns this multi-agent streaming event. */ class Agent @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseReasoningItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseReasoningItem.kt index fbe3a3e51..7bd34e1e7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseReasoningItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponseReasoningItem.kt @@ -105,6 +105,11 @@ private constructor( * The encrypted content of the reasoning item. This is populated by default for reasoning items * returned by `POST /v1/responses` and WebSocket `response.create` requests. * + * When streaming, use the completed reasoning item and its `encrypted_content` from the + * `response.output_item.done` event in subsequent requests. The `encrypted_content` in + * `response.output_item.added` may be incomplete. This is especially important when `store` is + * `false` or when using Zero Data Retention. + * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -308,6 +313,11 @@ private constructor( /** * The encrypted content of the reasoning item. This is populated by default for reasoning * items returned by `POST /v1/responses` and WebSocket `response.create` requests. + * + * When streaming, use the completed reasoning item and its `encrypted_content` from the + * `response.output_item.done` event in subsequent requests. The `encrypted_content` in + * `response.output_item.added` may be incomplete. This is especially important when `store` + * is `false` or when using Zero Data Retention. */ fun encryptedContent(encryptedContent: String?) = encryptedContent(JsonField.ofNullable(encryptedContent)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesClientEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesClientEvent.kt index 06a2367b1..73d4170ce 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesClientEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesClientEvent.kt @@ -747,6 +747,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -1863,6 +1866,10 @@ private constructor( * the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the + * access-controlled Ultrafast Processing service tier. This tier is currently + * available for `gpt-5.6-sol`; a response served through it will show + * `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -3406,6 +3413,8 @@ private constructor( @JvmField val GPT_5_5 = of("gpt-5.5") + @JvmField val GPT_5_5_2026_04_23 = of("gpt-5.5-2026-04-23") + @JvmField val GPT_5_4 = of("gpt-5.4") @JvmField val GPT_5_4_MINI = of("gpt-5.4-mini") @@ -3592,6 +3601,10 @@ private constructor( @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + @JvmField val GPT_5_5_PRO = of("gpt-5.5-pro") + + @JvmField val GPT_5_5_PRO_2026_04_23 = of("gpt-5.5-pro-2026-04-23") + @JvmField val GPT_5_CODEX = of("gpt-5-codex") @JvmField val GPT_5_PRO = of("gpt-5-pro") @@ -3615,6 +3628,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -3703,6 +3717,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -3726,6 +3742,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -3814,6 +3831,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -3840,6 +3859,7 @@ private constructor( GPT_5_6_TERRA -> Value.GPT_5_6_TERRA GPT_5_6_LUNA -> Value.GPT_5_6_LUNA GPT_5_5 -> Value.GPT_5_5 + GPT_5_5_2026_04_23 -> Value.GPT_5_5_2026_04_23 GPT_5_4 -> Value.GPT_5_4 GPT_5_4_MINI -> Value.GPT_5_4_MINI GPT_5_4_NANO -> Value.GPT_5_4_NANO @@ -3930,6 +3950,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Value.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Value.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 @@ -3955,6 +3977,7 @@ private constructor( GPT_5_6_TERRA -> Known.GPT_5_6_TERRA GPT_5_6_LUNA -> Known.GPT_5_6_LUNA GPT_5_5 -> Known.GPT_5_5 + GPT_5_5_2026_04_23 -> Known.GPT_5_5_2026_04_23 GPT_5_4 -> Known.GPT_5_4 GPT_5_4_MINI -> Known.GPT_5_4_MINI GPT_5_4_NANO -> Known.GPT_5_4_NANO @@ -4045,6 +4068,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Known.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Known.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 @@ -7291,6 +7316,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -7324,6 +7352,8 @@ private constructor( @JvmField val FAST = of("fast") + @JvmField val ULTRAFAST = of("ultrafast") + @JvmStatic fun of(value: String) = ServiceTier(JsonField.of(value)) } @@ -7335,6 +7365,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, } /** @@ -7353,6 +7384,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, /** * An enum member indicating that [ServiceTier] was instantiated with an unknown * value. @@ -7375,6 +7407,7 @@ private constructor( SCALE -> Value.SCALE PRIORITY -> Value.PRIORITY FAST -> Value.FAST + ULTRAFAST -> Value.ULTRAFAST else -> Value._UNKNOWN } @@ -7395,6 +7428,7 @@ private constructor( SCALE -> Known.SCALE PRIORITY -> Known.PRIORITY FAST -> Known.FAST + ULTRAFAST -> Known.ULTRAFAST else -> throw OpenAIInvalidDataException("Unknown ServiceTier: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesServerEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesServerEvent.kt index 23ab3b07a..58b75595c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesServerEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaResponsesServerEvent.kt @@ -2,6 +2,10 @@ package com.openai.models.beta.responses +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -11,11 +15,15 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openai.core.BaseDeserializer import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue +import com.openai.core.checkRequired import com.openai.core.getOrThrow +import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -53,7 +61,7 @@ private constructor( private val responseContentPartAdded: BetaResponseContentPartAddedEvent? = null, private val responseContentPartDone: BetaResponseContentPartDoneEvent? = null, private val responseCreated: BetaResponseCreatedEvent? = null, - private val error: BetaResponseErrorEvent? = null, + private val error: BetaResponseWsError? = null, private val responseFileSearchCallCompleted: BetaResponseFileSearchCallCompletedEvent? = null, private val responseFileSearchCallInProgress: BetaResponseFileSearchCallInProgressEvent? = null, private val responseFileSearchCallSearching: BetaResponseFileSearchCallSearchingEvent? = null, @@ -165,7 +173,7 @@ private constructor( fun responseCreated(): Optional = Optional.ofNullable(responseCreated) /** Emitted when an error occurs. */ - fun error(): Optional = Optional.ofNullable(error) + fun error(): Optional = Optional.ofNullable(error) /** Emitted when a file search call is completed (results found). */ fun responseFileSearchCallCompleted(): Optional = @@ -627,7 +635,7 @@ private constructor( responseCreated.getOrThrow("responseCreated") /** Emitted when an error occurs. */ - fun asError(): BetaResponseErrorEvent = error.getOrThrow("error") + fun asError(): BetaResponseWsError = error.getOrThrow("error") /** Emitted when a file search call is completed (results found). */ fun asResponseFileSearchCallCompleted(): BetaResponseFileSearchCallCompletedEvent = @@ -1049,7 +1057,7 @@ private constructor( responseCreated.validate() } - override fun visitError(error: BetaResponseErrorEvent) { + override fun visitError(error: BetaResponseWsError) { error.validate() } @@ -1372,7 +1380,7 @@ private constructor( override fun visitResponseCreated(responseCreated: BetaResponseCreatedEvent) = responseCreated.validity() - override fun visitError(error: BetaResponseErrorEvent) = error.validity() + override fun visitError(error: BetaResponseWsError) = error.validity() override fun visitResponseFileSearchCallCompleted( responseFileSearchCallCompleted: BetaResponseFileSearchCallCompletedEvent @@ -1869,8 +1877,7 @@ private constructor( BetaResponsesServerEvent(responseCreated = responseCreated) /** Emitted when an error occurs. */ - @JvmStatic - fun ofError(error: BetaResponseErrorEvent) = BetaResponsesServerEvent(error = error) + @JvmStatic fun ofError(error: BetaResponseWsError) = BetaResponsesServerEvent(error = error) /** Emitted when a file search call is completed (results found). */ @JvmStatic @@ -2245,7 +2252,7 @@ private constructor( fun visitResponseCreated(responseCreated: BetaResponseCreatedEvent): T /** Emitted when an error occurs. */ - fun visitError(error: BetaResponseErrorEvent): T + fun visitError(error: BetaResponseWsError): T /** Emitted when a file search call is completed (results found). */ fun visitResponseFileSearchCallCompleted( @@ -2579,7 +2586,7 @@ private constructor( } ?: BetaResponsesServerEvent(_json = json) } "error" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { BetaResponsesServerEvent(error = it, _json = json) } ?: BetaResponsesServerEvent(_json = json) } @@ -3089,4 +3096,1002 @@ private constructor( } } } + + /** Emitted when an error occurs while processing a Responses WebSocket request. */ + class BetaResponseWsError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val error: JsonField, + private val type: JsonValue, + private val agent: JsonField, + private val sequenceNumber: JsonField, + private val status: JsonField, + private val streamId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("agent") @ExcludeMissing agent: JsonField = JsonMissing.of(), + @JsonProperty("sequence_number") + @ExcludeMissing + sequenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("stream_id") + @ExcludeMissing + streamId: JsonField = JsonMissing.of(), + ) : this(error, type, agent, sequenceNumber, status, streamId, mutableMapOf()) + + /** + * Details about the error. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun error(): Error = error.getRequired("error") + + /** + * The type of the event. Always `error`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The agent that owns this multi-agent streaming event. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun agent(): Optional = agent.getOptional("agent") + + /** + * The sequence number of an error emitted by the response stream. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sequenceNumber(): Optional = sequenceNumber.getOptional("sequence_number") + + /** + * The HTTP status code associated with a WebSocket protocol error. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * The WebSocket lane that emitted this event. This field is present when the originating + * `response.create` event supplied a `stream_id`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamId(): Optional = streamId.getOptional("stream_id") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [agent]. + * + * Unlike [agent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agent") @ExcludeMissing fun _agent(): JsonField = agent + + /** + * Returns the raw JSON value of [sequenceNumber]. + * + * Unlike [sequenceNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sequence_number") + @ExcludeMissing + fun _sequenceNumber(): JsonField = sequenceNumber + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [streamId]. + * + * Unlike [streamId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stream_id") @ExcludeMissing fun _streamId(): JsonField = streamId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BetaResponseWsError]. + * + * The following fields are required: + * ```java + * .error() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaResponseWsError]. */ + class Builder internal constructor() { + + private var error: JsonField? = null + private var type: JsonValue = JsonValue.from("error") + private var agent: JsonField = JsonMissing.of() + private var sequenceNumber: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var streamId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaResponseWsError: BetaResponseWsError) = apply { + error = betaResponseWsError.error + type = betaResponseWsError.type + agent = betaResponseWsError.agent + sequenceNumber = betaResponseWsError.sequenceNumber + status = betaResponseWsError.status + streamId = betaResponseWsError.streamId + additionalProperties = betaResponseWsError.additionalProperties.toMutableMap() + } + + /** Details about the error. */ + fun error(error: Error) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Error] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** The agent that owns this multi-agent streaming event. */ + fun agent(agent: Agent?) = agent(JsonField.ofNullable(agent)) + + /** Alias for calling [Builder.agent] with `agent.orElse(null)`. */ + fun agent(agent: Optional) = agent(agent.getOrNull()) + + /** + * Sets [Builder.agent] to an arbitrary JSON value. + * + * You should usually call [Builder.agent] with a well-typed [Agent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun agent(agent: JsonField) = apply { this.agent = agent } + + /** The sequence number of an error emitted by the response stream. */ + fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) + + /** + * Sets [Builder.sequenceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.sequenceNumber] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sequenceNumber(sequenceNumber: JsonField) = apply { + this.sequenceNumber = sequenceNumber + } + + /** The HTTP status code associated with a WebSocket protocol error. */ + fun status(status: Long) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** + * The WebSocket lane that emitted this event. This field is present when the + * originating `response.create` event supplied a `stream_id`. + */ + fun streamId(streamId: String) = streamId(JsonField.of(streamId)) + + /** + * Sets [Builder.streamId] to an arbitrary JSON value. + * + * You should usually call [Builder.streamId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun streamId(streamId: JsonField) = apply { this.streamId = streamId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaResponseWsError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .error() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaResponseWsError = + BetaResponseWsError( + checkRequired("error", error), + type, + agent, + sequenceNumber, + status, + streamId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BetaResponseWsError = apply { + if (validated) { + return@apply + } + + error().validate() + _type().let { + if (it != JsonValue.from("error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + agent().ifPresent { it.validate() } + sequenceNumber() + status() + streamId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (error.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("error")) 1 else 0 } + + (agent.asKnown().getOrNull()?.validity() ?: 0) + + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (streamId.asKnown().isPresent) 1 else 0) + + /** Details about the error. */ + class Error + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val message: JsonField, + private val param: JsonField, + private val type: JsonField, + private val headers: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + @JsonProperty("param") @ExcludeMissing param: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + ) : this(code, message, param, type, headers, mutableMapOf()) + + /** + * The error code that was emitted, if any. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * The human-readable error message that was emitted. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun message(): String = message.getRequired("message") + + /** + * The parameter name that was associated with the error, if any. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun param(): Optional = param.getOptional("param") + + /** + * The error type that was emitted. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): String = type.getRequired("type") + + /** + * The response headers that were emitted with the error, if any. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [param]. + * + * Unlike [param], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("param") @ExcludeMissing fun _param(): JsonField = param + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Error]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .param() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Error]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var param: JsonField? = null + private var type: JsonField? = null + private var headers: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(error: Error) = apply { + code = error.code + message = error.message + param = error.param + type = error.type + headers = error.headers + additionalProperties = error.additionalProperties.toMutableMap() + } + + /** The error code that was emitted, if any. */ + fun code(code: String?) = code(JsonField.ofNullable(code)) + + /** Alias for calling [Builder.code] with `code.orElse(null)`. */ + fun code(code: Optional) = code(code.getOrNull()) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + /** The human-readable error message that was emitted. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** The parameter name that was associated with the error, if any. */ + fun param(param: String?) = param(JsonField.ofNullable(param)) + + /** Alias for calling [Builder.param] with `param.orElse(null)`. */ + fun param(param: Optional) = param(param.getOrNull()) + + /** + * Sets [Builder.param] to an arbitrary JSON value. + * + * You should usually call [Builder.param] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun param(param: JsonField) = apply { this.param = param } + + /** The error type that was emitted. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The response headers that were emitted with the error, if any. */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Error]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .param() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Error = + Error( + checkRequired("code", code), + checkRequired("message", message), + checkRequired("param", param), + checkRequired("type", type), + headers, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Error = apply { + if (validated) { + return@apply + } + + code() + message() + param() + type() + headers().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (param.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + /** The response headers that were emitted with the error, if any. */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Error && + code == other.code && + message == other.message && + param == other.param && + type == other.type && + headers == other.headers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, message, param, type, headers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Error{code=$code, message=$message, param=$param, type=$type, headers=$headers, additionalProperties=$additionalProperties}" + } + + /** The agent that owns this multi-agent streaming event. */ + class Agent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agentName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agent_name") + @ExcludeMissing + agentName: JsonField = JsonMissing.of() + ) : this(agentName, mutableMapOf()) + + /** + * The canonical name of the agent that produced this item. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun agentName(): String = agentName.getRequired("agent_name") + + /** + * Returns the raw JSON value of [agentName]. + * + * Unlike [agentName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("agent_name") + @ExcludeMissing + fun _agentName(): JsonField = agentName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Agent]. + * + * The following fields are required: + * ```java + * .agentName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Agent]. */ + class Builder internal constructor() { + + private var agentName: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(agent: Agent) = apply { + agentName = agent.agentName + additionalProperties = agent.additionalProperties.toMutableMap() + } + + /** The canonical name of the agent that produced this item. */ + fun agentName(agentName: String) = agentName(JsonField.of(agentName)) + + /** + * Sets [Builder.agentName] to an arbitrary JSON value. + * + * You should usually call [Builder.agentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun agentName(agentName: JsonField) = apply { this.agentName = agentName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Agent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agentName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Agent = + Agent( + checkRequired("agentName", agentName), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Agent = apply { + if (validated) { + return@apply + } + + agentName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (agentName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Agent && + agentName == other.agentName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(agentName, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Agent{agentName=$agentName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaResponseWsError && + error == other.error && + type == other.type && + agent == other.agent && + sequenceNumber == other.sequenceNumber && + status == other.status && + streamId == other.streamId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(error, type, agent, sequenceNumber, status, streamId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaResponseWsError{error=$error, type=$type, agent=$agent, sequenceNumber=$sequenceNumber, status=$status, streamId=$streamId, additionalProperties=$additionalProperties}" + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaWebSearchTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaWebSearchTool.kt index 85f8e2fc0..68b2fc3f2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaWebSearchTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/BetaWebSearchTool.kt @@ -28,6 +28,7 @@ class BetaWebSearchTool @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, + private val externalWebAccess: JsonField, private val filters: JsonField, private val searchContextSize: JsonField, private val userLocation: JsonField, @@ -37,6 +38,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("external_web_access") + @ExcludeMissing + externalWebAccess: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), @JsonProperty("search_context_size") @ExcludeMissing @@ -44,7 +48,7 @@ private constructor( @JsonProperty("user_location") @ExcludeMissing userLocation: JsonField = JsonMissing.of(), - ) : this(type, filters, searchContextSize, userLocation, mutableMapOf()) + ) : this(type, externalWebAccess, filters, searchContextSize, userLocation, mutableMapOf()) /** * The type of the web search tool. One of `web_search` or `web_search_2025_08_26`. @@ -54,6 +58,16 @@ private constructor( */ fun type(): Type = type.getRequired("type") + /** + * Allow live internet access for web search. Defaults to true when omitted. When false, the web + * search tool runs in offline/cache-only mode and will not fetch new external content. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalWebAccess(): Optional = + externalWebAccess.getOptional("external_web_access") + /** * Filters for the search. * @@ -87,6 +101,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [externalWebAccess]. + * + * Unlike [externalWebAccess], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_web_access") + @ExcludeMissing + fun _externalWebAccess(): JsonField = externalWebAccess + /** * Returns the raw JSON value of [filters]. * @@ -142,6 +166,7 @@ private constructor( class Builder internal constructor() { private var type: JsonField? = null + private var externalWebAccess: JsonField = JsonMissing.of() private var filters: JsonField = JsonMissing.of() private var searchContextSize: JsonField = JsonMissing.of() private var userLocation: JsonField = JsonMissing.of() @@ -150,6 +175,7 @@ private constructor( @JvmSynthetic internal fun from(betaWebSearchTool: BetaWebSearchTool) = apply { type = betaWebSearchTool.type + externalWebAccess = betaWebSearchTool.externalWebAccess filters = betaWebSearchTool.filters searchContextSize = betaWebSearchTool.searchContextSize userLocation = betaWebSearchTool.userLocation @@ -167,6 +193,24 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** + * Allow live internet access for web search. Defaults to true when omitted. When false, the + * web search tool runs in offline/cache-only mode and will not fetch new external content. + */ + fun externalWebAccess(externalWebAccess: Boolean) = + externalWebAccess(JsonField.of(externalWebAccess)) + + /** + * Sets [Builder.externalWebAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.externalWebAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalWebAccess(externalWebAccess: JsonField) = apply { + this.externalWebAccess = externalWebAccess + } + /** Filters for the search. */ fun filters(filters: Filters?) = filters(JsonField.ofNullable(filters)) @@ -252,6 +296,7 @@ private constructor( fun build(): BetaWebSearchTool = BetaWebSearchTool( checkRequired("type", type), + externalWebAccess, filters, searchContextSize, userLocation, @@ -275,6 +320,7 @@ private constructor( } type().validate() + externalWebAccess() filters().ifPresent { it.validate() } searchContextSize().ifPresent { it.validate() } userLocation().ifPresent { it.validate() } @@ -297,6 +343,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalWebAccess.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.validity() ?: 0) + (searchContextSize.asKnown().getOrNull()?.validity() ?: 0) + (userLocation.asKnown().getOrNull()?.validity() ?: 0) @@ -1232,6 +1279,7 @@ private constructor( return other is BetaWebSearchTool && type == other.type && + externalWebAccess == other.externalWebAccess && filters == other.filters && searchContextSize == other.searchContextSize && userLocation == other.userLocation && @@ -1239,11 +1287,18 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(type, filters, searchContextSize, userLocation, additionalProperties) + Objects.hash( + type, + externalWebAccess, + filters, + searchContextSize, + userLocation, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "BetaWebSearchTool{type=$type, filters=$filters, searchContextSize=$searchContextSize, userLocation=$userLocation, additionalProperties=$additionalProperties}" + "BetaWebSearchTool{type=$type, externalWebAccess=$externalWebAccess, filters=$filters, searchContextSize=$searchContextSize, userLocation=$userLocation, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCompactParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCompactParams.kt index e6915c4ac..3ad08e786 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCompactParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCompactParams.kt @@ -1276,6 +1276,8 @@ private constructor( @JvmField val GPT_5_5 = of("gpt-5.5") + @JvmField val GPT_5_5_2026_04_23 = of("gpt-5.5-2026-04-23") + @JvmField val GPT_5_4 = of("gpt-5.4") @JvmField val GPT_5_4_MINI = of("gpt-5.4-mini") @@ -1454,6 +1456,10 @@ private constructor( @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + @JvmField val GPT_5_5_PRO = of("gpt-5.5-pro") + + @JvmField val GPT_5_5_PRO_2026_04_23 = of("gpt-5.5-pro-2026-04-23") + @JvmField val GPT_5_CODEX = of("gpt-5-codex") @JvmField val GPT_5_PRO = of("gpt-5-pro") @@ -1477,6 +1483,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -1565,6 +1572,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -1588,6 +1597,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -1676,6 +1686,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -1700,6 +1712,7 @@ private constructor( GPT_5_6_TERRA -> Value.GPT_5_6_TERRA GPT_5_6_LUNA -> Value.GPT_5_6_LUNA GPT_5_5 -> Value.GPT_5_5 + GPT_5_5_2026_04_23 -> Value.GPT_5_5_2026_04_23 GPT_5_4 -> Value.GPT_5_4 GPT_5_4_MINI -> Value.GPT_5_4_MINI GPT_5_4_NANO -> Value.GPT_5_4_NANO @@ -1788,6 +1801,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Value.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Value.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 @@ -1813,6 +1828,7 @@ private constructor( GPT_5_6_TERRA -> Known.GPT_5_6_TERRA GPT_5_6_LUNA -> Known.GPT_5_6_LUNA GPT_5_5 -> Known.GPT_5_5 + GPT_5_5_2026_04_23 -> Known.GPT_5_5_2026_04_23 GPT_5_4 -> Known.GPT_5_4 GPT_5_4_MINI -> Known.GPT_5_4_MINI GPT_5_4_NANO -> Known.GPT_5_4_NANO @@ -1901,6 +1917,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Known.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Known.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCreateParams.kt index 9bf5ef5a7..85bc97b62 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/responses/ResponseCreateParams.kt @@ -299,6 +299,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -1240,6 +1243,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -2229,6 +2235,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -3286,6 +3295,10 @@ private constructor( * the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the + * access-controlled Ultrafast Processing service tier. This tier is currently + * available for `gpt-5.6-sol`; a response served through it will show + * `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -4822,6 +4835,8 @@ private constructor( @JvmField val GPT_5_5 = of("gpt-5.5") + @JvmField val GPT_5_5_2026_04_23 = of("gpt-5.5-2026-04-23") + @JvmField val GPT_5_4 = of("gpt-5.4") @JvmField val GPT_5_4_MINI = of("gpt-5.4-mini") @@ -5000,6 +5015,10 @@ private constructor( @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + @JvmField val GPT_5_5_PRO = of("gpt-5.5-pro") + + @JvmField val GPT_5_5_PRO_2026_04_23 = of("gpt-5.5-pro-2026-04-23") + @JvmField val GPT_5_CODEX = of("gpt-5-codex") @JvmField val GPT_5_PRO = of("gpt-5-pro") @@ -5023,6 +5042,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -5111,6 +5131,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -5134,6 +5156,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -5222,6 +5245,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -5246,6 +5271,7 @@ private constructor( GPT_5_6_TERRA -> Value.GPT_5_6_TERRA GPT_5_6_LUNA -> Value.GPT_5_6_LUNA GPT_5_5 -> Value.GPT_5_5 + GPT_5_5_2026_04_23 -> Value.GPT_5_5_2026_04_23 GPT_5_4 -> Value.GPT_5_4 GPT_5_4_MINI -> Value.GPT_5_4_MINI GPT_5_4_NANO -> Value.GPT_5_4_NANO @@ -5334,6 +5360,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Value.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Value.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 @@ -5359,6 +5387,7 @@ private constructor( GPT_5_6_TERRA -> Known.GPT_5_6_TERRA GPT_5_6_LUNA -> Known.GPT_5_6_LUNA GPT_5_5 -> Known.GPT_5_5 + GPT_5_5_2026_04_23 -> Known.GPT_5_5_2026_04_23 GPT_5_4 -> Known.GPT_5_4 GPT_5_4_MINI -> Known.GPT_5_4_MINI GPT_5_4_NANO -> Known.GPT_5_4_NANO @@ -5447,6 +5476,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Known.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Known.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 @@ -8614,6 +8645,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -8647,6 +8681,8 @@ private constructor( @JvmField val FAST = of("fast") + @JvmField val ULTRAFAST = of("ultrafast") + @JvmStatic fun of(value: String) = ServiceTier(JsonField.of(value)) } @@ -8658,6 +8694,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, } /** @@ -8676,6 +8713,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, /** * An enum member indicating that [ServiceTier] was instantiated with an unknown value. */ @@ -8697,6 +8735,7 @@ private constructor( SCALE -> Value.SCALE PRIORITY -> Value.PRIORITY FAST -> Value.FAST + ULTRAFAST -> Value.ULTRAFAST else -> Value._UNKNOWN } @@ -8717,6 +8756,7 @@ private constructor( SCALE -> Known.SCALE PRIORITY -> Known.PRIORITY FAST -> Known.FAST + ULTRAFAST -> Known.ULTRAFAST else -> throw OpenAIInvalidDataException("Unknown ServiceTier: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt index 65366caa1..652dfc2a6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt @@ -356,6 +356,7 @@ private constructor( private val audioTokens: JsonField, private val reasoningTokens: JsonField, private val rejectedPredictionTokens: JsonField, + private val textTokens: JsonField, private val additionalProperties: MutableMap, ) { @@ -373,11 +374,15 @@ private constructor( @JsonProperty("rejected_prediction_tokens") @ExcludeMissing rejectedPredictionTokens: JsonField = JsonMissing.of(), + @JsonProperty("text_tokens") + @ExcludeMissing + textTokens: JsonField = JsonMissing.of(), ) : this( acceptedPredictionTokens, audioTokens, reasoningTokens, rejectedPredictionTokens, + textTokens, mutableMapOf(), ) @@ -418,6 +423,14 @@ private constructor( fun rejectedPredictionTokens(): Optional = rejectedPredictionTokens.getOptional("rejected_prediction_tokens") + /** + * Text output tokens generated by the model. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun textTokens(): Optional = textTokens.getOptional("text_tokens") + /** * Returns the raw JSON value of [acceptedPredictionTokens]. * @@ -457,6 +470,13 @@ private constructor( @ExcludeMissing fun _rejectedPredictionTokens(): JsonField = rejectedPredictionTokens + /** + * Returns the raw JSON value of [textTokens]. + * + * Unlike [textTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text_tokens") @ExcludeMissing fun _textTokens(): JsonField = textTokens + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -484,6 +504,7 @@ private constructor( private var audioTokens: JsonField = JsonMissing.of() private var reasoningTokens: JsonField = JsonMissing.of() private var rejectedPredictionTokens: JsonField = JsonMissing.of() + private var textTokens: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -492,6 +513,7 @@ private constructor( audioTokens = completionTokensDetails.audioTokens reasoningTokens = completionTokensDetails.reasoningTokens rejectedPredictionTokens = completionTokensDetails.rejectedPredictionTokens + textTokens = completionTokensDetails.textTokens additionalProperties = completionTokensDetails.additionalProperties.toMutableMap() } @@ -560,6 +582,18 @@ private constructor( this.rejectedPredictionTokens = rejectedPredictionTokens } + /** Text output tokens generated by the model. */ + fun textTokens(textTokens: Long) = textTokens(JsonField.of(textTokens)) + + /** + * Sets [Builder.textTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.textTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun textTokens(textTokens: JsonField) = apply { this.textTokens = textTokens } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -590,6 +624,7 @@ private constructor( audioTokens, reasoningTokens, rejectedPredictionTokens, + textTokens, additionalProperties.toMutableMap(), ) } @@ -614,6 +649,7 @@ private constructor( audioTokens() reasoningTokens() rejectedPredictionTokens() + textTokens() validated = true } @@ -636,7 +672,8 @@ private constructor( (if (acceptedPredictionTokens.asKnown().isPresent) 1 else 0) + (if (audioTokens.asKnown().isPresent) 1 else 0) + (if (reasoningTokens.asKnown().isPresent) 1 else 0) + - (if (rejectedPredictionTokens.asKnown().isPresent) 1 else 0) + (if (rejectedPredictionTokens.asKnown().isPresent) 1 else 0) + + (if (textTokens.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -648,6 +685,7 @@ private constructor( audioTokens == other.audioTokens && reasoningTokens == other.reasoningTokens && rejectedPredictionTokens == other.rejectedPredictionTokens && + textTokens == other.textTokens && additionalProperties == other.additionalProperties } @@ -657,6 +695,7 @@ private constructor( audioTokens, reasoningTokens, rejectedPredictionTokens, + textTokens, additionalProperties, ) } @@ -664,7 +703,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CompletionTokensDetails{acceptedPredictionTokens=$acceptedPredictionTokens, audioTokens=$audioTokens, reasoningTokens=$reasoningTokens, rejectedPredictionTokens=$rejectedPredictionTokens, additionalProperties=$additionalProperties}" + "CompletionTokensDetails{acceptedPredictionTokens=$acceptedPredictionTokens, audioTokens=$audioTokens, reasoningTokens=$reasoningTokens, rejectedPredictionTokens=$rejectedPredictionTokens, textTokens=$textTokens, additionalProperties=$additionalProperties}" } /** Breakdown of tokens used in the prompt. */ @@ -674,6 +713,8 @@ private constructor( private val audioTokens: JsonField, private val cacheWriteTokens: JsonField, private val cachedTokens: JsonField, + private val imageTokens: JsonField, + private val textTokens: JsonField, private val additionalProperties: MutableMap, ) { @@ -688,7 +729,20 @@ private constructor( @JsonProperty("cached_tokens") @ExcludeMissing cachedTokens: JsonField = JsonMissing.of(), - ) : this(audioTokens, cacheWriteTokens, cachedTokens, mutableMapOf()) + @JsonProperty("image_tokens") + @ExcludeMissing + imageTokens: JsonField = JsonMissing.of(), + @JsonProperty("text_tokens") + @ExcludeMissing + textTokens: JsonField = JsonMissing.of(), + ) : this( + audioTokens, + cacheWriteTokens, + cachedTokens, + imageTokens, + textTokens, + mutableMapOf(), + ) /** * Audio input tokens present in the prompt. @@ -714,6 +768,22 @@ private constructor( */ fun cachedTokens(): Optional = cachedTokens.getOptional("cached_tokens") + /** + * Image input tokens present in the prompt. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun imageTokens(): Optional = imageTokens.getOptional("image_tokens") + + /** + * Text input tokens present in the prompt. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun textTokens(): Optional = textTokens.getOptional("text_tokens") + /** * Returns the raw JSON value of [audioTokens]. * @@ -743,6 +813,22 @@ private constructor( @ExcludeMissing fun _cachedTokens(): JsonField = cachedTokens + /** + * Returns the raw JSON value of [imageTokens]. + * + * Unlike [imageTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("image_tokens") + @ExcludeMissing + fun _imageTokens(): JsonField = imageTokens + + /** + * Returns the raw JSON value of [textTokens]. + * + * Unlike [textTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text_tokens") @ExcludeMissing fun _textTokens(): JsonField = textTokens + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -767,6 +853,8 @@ private constructor( private var audioTokens: JsonField = JsonMissing.of() private var cacheWriteTokens: JsonField = JsonMissing.of() private var cachedTokens: JsonField = JsonMissing.of() + private var imageTokens: JsonField = JsonMissing.of() + private var textTokens: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -774,6 +862,8 @@ private constructor( audioTokens = promptTokensDetails.audioTokens cacheWriteTokens = promptTokensDetails.cacheWriteTokens cachedTokens = promptTokensDetails.cachedTokens + imageTokens = promptTokensDetails.imageTokens + textTokens = promptTokensDetails.textTokens additionalProperties = promptTokensDetails.additionalProperties.toMutableMap() } @@ -818,6 +908,30 @@ private constructor( this.cachedTokens = cachedTokens } + /** Image input tokens present in the prompt. */ + fun imageTokens(imageTokens: Long) = imageTokens(JsonField.of(imageTokens)) + + /** + * Sets [Builder.imageTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.imageTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageTokens(imageTokens: JsonField) = apply { this.imageTokens = imageTokens } + + /** Text input tokens present in the prompt. */ + fun textTokens(textTokens: Long) = textTokens(JsonField.of(textTokens)) + + /** + * Sets [Builder.textTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.textTokens] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun textTokens(textTokens: JsonField) = apply { this.textTokens = textTokens } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -847,6 +961,8 @@ private constructor( audioTokens, cacheWriteTokens, cachedTokens, + imageTokens, + textTokens, additionalProperties.toMutableMap(), ) } @@ -870,6 +986,8 @@ private constructor( audioTokens() cacheWriteTokens() cachedTokens() + imageTokens() + textTokens() validated = true } @@ -891,7 +1009,9 @@ private constructor( internal fun validity(): Int = (if (audioTokens.asKnown().isPresent) 1 else 0) + (if (cacheWriteTokens.asKnown().isPresent) 1 else 0) + - (if (cachedTokens.asKnown().isPresent) 1 else 0) + (if (cachedTokens.asKnown().isPresent) 1 else 0) + + (if (imageTokens.asKnown().isPresent) 1 else 0) + + (if (textTokens.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -902,17 +1022,26 @@ private constructor( audioTokens == other.audioTokens && cacheWriteTokens == other.cacheWriteTokens && cachedTokens == other.cachedTokens && + imageTokens == other.imageTokens && + textTokens == other.textTokens && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(audioTokens, cacheWriteTokens, cachedTokens, additionalProperties) + Objects.hash( + audioTokens, + cacheWriteTokens, + cachedTokens, + imageTokens, + textTokens, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PromptTokensDetails{audioTokens=$audioTokens, cacheWriteTokens=$cacheWriteTokens, cachedTokens=$cachedTokens, additionalProperties=$additionalProperties}" + "PromptTokensDetails{audioTokens=$audioTokens, cacheWriteTokens=$cacheWriteTokens, cachedTokens=$cachedTokens, imageTokens=$imageTokens, textTokens=$textTokens, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt index e148e04ba..feaa3d39e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt @@ -33,6 +33,7 @@ import com.openai.models.responses.CustomTool import com.openai.models.responses.FileSearchTool import com.openai.models.responses.FunctionShellTool import com.openai.models.responses.FunctionTool +import com.openai.models.responses.McpToolCallError import com.openai.models.responses.NamespaceTool import com.openai.models.responses.ResponseApplyPatchToolCall import com.openai.models.responses.ResponseApplyPatchToolCallOutput @@ -5833,7 +5834,7 @@ private constructor( private val serverLabel: JsonField, private val type: JsonValue, private val approvalRequestId: JsonField, - private val error: JsonField, + private val error: JsonField, private val output: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -5853,7 +5854,9 @@ private constructor( @JsonProperty("approval_request_id") @ExcludeMissing approvalRequestId: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), ) : this( @@ -5931,7 +5934,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = error.getOptional("error") + fun error(): Optional = error.getOptional("error") /** * The output from the tool call. @@ -5995,7 +5998,7 @@ private constructor( * * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error /** * Returns the raw JSON value of [output]. @@ -6048,7 +6051,7 @@ private constructor( private var serverLabel: JsonField? = null private var type: JsonValue = JsonValue.from("mcp_call") private var approvalRequestId: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() private var output: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6157,19 +6160,41 @@ private constructor( } /** The error from the tool call, if any. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) + fun error(error: McpToolCallError?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) + fun error(error: Optional) = error(error.getOrNull()) /** * Sets [Builder.error] to an arbitrary JSON value. * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.error] with a well-typed [McpToolCallError] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun error(error: JsonField) = apply { this.error = error } + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `McpToolCallError.ofProtocol(protocol)`. */ + fun error(protocol: McpToolCallError.McpProtocolError) = + error(McpToolCallError.ofProtocol(protocol)) + + /** Alias for calling [error] with `McpToolCallError.ofToolExecution(toolExecution)`. */ + fun error(toolExecution: McpToolCallError.McpToolExecutionError) = + error(McpToolCallError.ofToolExecution(toolExecution)) + + /** + * Alias for calling [error] with the following: + * ```java + * McpToolCallError.McpToolExecutionError.builder() + * .content(content) + * .build() + * ``` + */ + fun toolExecutionError(content: JsonValue) = + error(McpToolCallError.McpToolExecutionError.builder().content(content).build()) + + /** Alias for calling [error] with `McpToolCallError.ofHttp(http)`. */ + fun error(http: McpToolCallError.HttpError) = error(McpToolCallError.ofHttp(http)) /** The output from the tool call. */ fun output(output: String?) = output(JsonField.ofNullable(output)) @@ -6276,7 +6301,7 @@ private constructor( } } approvalRequestId() - error() + error().ifPresent { it.validate() } output() status().ifPresent { it.validate() } validated = true @@ -6304,7 +6329,7 @@ private constructor( (if (serverLabel.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } + (if (approvalRequestId.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileContentParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileContentParams.kt index 1b2c52a25..818f7c272 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileContentParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileContentParams.kt @@ -9,7 +9,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Returns the contents of the specified file. */ +/** Returns a response containing the contents of the specified file. */ class FileContentParams private constructor( private val fileId: String?, diff --git a/openai-java-core/src/main/kotlin/com/openai/models/models/Model.kt b/openai-java-core/src/main/kotlin/com/openai/models/models/Model.kt index c9f9a27ee..f60a4b85b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/models/Model.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/models/Model.kt @@ -12,8 +12,11 @@ import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired import com.openai.errors.OpenAIInvalidDataException +import java.time.LocalDate import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Describes an OpenAI model offering that can be used with the API. */ class Model @@ -23,6 +26,7 @@ private constructor( private val created: JsonField, private val object_: JsonValue, private val ownedBy: JsonField, + private val shutdownDate: JsonField, private val additionalProperties: MutableMap, ) { @@ -32,7 +36,10 @@ private constructor( @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(), @JsonProperty("owned_by") @ExcludeMissing ownedBy: JsonField = JsonMissing.of(), - ) : this(id, created, object_, ownedBy, mutableMapOf()) + @JsonProperty("shutdown_date") + @ExcludeMissing + shutdownDate: JsonField = JsonMissing.of(), + ) : this(id, created, object_, ownedBy, shutdownDate, mutableMapOf()) /** * The model identifier, which can be referenced in the API endpoints. @@ -71,6 +78,14 @@ private constructor( */ fun ownedBy(): String = ownedBy.getRequired("owned_by") + /** + * The date when the model will shut down, or null if not announced. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun shutdownDate(): Optional = shutdownDate.getOptional("shutdown_date") + /** * Returns the raw JSON value of [id]. * @@ -92,6 +107,15 @@ private constructor( */ @JsonProperty("owned_by") @ExcludeMissing fun _ownedBy(): JsonField = ownedBy + /** + * Returns the raw JSON value of [shutdownDate]. + * + * Unlike [shutdownDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shutdown_date") + @ExcludeMissing + fun _shutdownDate(): JsonField = shutdownDate + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -126,6 +150,7 @@ private constructor( private var created: JsonField? = null private var object_: JsonValue = JsonValue.from("model") private var ownedBy: JsonField? = null + private var shutdownDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -134,6 +159,7 @@ private constructor( created = model.created object_ = model.object_ ownedBy = model.ownedBy + shutdownDate = model.shutdownDate additionalProperties = model.additionalProperties.toMutableMap() } @@ -184,6 +210,24 @@ private constructor( */ fun ownedBy(ownedBy: JsonField) = apply { this.ownedBy = ownedBy } + /** The date when the model will shut down, or null if not announced. */ + fun shutdownDate(shutdownDate: LocalDate?) = + shutdownDate(JsonField.ofNullable(shutdownDate)) + + /** Alias for calling [Builder.shutdownDate] with `shutdownDate.orElse(null)`. */ + fun shutdownDate(shutdownDate: Optional) = shutdownDate(shutdownDate.getOrNull()) + + /** + * Sets [Builder.shutdownDate] to an arbitrary JSON value. + * + * You should usually call [Builder.shutdownDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shutdownDate(shutdownDate: JsonField) = apply { + this.shutdownDate = shutdownDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -223,6 +267,7 @@ private constructor( checkRequired("created", created), object_, checkRequired("ownedBy", ownedBy), + shutdownDate, additionalProperties.toMutableMap(), ) } @@ -250,6 +295,7 @@ private constructor( } } ownedBy() + shutdownDate() validated = true } @@ -271,7 +317,8 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (created.asKnown().isPresent) 1 else 0) + object_.let { if (it == JsonValue.from("model")) 1 else 0 } + - (if (ownedBy.asKnown().isPresent) 1 else 0) + (if (ownedBy.asKnown().isPresent) 1 else 0) + + (if (shutdownDate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -283,15 +330,16 @@ private constructor( created == other.created && object_ == other.object_ && ownedBy == other.ownedBy && + shutdownDate == other.shutdownDate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, created, object_, ownedBy, additionalProperties) + Objects.hash(id, created, object_, ownedBy, shutdownDate, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Model{id=$id, created=$created, object_=$object_, ownedBy=$ownedBy, additionalProperties=$additionalProperties}" + "Model{id=$id, created=$created, object_=$object_, ownedBy=$ownedBy, shutdownDate=$shutdownDate, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/McpToolCallError.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/McpToolCallError.kt new file mode 100644 index 000000000..43f6fe220 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/McpToolCallError.kt @@ -0,0 +1,931 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.responses + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.core.getOrThrow +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = McpToolCallError.Deserializer::class) +@JsonSerialize(using = McpToolCallError.Serializer::class) +class McpToolCallError +private constructor( + private val protocol: McpProtocolError? = null, + private val toolExecution: McpToolExecutionError? = null, + private val http: HttpError? = null, + private val _json: JsonValue? = null, +) { + + fun protocol(): Optional = Optional.ofNullable(protocol) + + fun toolExecution(): Optional = Optional.ofNullable(toolExecution) + + fun http(): Optional = Optional.ofNullable(http) + + fun isProtocol(): Boolean = protocol != null + + fun isToolExecution(): Boolean = toolExecution != null + + fun isHttp(): Boolean = http != null + + fun asProtocol(): McpProtocolError = protocol.getOrThrow("protocol") + + fun asToolExecution(): McpToolExecutionError = toolExecution.getOrThrow("toolExecution") + + fun asHttp(): HttpError = http.getOrThrow("http") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = mcpToolCallError.accept(new McpToolCallError.Visitor>() { + * @Override + * public Optional visitProtocol(McpProtocolError protocol) { + * return Optional.of(protocol.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + protocol != null -> visitor.visitProtocol(protocol) + toolExecution != null -> visitor.visitToolExecution(toolExecution) + http != null -> visitor.visitHttp(http) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): McpToolCallError = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitProtocol(protocol: McpProtocolError) { + protocol.validate() + } + + override fun visitToolExecution(toolExecution: McpToolExecutionError) { + toolExecution.validate() + } + + override fun visitHttp(http: HttpError) { + http.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitProtocol(protocol: McpProtocolError) = protocol.validity() + + override fun visitToolExecution(toolExecution: McpToolExecutionError) = + toolExecution.validity() + + override fun visitHttp(http: HttpError) = http.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolCallError && + protocol == other.protocol && + toolExecution == other.toolExecution && + http == other.http + } + + override fun hashCode(): Int = Objects.hash(protocol, toolExecution, http) + + override fun toString(): String = + when { + protocol != null -> "McpToolCallError{protocol=$protocol}" + toolExecution != null -> "McpToolCallError{toolExecution=$toolExecution}" + http != null -> "McpToolCallError{http=$http}" + _json != null -> "McpToolCallError{_unknown=$_json}" + else -> throw IllegalStateException("Invalid McpToolCallError") + } + + companion object { + + @JvmStatic + fun ofProtocol(protocol: McpProtocolError) = McpToolCallError(protocol = protocol) + + @JvmStatic + fun ofToolExecution(toolExecution: McpToolExecutionError) = + McpToolCallError(toolExecution = toolExecution) + + @JvmStatic fun ofHttp(http: HttpError) = McpToolCallError(http = http) + } + + /** + * An interface that defines how to map each variant of [McpToolCallError] to a value of type + * [T]. + */ + interface Visitor { + + fun visitProtocol(protocol: McpProtocolError): T + + fun visitToolExecution(toolExecution: McpToolExecutionError): T + + fun visitHttp(http: HttpError): T + + /** + * Maps an unknown variant of [McpToolCallError] to a value of type [T]. + * + * An instance of [McpToolCallError] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown McpToolCallError: $json") + } + } + + internal class Deserializer : BaseDeserializer(McpToolCallError::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): McpToolCallError { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "mcp_protocol_error" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + McpToolCallError(protocol = it, _json = json) + } ?: McpToolCallError(_json = json) + } + "mcp_tool_execution_error" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + McpToolCallError(toolExecution = it, _json = json) + } ?: McpToolCallError(_json = json) + } + "http_error" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + McpToolCallError(http = it, _json = json) + } ?: McpToolCallError(_json = json) + } + } + + return McpToolCallError(_json = json) + } + } + + internal class Serializer : BaseSerializer(McpToolCallError::class) { + + override fun serialize( + value: McpToolCallError, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.protocol != null -> generator.writeObject(value.protocol) + value.toolExecution != null -> generator.writeObject(value.toolExecution) + value.http != null -> generator.writeObject(value.http) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid McpToolCallError") + } + } + } + + class McpProtocolError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val message: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(code, message, type, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mcp_protocol_error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpProtocolError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpProtocolError]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var type: JsonValue = JsonValue.from("mcp_protocol_error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpProtocolError: McpProtocolError) = apply { + code = mcpProtocolError.code + message = mcpProtocolError.message + type = mcpProtocolError.type + additionalProperties = mcpProtocolError.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mcp_protocol_error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpProtocolError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): McpProtocolError = + McpProtocolError( + checkRequired("code", code), + checkRequired("message", message), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): McpProtocolError = apply { + if (validated) { + return@apply + } + + code() + message() + _type().let { + if (it != JsonValue.from("mcp_protocol_error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("mcp_protocol_error")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpProtocolError && + code == other.code && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, message, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpProtocolError{code=$code, message=$message, type=$type, additionalProperties=$additionalProperties}" + } + + class McpToolExecutionError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") @ExcludeMissing content: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(content, type, mutableMapOf()) + + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = mcpToolExecutionError.content().convert(MyClass.class); + * ``` + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonValue = content + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mcp_tool_execution_error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [McpToolExecutionError]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [McpToolExecutionError]. */ + class Builder internal constructor() { + + private var content: JsonValue? = null + private var type: JsonValue = JsonValue.from("mcp_tool_execution_error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mcpToolExecutionError: McpToolExecutionError) = apply { + content = mcpToolExecutionError.content + type = mcpToolExecutionError.type + additionalProperties = mcpToolExecutionError.additionalProperties.toMutableMap() + } + + fun content(content: JsonValue) = apply { this.content = content } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mcp_tool_execution_error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [McpToolExecutionError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): McpToolExecutionError = + McpToolExecutionError( + checkRequired("content", content), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): McpToolExecutionError = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("mcp_tool_execution_error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + type.let { if (it == JsonValue.from("mcp_tool_execution_error")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is McpToolExecutionError && + content == other.content && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(content, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "McpToolExecutionError{content=$content, type=$type, additionalProperties=$additionalProperties}" + } + + class HttpError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val message: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(code, message, type, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Long = code.getRequired("code") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("http_error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [HttpError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HttpError]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var type: JsonValue = JsonValue.from("http_error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(httpError: HttpError) = apply { + code = httpError.code + message = httpError.message + type = httpError.type + additionalProperties = httpError.additionalProperties.toMutableMap() + } + + fun code(code: Long) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("http_error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [HttpError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HttpError = + HttpError( + checkRequired("code", code), + checkRequired("message", message), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): HttpError = apply { + if (validated) { + return@apply + } + + code() + message() + _type().let { + if (it != JsonValue.from("http_error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("http_error")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HttpError && + code == other.code && + message == other.message && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, message, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HttpError{code=$code, message=$message, type=$type, additionalProperties=$additionalProperties}" + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt index 6a1df2340..1bd2a80c2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/Response.kt @@ -506,6 +506,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -1914,6 +1917,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -7011,6 +7017,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -7044,6 +7053,8 @@ private constructor( @JvmField val FAST = of("fast") + @JvmField val ULTRAFAST = of("ultrafast") + @JvmStatic fun of(value: String) = ServiceTier(JsonField.of(value)) } @@ -7055,6 +7066,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, } /** @@ -7073,6 +7085,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, /** * An enum member indicating that [ServiceTier] was instantiated with an unknown value. */ @@ -7094,6 +7107,7 @@ private constructor( SCALE -> Value.SCALE PRIORITY -> Value.PRIORITY FAST -> Value.FAST + ULTRAFAST -> Value.ULTRAFAST else -> Value._UNKNOWN } @@ -7114,6 +7128,7 @@ private constructor( SCALE -> Known.SCALE PRIORITY -> Known.PRIORITY FAST -> Known.FAST + ULTRAFAST -> Known.ULTRAFAST else -> throw OpenAIInvalidDataException("Unknown ServiceTier: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt index d26b12685..62c8ba274 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCompactParams.kt @@ -1246,6 +1246,8 @@ private constructor( @JvmField val GPT_5_5 = of("gpt-5.5") + @JvmField val GPT_5_5_2026_04_23 = of("gpt-5.5-2026-04-23") + @JvmField val GPT_5_4 = of("gpt-5.4") @JvmField val GPT_5_4_MINI = of("gpt-5.4-mini") @@ -1424,6 +1426,10 @@ private constructor( @JvmField val COMPUTER_USE_PREVIEW_2025_03_11 = of("computer-use-preview-2025-03-11") + @JvmField val GPT_5_5_PRO = of("gpt-5.5-pro") + + @JvmField val GPT_5_5_PRO_2026_04_23 = of("gpt-5.5-pro-2026-04-23") + @JvmField val GPT_5_CODEX = of("gpt-5-codex") @JvmField val GPT_5_PRO = of("gpt-5-pro") @@ -1447,6 +1453,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -1535,6 +1542,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -1558,6 +1567,7 @@ private constructor( GPT_5_6_TERRA, GPT_5_6_LUNA, GPT_5_5, + GPT_5_5_2026_04_23, GPT_5_4, GPT_5_4_MINI, GPT_5_4_NANO, @@ -1646,6 +1656,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26, COMPUTER_USE_PREVIEW, COMPUTER_USE_PREVIEW_2025_03_11, + GPT_5_5_PRO, + GPT_5_5_PRO_2026_04_23, GPT_5_CODEX, GPT_5_PRO, GPT_5_PRO_2025_10_06, @@ -1670,6 +1682,7 @@ private constructor( GPT_5_6_TERRA -> Value.GPT_5_6_TERRA GPT_5_6_LUNA -> Value.GPT_5_6_LUNA GPT_5_5 -> Value.GPT_5_5 + GPT_5_5_2026_04_23 -> Value.GPT_5_5_2026_04_23 GPT_5_4 -> Value.GPT_5_4 GPT_5_4_MINI -> Value.GPT_5_4_MINI GPT_5_4_NANO -> Value.GPT_5_4_NANO @@ -1758,6 +1771,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Value.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Value.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Value.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Value.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Value.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Value.GPT_5_CODEX GPT_5_PRO -> Value.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Value.GPT_5_PRO_2025_10_06 @@ -1783,6 +1798,7 @@ private constructor( GPT_5_6_TERRA -> Known.GPT_5_6_TERRA GPT_5_6_LUNA -> Known.GPT_5_6_LUNA GPT_5_5 -> Known.GPT_5_5 + GPT_5_5_2026_04_23 -> Known.GPT_5_5_2026_04_23 GPT_5_4 -> Known.GPT_5_4 GPT_5_4_MINI -> Known.GPT_5_4_MINI GPT_5_4_NANO -> Known.GPT_5_4_NANO @@ -1871,6 +1887,8 @@ private constructor( O4_MINI_DEEP_RESEARCH_2025_06_26 -> Known.O4_MINI_DEEP_RESEARCH_2025_06_26 COMPUTER_USE_PREVIEW -> Known.COMPUTER_USE_PREVIEW COMPUTER_USE_PREVIEW_2025_03_11 -> Known.COMPUTER_USE_PREVIEW_2025_03_11 + GPT_5_5_PRO -> Known.GPT_5_5_PRO + GPT_5_5_PRO_2026_04_23 -> Known.GPT_5_5_PRO_2026_04_23 GPT_5_CODEX -> Known.GPT_5_CODEX GPT_5_PRO -> Known.GPT_5_PRO GPT_5_PRO_2025_10_06 -> Known.GPT_5_PRO_2025_10_06 diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt index d00082618..261ade367 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt @@ -293,6 +293,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -1198,6 +1201,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -2180,6 +2186,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -3203,6 +3212,10 @@ private constructor( * the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the + * access-controlled Ultrafast Processing service tier. This tier is currently + * available for `gpt-5.6-sol`; a response served through it will show + * `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -6369,6 +6382,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -6402,6 +6418,8 @@ private constructor( @JvmField val FAST = of("fast") + @JvmField val ULTRAFAST = of("ultrafast") + @JvmStatic fun of(value: String) = ServiceTier(JsonField.of(value)) } @@ -6413,6 +6431,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, } /** @@ -6431,6 +6450,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, /** * An enum member indicating that [ServiceTier] was instantiated with an unknown value. */ @@ -6452,6 +6472,7 @@ private constructor( SCALE -> Value.SCALE PRIORITY -> Value.PRIORITY FAST -> Value.FAST + ULTRAFAST -> Value.ULTRAFAST else -> Value._UNKNOWN } @@ -6472,6 +6493,7 @@ private constructor( SCALE -> Known.SCALE PRIORITY -> Known.PRIORITY FAST -> Known.FAST + ULTRAFAST -> Known.ULTRAFAST else -> throw OpenAIInvalidDataException("Unknown ServiceTier: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt index 6320ad1f2..ea17d922d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseInputItem.kt @@ -14178,7 +14178,7 @@ private constructor( private val serverLabel: JsonField, private val type: JsonValue, private val approvalRequestId: JsonField, - private val error: JsonField, + private val error: JsonField, private val output: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -14198,7 +14198,9 @@ private constructor( @JsonProperty("approval_request_id") @ExcludeMissing approvalRequestId: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), ) : this( @@ -14276,7 +14278,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = error.getOptional("error") + fun error(): Optional = error.getOptional("error") /** * The output from the tool call. @@ -14340,7 +14342,7 @@ private constructor( * * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error /** * Returns the raw JSON value of [output]. @@ -14393,7 +14395,7 @@ private constructor( private var serverLabel: JsonField? = null private var type: JsonValue = JsonValue.from("mcp_call") private var approvalRequestId: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() private var output: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -14502,19 +14504,41 @@ private constructor( } /** The error from the tool call, if any. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) + fun error(error: McpToolCallError?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) + fun error(error: Optional) = error(error.getOrNull()) /** * Sets [Builder.error] to an arbitrary JSON value. * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.error] with a well-typed [McpToolCallError] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun error(error: JsonField) = apply { this.error = error } + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `McpToolCallError.ofProtocol(protocol)`. */ + fun error(protocol: McpToolCallError.McpProtocolError) = + error(McpToolCallError.ofProtocol(protocol)) + + /** Alias for calling [error] with `McpToolCallError.ofToolExecution(toolExecution)`. */ + fun error(toolExecution: McpToolCallError.McpToolExecutionError) = + error(McpToolCallError.ofToolExecution(toolExecution)) + + /** + * Alias for calling [error] with the following: + * ```java + * McpToolCallError.McpToolExecutionError.builder() + * .content(content) + * .build() + * ``` + */ + fun toolExecutionError(content: JsonValue) = + error(McpToolCallError.McpToolExecutionError.builder().content(content).build()) + + /** Alias for calling [error] with `McpToolCallError.ofHttp(http)`. */ + fun error(http: McpToolCallError.HttpError) = error(McpToolCallError.ofHttp(http)) /** The output from the tool call. */ fun output(output: String?) = output(JsonField.ofNullable(output)) @@ -14621,7 +14645,7 @@ private constructor( } } approvalRequestId() - error() + error().ifPresent { it.validate() } output() status().ifPresent { it.validate() } validated = true @@ -14649,7 +14673,7 @@ private constructor( (if (serverLabel.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } + (if (approvalRequestId.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt index fe3c03be9..21eae5bf2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseItem.kt @@ -5857,7 +5857,7 @@ private constructor( private val serverLabel: JsonField, private val type: JsonValue, private val approvalRequestId: JsonField, - private val error: JsonField, + private val error: JsonField, private val output: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -5877,7 +5877,9 @@ private constructor( @JsonProperty("approval_request_id") @ExcludeMissing approvalRequestId: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), ) : this( @@ -5955,7 +5957,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = error.getOptional("error") + fun error(): Optional = error.getOptional("error") /** * The output from the tool call. @@ -6019,7 +6021,7 @@ private constructor( * * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error /** * Returns the raw JSON value of [output]. @@ -6072,7 +6074,7 @@ private constructor( private var serverLabel: JsonField? = null private var type: JsonValue = JsonValue.from("mcp_call") private var approvalRequestId: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() private var output: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6181,19 +6183,41 @@ private constructor( } /** The error from the tool call, if any. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) + fun error(error: McpToolCallError?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) + fun error(error: Optional) = error(error.getOrNull()) /** * Sets [Builder.error] to an arbitrary JSON value. * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.error] with a well-typed [McpToolCallError] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun error(error: JsonField) = apply { this.error = error } + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `McpToolCallError.ofProtocol(protocol)`. */ + fun error(protocol: McpToolCallError.McpProtocolError) = + error(McpToolCallError.ofProtocol(protocol)) + + /** Alias for calling [error] with `McpToolCallError.ofToolExecution(toolExecution)`. */ + fun error(toolExecution: McpToolCallError.McpToolExecutionError) = + error(McpToolCallError.ofToolExecution(toolExecution)) + + /** + * Alias for calling [error] with the following: + * ```java + * McpToolCallError.McpToolExecutionError.builder() + * .content(content) + * .build() + * ``` + */ + fun toolExecutionError(content: JsonValue) = + error(McpToolCallError.McpToolExecutionError.builder().content(content).build()) + + /** Alias for calling [error] with `McpToolCallError.ofHttp(http)`. */ + fun error(http: McpToolCallError.HttpError) = error(McpToolCallError.ofHttp(http)) /** The output from the tool call. */ fun output(output: String?) = output(JsonField.ofNullable(output)) @@ -6300,7 +6324,7 @@ private constructor( } } approvalRequestId() - error() + error().ifPresent { it.validate() } output() status().ifPresent { it.validate() } validated = true @@ -6328,7 +6352,7 @@ private constructor( (if (serverLabel.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } + (if (approvalRequestId.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt index 947f041cf..97008bb5f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItem.kt @@ -4524,7 +4524,7 @@ private constructor( private val serverLabel: JsonField, private val type: JsonValue, private val approvalRequestId: JsonField, - private val error: JsonField, + private val error: JsonField, private val output: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -4544,7 +4544,9 @@ private constructor( @JsonProperty("approval_request_id") @ExcludeMissing approvalRequestId: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("error") + @ExcludeMissing + error: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), ) : this( @@ -4622,7 +4624,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun error(): Optional = error.getOptional("error") + fun error(): Optional = error.getOptional("error") /** * The output from the tool call. @@ -4686,7 +4688,7 @@ private constructor( * * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error /** * Returns the raw JSON value of [output]. @@ -4739,7 +4741,7 @@ private constructor( private var serverLabel: JsonField? = null private var type: JsonValue = JsonValue.from("mcp_call") private var approvalRequestId: JsonField = JsonMissing.of() - private var error: JsonField = JsonMissing.of() + private var error: JsonField = JsonMissing.of() private var output: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4848,19 +4850,41 @@ private constructor( } /** The error from the tool call, if any. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) + fun error(error: McpToolCallError?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) + fun error(error: Optional) = error(error.getOrNull()) /** * Sets [Builder.error] to an arbitrary JSON value. * - * You should usually call [Builder.error] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.error] with a well-typed [McpToolCallError] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun error(error: JsonField) = apply { this.error = error } + fun error(error: JsonField) = apply { this.error = error } + + /** Alias for calling [error] with `McpToolCallError.ofProtocol(protocol)`. */ + fun error(protocol: McpToolCallError.McpProtocolError) = + error(McpToolCallError.ofProtocol(protocol)) + + /** Alias for calling [error] with `McpToolCallError.ofToolExecution(toolExecution)`. */ + fun error(toolExecution: McpToolCallError.McpToolExecutionError) = + error(McpToolCallError.ofToolExecution(toolExecution)) + + /** + * Alias for calling [error] with the following: + * ```java + * McpToolCallError.McpToolExecutionError.builder() + * .content(content) + * .build() + * ``` + */ + fun toolExecutionError(content: JsonValue) = + error(McpToolCallError.McpToolExecutionError.builder().content(content).build()) + + /** Alias for calling [error] with `McpToolCallError.ofHttp(http)`. */ + fun error(http: McpToolCallError.HttpError) = error(McpToolCallError.ofHttp(http)) /** The output from the tool call. */ fun output(output: String?) = output(JsonField.ofNullable(output)) @@ -4967,7 +4991,7 @@ private constructor( } } approvalRequestId() - error() + error().ifPresent { it.validate() } output() status().ifPresent { it.validate() } validated = true @@ -4995,7 +5019,7 @@ private constructor( (if (serverLabel.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("mcp_call")) 1 else 0 } + (if (approvalRequestId.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + (if (output.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt index 138ccbcdd..14271b158 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputItemAddedEvent.kt @@ -42,7 +42,9 @@ private constructor( ) : this(item, outputIndex, sequenceNumber, type, mutableMapOf()) /** - * The output item that was added. + * The output item that was added. For reasoning items, `encrypted_content` may be incomplete + * while the item is in progress. Use the reasoning item from the corresponding + * `response.output_item.done` event when passing it as input to a subsequent request. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -146,7 +148,11 @@ private constructor( additionalProperties = responseOutputItemAddedEvent.additionalProperties.toMutableMap() } - /** The output item that was added. */ + /** + * The output item that was added. For reasoning items, `encrypted_content` may be + * incomplete while the item is in progress. Use the reasoning item from the corresponding + * `response.output_item.done` event when passing it as input to a subsequent request. + */ fun item(item: ResponseOutputItem) = item(JsonField.of(item)) /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEvent.kt index a869e2dd3..fa8d161b6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEvent.kt @@ -6,20 +6,32 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired +import com.openai.core.getOrThrow import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Emitted when an annotation is added to output text content. */ class ResponseOutputTextAnnotationAddedEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val annotation: JsonValue, + private val annotation: JsonField, private val annotationIndex: JsonField, private val contentIndex: JsonField, private val itemId: JsonField, @@ -31,7 +43,9 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("annotation") @ExcludeMissing annotation: JsonValue = JsonMissing.of(), + @JsonProperty("annotation") + @ExcludeMissing + annotation: JsonField = JsonMissing.of(), @JsonProperty("annotation_index") @ExcludeMissing annotationIndex: JsonField = JsonMissing.of(), @@ -58,14 +72,12 @@ private constructor( ) /** - * The annotation object being added. (See annotation schema for details.) + * An annotation that applies to a span of output text. * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = responseOutputTextAnnotationAddedEvent.annotation().convert(MyClass.class); - * ``` + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("annotation") @ExcludeMissing fun _annotation(): JsonValue = annotation + fun annotation(): Optional = annotation.getOptional("annotation") /** * The index of the annotation within the content part. @@ -120,6 +132,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns the raw JSON value of [annotation]. + * + * Unlike [annotation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("annotation") + @ExcludeMissing + fun _annotation(): JsonField = annotation + /** * Returns the raw JSON value of [annotationIndex]. * @@ -195,7 +216,7 @@ private constructor( /** A builder for [ResponseOutputTextAnnotationAddedEvent]. */ class Builder internal constructor() { - private var annotation: JsonValue? = null + private var annotation: JsonField? = null private var annotationIndex: JsonField? = null private var contentIndex: JsonField? = null private var itemId: JsonField? = null @@ -219,8 +240,38 @@ private constructor( responseOutputTextAnnotationAddedEvent.additionalProperties.toMutableMap() } - /** The annotation object being added. (See annotation schema for details.) */ - fun annotation(annotation: JsonValue) = apply { this.annotation = annotation } + /** An annotation that applies to a span of output text. */ + fun annotation(annotation: Annotation?) = annotation(JsonField.ofNullable(annotation)) + + /** Alias for calling [Builder.annotation] with `annotation.orElse(null)`. */ + fun annotation(annotation: Optional) = annotation(annotation.getOrNull()) + + /** + * Sets [Builder.annotation] to an arbitrary JSON value. + * + * You should usually call [Builder.annotation] with a well-typed [Annotation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun annotation(annotation: JsonField) = apply { this.annotation = annotation } + + /** Alias for calling [annotation] with `Annotation.ofFileCitation(fileCitation)`. */ + fun annotation(fileCitation: Annotation.FileCitation) = + annotation(Annotation.ofFileCitation(fileCitation)) + + /** Alias for calling [annotation] with `Annotation.ofUrlCitation(urlCitation)`. */ + fun annotation(urlCitation: Annotation.UrlCitation) = + annotation(Annotation.ofUrlCitation(urlCitation)) + + /** + * Alias for calling [annotation] with + * `Annotation.ofContainerFileCitation(containerFileCitation)`. + */ + fun annotation(containerFileCitation: Annotation.ContainerFileCitation) = + annotation(Annotation.ofContainerFileCitation(containerFileCitation)) + + /** Alias for calling [annotation] with `Annotation.ofFilePath(filePath)`. */ + fun annotation(filePath: Annotation.FilePath) = annotation(Annotation.ofFilePath(filePath)) /** The index of the annotation within the content part. */ fun annotationIndex(annotationIndex: Long) = annotationIndex(JsonField.of(annotationIndex)) @@ -363,6 +414,7 @@ private constructor( return@apply } + annotation().ifPresent { it.validate() } annotationIndex() contentIndex() itemId() @@ -391,13 +443,1600 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (annotationIndex.asKnown().isPresent) 1 else 0) + + (annotation.asKnown().getOrNull()?.validity() ?: 0) + + (if (annotationIndex.asKnown().isPresent) 1 else 0) + (if (contentIndex.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (if (outputIndex.asKnown().isPresent) 1 else 0) + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("response.output_text.annotation.added")) 1 else 0 } + /** An annotation that applies to a span of output text. */ + @JsonDeserialize(using = Annotation.Deserializer::class) + @JsonSerialize(using = Annotation.Serializer::class) + class Annotation + private constructor( + private val fileCitation: FileCitation? = null, + private val urlCitation: UrlCitation? = null, + private val containerFileCitation: ContainerFileCitation? = null, + private val filePath: FilePath? = null, + private val _json: JsonValue? = null, + ) { + + /** A citation to a file. */ + fun fileCitation(): Optional = Optional.ofNullable(fileCitation) + + /** A citation for a web resource used to generate a model response. */ + fun urlCitation(): Optional = Optional.ofNullable(urlCitation) + + /** A citation for a container file used to generate a model response. */ + fun containerFileCitation(): Optional = + Optional.ofNullable(containerFileCitation) + + /** A path to a file. */ + fun filePath(): Optional = Optional.ofNullable(filePath) + + fun isFileCitation(): Boolean = fileCitation != null + + fun isUrlCitation(): Boolean = urlCitation != null + + fun isContainerFileCitation(): Boolean = containerFileCitation != null + + fun isFilePath(): Boolean = filePath != null + + /** A citation to a file. */ + fun asFileCitation(): FileCitation = fileCitation.getOrThrow("fileCitation") + + /** A citation for a web resource used to generate a model response. */ + fun asUrlCitation(): UrlCitation = urlCitation.getOrThrow("urlCitation") + + /** A citation for a container file used to generate a model response. */ + fun asContainerFileCitation(): ContainerFileCitation = + containerFileCitation.getOrThrow("containerFileCitation") + + /** A path to a file. */ + fun asFilePath(): FilePath = filePath.getOrThrow("filePath") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = annotation.accept(new Annotation.Visitor>() { + * @Override + * public Optional visitFileCitation(FileCitation fileCitation) { + * return Optional.of(fileCitation.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + fileCitation != null -> visitor.visitFileCitation(fileCitation) + urlCitation != null -> visitor.visitUrlCitation(urlCitation) + containerFileCitation != null -> + visitor.visitContainerFileCitation(containerFileCitation) + filePath != null -> visitor.visitFilePath(filePath) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Annotation = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFileCitation(fileCitation: FileCitation) { + fileCitation.validate() + } + + override fun visitUrlCitation(urlCitation: UrlCitation) { + urlCitation.validate() + } + + override fun visitContainerFileCitation( + containerFileCitation: ContainerFileCitation + ) { + containerFileCitation.validate() + } + + override fun visitFilePath(filePath: FilePath) { + filePath.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitFileCitation(fileCitation: FileCitation) = + fileCitation.validity() + + override fun visitUrlCitation(urlCitation: UrlCitation) = urlCitation.validity() + + override fun visitContainerFileCitation( + containerFileCitation: ContainerFileCitation + ) = containerFileCitation.validity() + + override fun visitFilePath(filePath: FilePath) = filePath.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Annotation && + fileCitation == other.fileCitation && + urlCitation == other.urlCitation && + containerFileCitation == other.containerFileCitation && + filePath == other.filePath + } + + override fun hashCode(): Int = + Objects.hash(fileCitation, urlCitation, containerFileCitation, filePath) + + override fun toString(): String = + when { + fileCitation != null -> "Annotation{fileCitation=$fileCitation}" + urlCitation != null -> "Annotation{urlCitation=$urlCitation}" + containerFileCitation != null -> + "Annotation{containerFileCitation=$containerFileCitation}" + filePath != null -> "Annotation{filePath=$filePath}" + _json != null -> "Annotation{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Annotation") + } + + companion object { + + /** A citation to a file. */ + @JvmStatic + fun ofFileCitation(fileCitation: FileCitation) = Annotation(fileCitation = fileCitation) + + /** A citation for a web resource used to generate a model response. */ + @JvmStatic + fun ofUrlCitation(urlCitation: UrlCitation) = Annotation(urlCitation = urlCitation) + + /** A citation for a container file used to generate a model response. */ + @JvmStatic + fun ofContainerFileCitation(containerFileCitation: ContainerFileCitation) = + Annotation(containerFileCitation = containerFileCitation) + + /** A path to a file. */ + @JvmStatic fun ofFilePath(filePath: FilePath) = Annotation(filePath = filePath) + } + + /** + * An interface that defines how to map each variant of [Annotation] to a value of type [T]. + */ + interface Visitor { + + /** A citation to a file. */ + fun visitFileCitation(fileCitation: FileCitation): T + + /** A citation for a web resource used to generate a model response. */ + fun visitUrlCitation(urlCitation: UrlCitation): T + + /** A citation for a container file used to generate a model response. */ + fun visitContainerFileCitation(containerFileCitation: ContainerFileCitation): T + + /** A path to a file. */ + fun visitFilePath(filePath: FilePath): T + + /** + * Maps an unknown variant of [Annotation] to a value of type [T]. + * + * An instance of [Annotation] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown Annotation: $json") + } + } + + internal class Deserializer : BaseDeserializer(Annotation::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Annotation { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "file_citation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(fileCitation = it, _json = json) + } ?: Annotation(_json = json) + } + "url_citation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(urlCitation = it, _json = json) + } ?: Annotation(_json = json) + } + "container_file_citation" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(containerFileCitation = it, _json = json) + } ?: Annotation(_json = json) + } + "file_path" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Annotation(filePath = it, _json = json) + } ?: Annotation(_json = json) + } + } + + return Annotation(_json = json) + } + } + + internal class Serializer : BaseSerializer(Annotation::class) { + + override fun serialize( + value: Annotation, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.fileCitation != null -> generator.writeObject(value.fileCitation) + value.urlCitation != null -> generator.writeObject(value.urlCitation) + value.containerFileCitation != null -> + generator.writeObject(value.containerFileCitation) + value.filePath != null -> generator.writeObject(value.filePath) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Annotation") + } + } + } + + /** A citation to a file. */ + class FileCitation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val filename: JsonField, + private val index: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(fileId, filename, index, type, mutableMapOf()) + + /** + * The ID of the file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * The filename of the file cited. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun filename(): String = filename.getRequired("filename") + + /** + * The index of the file in the list of files. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun index(): Long = index.getRequired("index") + + /** + * The type of the file citation. Always `file_citation`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("file_citation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FileCitation]. + * + * The following fields are required: + * ```java + * .fileId() + * .filename() + * .index() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileCitation]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var filename: JsonField? = null + private var index: JsonField? = null + private var type: JsonValue = JsonValue.from("file_citation") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileCitation: FileCitation) = apply { + fileId = fileCitation.fileId + filename = fileCitation.filename + index = fileCitation.index + type = fileCitation.type + additionalProperties = fileCitation.additionalProperties.toMutableMap() + } + + /** The ID of the file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** The filename of the file cited. */ + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filename(filename: JsonField) = apply { this.filename = filename } + + /** The index of the file in the list of files. */ + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun index(index: JsonField) = apply { this.index = index } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("file_citation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileCitation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .filename() + * .index() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileCitation = + FileCitation( + checkRequired("fileId", fileId), + checkRequired("filename", filename), + checkRequired("index", index), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FileCitation = apply { + if (validated) { + return@apply + } + + fileId() + filename() + index() + _type().let { + if (it != JsonValue.from("file_citation")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("file_citation")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileCitation && + fileId == other.fileId && + filename == other.filename && + index == other.index && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fileId, filename, index, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileCitation{fileId=$fileId, filename=$filename, index=$index, type=$type, additionalProperties=$additionalProperties}" + } + + /** A citation for a web resource used to generate a model response. */ + class UrlCitation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endIndex: JsonField, + private val startIndex: JsonField, + private val title: JsonField, + private val type: JsonValue, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_index") + @ExcludeMissing + endIndex: JsonField = JsonMissing.of(), + @JsonProperty("start_index") + @ExcludeMissing + startIndex: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(endIndex, startIndex, title, type, url, mutableMapOf()) + + /** + * The index of the last character of the URL citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun endIndex(): Long = endIndex.getRequired("end_index") + + /** + * The index of the first character of the URL citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startIndex(): Long = startIndex.getRequired("start_index") + + /** + * The title of the web resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun title(): String = title.getRequired("title") + + /** + * The type of the URL citation. Always `url_citation`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("url_citation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The URL of the web resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [endIndex]. + * + * Unlike [endIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_index") @ExcludeMissing fun _endIndex(): JsonField = endIndex + + /** + * Returns the raw JSON value of [startIndex]. + * + * Unlike [startIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_index") + @ExcludeMissing + fun _startIndex(): JsonField = startIndex + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UrlCitation]. + * + * The following fields are required: + * ```java + * .endIndex() + * .startIndex() + * .title() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlCitation]. */ + class Builder internal constructor() { + + private var endIndex: JsonField? = null + private var startIndex: JsonField? = null + private var title: JsonField? = null + private var type: JsonValue = JsonValue.from("url_citation") + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(urlCitation: UrlCitation) = apply { + endIndex = urlCitation.endIndex + startIndex = urlCitation.startIndex + title = urlCitation.title + type = urlCitation.type + url = urlCitation.url + additionalProperties = urlCitation.additionalProperties.toMutableMap() + } + + /** The index of the last character of the URL citation in the message. */ + fun endIndex(endIndex: Long) = endIndex(JsonField.of(endIndex)) + + /** + * Sets [Builder.endIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.endIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun endIndex(endIndex: JsonField) = apply { this.endIndex = endIndex } + + /** The index of the first character of the URL citation in the message. */ + fun startIndex(startIndex: Long) = startIndex(JsonField.of(startIndex)) + + /** + * Sets [Builder.startIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.startIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun startIndex(startIndex: JsonField) = apply { this.startIndex = startIndex } + + /** The title of the web resource. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("url_citation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** The URL of the web resource. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlCitation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endIndex() + * .startIndex() + * .title() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UrlCitation = + UrlCitation( + checkRequired("endIndex", endIndex), + checkRequired("startIndex", startIndex), + checkRequired("title", title), + type, + checkRequired("url", url), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UrlCitation = apply { + if (validated) { + return@apply + } + + endIndex() + startIndex() + title() + _type().let { + if (it != JsonValue.from("url_citation")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endIndex.asKnown().isPresent) 1 else 0) + + (if (startIndex.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("url_citation")) 1 else 0 } + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlCitation && + endIndex == other.endIndex && + startIndex == other.startIndex && + title == other.title && + type == other.type && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(endIndex, startIndex, title, type, url, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UrlCitation{endIndex=$endIndex, startIndex=$startIndex, title=$title, type=$type, url=$url, additionalProperties=$additionalProperties}" + } + + /** A citation for a container file used to generate a model response. */ + class ContainerFileCitation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val containerId: JsonField, + private val endIndex: JsonField, + private val fileId: JsonField, + private val filename: JsonField, + private val startIndex: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("container_id") + @ExcludeMissing + containerId: JsonField = JsonMissing.of(), + @JsonProperty("end_index") + @ExcludeMissing + endIndex: JsonField = JsonMissing.of(), + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("start_index") + @ExcludeMissing + startIndex: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(containerId, endIndex, fileId, filename, startIndex, type, mutableMapOf()) + + /** + * The ID of the container file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun containerId(): String = containerId.getRequired("container_id") + + /** + * The index of the last character of the container file citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun endIndex(): Long = endIndex.getRequired("end_index") + + /** + * The ID of the file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * The filename of the container file cited. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun filename(): String = filename.getRequired("filename") + + /** + * The index of the first character of the container file citation in the message. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun startIndex(): Long = startIndex.getRequired("start_index") + + /** + * The type of the container file citation. Always `container_file_citation`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("container_file_citation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [containerId]. + * + * Unlike [containerId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("container_id") + @ExcludeMissing + fun _containerId(): JsonField = containerId + + /** + * Returns the raw JSON value of [endIndex]. + * + * Unlike [endIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("end_index") @ExcludeMissing fun _endIndex(): JsonField = endIndex + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [startIndex]. + * + * Unlike [startIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("start_index") + @ExcludeMissing + fun _startIndex(): JsonField = startIndex + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ContainerFileCitation]. + * + * The following fields are required: + * ```java + * .containerId() + * .endIndex() + * .fileId() + * .filename() + * .startIndex() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContainerFileCitation]. */ + class Builder internal constructor() { + + private var containerId: JsonField? = null + private var endIndex: JsonField? = null + private var fileId: JsonField? = null + private var filename: JsonField? = null + private var startIndex: JsonField? = null + private var type: JsonValue = JsonValue.from("container_file_citation") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(containerFileCitation: ContainerFileCitation) = apply { + containerId = containerFileCitation.containerId + endIndex = containerFileCitation.endIndex + fileId = containerFileCitation.fileId + filename = containerFileCitation.filename + startIndex = containerFileCitation.startIndex + type = containerFileCitation.type + additionalProperties = containerFileCitation.additionalProperties.toMutableMap() + } + + /** The ID of the container file. */ + fun containerId(containerId: String) = containerId(JsonField.of(containerId)) + + /** + * Sets [Builder.containerId] to an arbitrary JSON value. + * + * You should usually call [Builder.containerId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun containerId(containerId: JsonField) = apply { + this.containerId = containerId + } + + /** + * The index of the last character of the container file citation in the message. + */ + fun endIndex(endIndex: Long) = endIndex(JsonField.of(endIndex)) + + /** + * Sets [Builder.endIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.endIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun endIndex(endIndex: JsonField) = apply { this.endIndex = endIndex } + + /** The ID of the file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** The filename of the container file cited. */ + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filename(filename: JsonField) = apply { this.filename = filename } + + /** + * The index of the first character of the container file citation in the message. + */ + fun startIndex(startIndex: Long) = startIndex(JsonField.of(startIndex)) + + /** + * Sets [Builder.startIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.startIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun startIndex(startIndex: JsonField) = apply { this.startIndex = startIndex } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("container_file_citation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContainerFileCitation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .containerId() + * .endIndex() + * .fileId() + * .filename() + * .startIndex() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ContainerFileCitation = + ContainerFileCitation( + checkRequired("containerId", containerId), + checkRequired("endIndex", endIndex), + checkRequired("fileId", fileId), + checkRequired("filename", filename), + checkRequired("startIndex", startIndex), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ContainerFileCitation = apply { + if (validated) { + return@apply + } + + containerId() + endIndex() + fileId() + filename() + startIndex() + _type().let { + if (it != JsonValue.from("container_file_citation")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (containerId.asKnown().isPresent) 1 else 0) + + (if (endIndex.asKnown().isPresent) 1 else 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (startIndex.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("container_file_citation")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContainerFileCitation && + containerId == other.containerId && + endIndex == other.endIndex && + fileId == other.fileId && + filename == other.filename && + startIndex == other.startIndex && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + containerId, + endIndex, + fileId, + filename, + startIndex, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContainerFileCitation{containerId=$containerId, endIndex=$endIndex, fileId=$fileId, filename=$filename, startIndex=$startIndex, type=$type, additionalProperties=$additionalProperties}" + } + + /** A path to a file. */ + class FilePath + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val index: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of(), + @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(fileId, index, type, mutableMapOf()) + + /** + * The ID of the file. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * The index of the file in the list of files. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun index(): Long = index.getRequired("index") + + /** + * The type of the file path. Always `file_path`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("file_path") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FilePath]. + * + * The following fields are required: + * ```java + * .fileId() + * .index() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FilePath]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var index: JsonField? = null + private var type: JsonValue = JsonValue.from("file_path") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filePath: FilePath) = apply { + fileId = filePath.fileId + index = filePath.index + type = filePath.type + additionalProperties = filePath.additionalProperties.toMutableMap() + } + + /** The ID of the file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** The index of the file in the list of files. */ + fun index(index: Long) = index(JsonField.of(index)) + + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun index(index: JsonField) = apply { this.index = index } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("file_path") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FilePath]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .index() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FilePath = + FilePath( + checkRequired("fileId", fileId), + checkRequired("index", index), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FilePath = apply { + if (validated) { + return@apply + } + + fileId() + index() + _type().let { + if (it != JsonValue.from("file_path")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (index.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("file_path")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FilePath && + fileId == other.fileId && + index == other.index && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fileId, index, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FilePath{fileId=$fileId, index=$index, type=$type, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningItem.kt index f7444baae..a8b5a5914 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseReasoningItem.kt @@ -95,6 +95,11 @@ private constructor( * The encrypted content of the reasoning item. This is populated by default for reasoning items * returned by `POST /v1/responses` and WebSocket `response.create` requests. * + * When streaming, use the completed reasoning item and its `encrypted_content` from the + * `response.output_item.done` event in subsequent requests. The `encrypted_content` in + * `response.output_item.added` may be incomplete. This is especially important when `store` is + * `false` or when using Zero Data Retention. + * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -275,6 +280,11 @@ private constructor( /** * The encrypted content of the reasoning item. This is populated by default for reasoning * items returned by `POST /v1/responses` and WebSocket `response.create` requests. + * + * When streaming, use the completed reasoning item and its `encrypted_content` from the + * `response.output_item.done` event in subsequent requests. The `encrypted_content` in + * `response.output_item.added` may be incomplete. This is especially important when `store` + * is `false` or when using Zero Data Retention. */ fun encryptedContent(encryptedContent: String?) = encryptedContent(JsonField.ofNullable(encryptedContent)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt index a8da2fdc5..03dbd4e47 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt @@ -445,6 +445,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -1492,6 +1495,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat * Completions. The response will show `service_tier=priority` regardless of if you * specify `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; + * a response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the @@ -4617,6 +4623,9 @@ private constructor( * `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. * The response will show `service_tier=priority` regardless of if you specify * `service_tier=fast` or `priority` in your request. + * - If set to 'ultrafast', then the request will be processed with the access-controlled + * Ultrafast Processing service tier. This tier is currently available for `gpt-5.6-sol`; a + * response served through it will show `service_tier=ultrafast`. * - When not set, the default behavior is 'auto'. * * When the `service_tier` parameter is set, the response body will include the `service_tier` @@ -4650,6 +4659,8 @@ private constructor( @JvmField val FAST = of("fast") + @JvmField val ULTRAFAST = of("ultrafast") + @JvmStatic fun of(value: String) = ServiceTier(JsonField.of(value)) } @@ -4661,6 +4672,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, } /** @@ -4679,6 +4691,7 @@ private constructor( SCALE, PRIORITY, FAST, + ULTRAFAST, /** * An enum member indicating that [ServiceTier] was instantiated with an unknown value. */ @@ -4700,6 +4713,7 @@ private constructor( SCALE -> Value.SCALE PRIORITY -> Value.PRIORITY FAST -> Value.FAST + ULTRAFAST -> Value.ULTRAFAST else -> Value._UNKNOWN } @@ -4720,6 +4734,7 @@ private constructor( SCALE -> Known.SCALE PRIORITY -> Known.PRIORITY FAST -> Known.FAST + ULTRAFAST -> Known.ULTRAFAST else -> throw OpenAIInvalidDataException("Unknown ServiceTier: $value") } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesServerEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesServerEvent.kt index 742e14598..2dc5bed7c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesServerEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesServerEvent.kt @@ -2,6 +2,10 @@ package com.openai.models.responses +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -11,11 +15,15 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openai.core.BaseDeserializer import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue +import com.openai.core.checkRequired import com.openai.core.getOrThrow +import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -50,7 +58,7 @@ private constructor( private val responseContentPartAdded: ResponseContentPartAddedEvent? = null, private val responseContentPartDone: ResponseContentPartDoneEvent? = null, private val responseCreated: ResponseCreatedEvent? = null, - private val error: ResponseErrorEvent? = null, + private val error: ResponseWsError? = null, private val responseFileSearchCallCompleted: ResponseFileSearchCallCompletedEvent? = null, private val responseFileSearchCallInProgress: ResponseFileSearchCallInProgressEvent? = null, private val responseFileSearchCallSearching: ResponseFileSearchCallSearchingEvent? = null, @@ -150,7 +158,7 @@ private constructor( fun responseCreated(): Optional = Optional.ofNullable(responseCreated) /** Emitted when an error occurs. */ - fun error(): Optional = Optional.ofNullable(error) + fun error(): Optional = Optional.ofNullable(error) /** Emitted when a file search call is completed (results found). */ fun responseFileSearchCallCompleted(): Optional = @@ -589,7 +597,7 @@ private constructor( fun asResponseCreated(): ResponseCreatedEvent = responseCreated.getOrThrow("responseCreated") /** Emitted when an error occurs. */ - fun asError(): ResponseErrorEvent = error.getOrThrow("error") + fun asError(): ResponseWsError = error.getOrThrow("error") /** Emitted when a file search call is completed (results found). */ fun asResponseFileSearchCallCompleted(): ResponseFileSearchCallCompletedEvent = @@ -990,7 +998,7 @@ private constructor( responseCreated.validate() } - override fun visitError(error: ResponseErrorEvent) { + override fun visitError(error: ResponseWsError) { error.validate() } @@ -1292,7 +1300,7 @@ private constructor( override fun visitResponseCreated(responseCreated: ResponseCreatedEvent) = responseCreated.validity() - override fun visitError(error: ResponseErrorEvent) = error.validity() + override fun visitError(error: ResponseWsError) = error.validity() override fun visitResponseFileSearchCallCompleted( responseFileSearchCallCompleted: ResponseFileSearchCallCompletedEvent @@ -1768,7 +1776,7 @@ private constructor( ResponsesServerEvent(responseCreated = responseCreated) /** Emitted when an error occurs. */ - @JvmStatic fun ofError(error: ResponseErrorEvent) = ResponsesServerEvent(error = error) + @JvmStatic fun ofError(error: ResponseWsError) = ResponsesServerEvent(error = error) /** Emitted when a file search call is completed (results found). */ @JvmStatic @@ -2100,7 +2108,7 @@ private constructor( fun visitResponseCreated(responseCreated: ResponseCreatedEvent): T /** Emitted when an error occurs. */ - fun visitError(error: ResponseErrorEvent): T + fun visitError(error: ResponseWsError): T /** Emitted when a file search call is completed (results found). */ fun visitResponseFileSearchCallCompleted( @@ -2409,7 +2417,7 @@ private constructor( } ?: ResponsesServerEvent(_json = json) } "error" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { ResponsesServerEvent(error = it, _json = json) } ?: ResponsesServerEvent(_json = json) } @@ -2854,4 +2862,784 @@ private constructor( } } } + + /** Emitted when an error occurs while processing a Responses WebSocket request. */ + class ResponseWsError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val error: JsonField, + private val type: JsonValue, + private val sequenceNumber: JsonField, + private val status: JsonField, + private val streamId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("sequence_number") + @ExcludeMissing + sequenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("stream_id") + @ExcludeMissing + streamId: JsonField = JsonMissing.of(), + ) : this(error, type, sequenceNumber, status, streamId, mutableMapOf()) + + /** + * Details about the error. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun error(): Error = error.getRequired("error") + + /** + * The type of the event. Always `error`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The sequence number of an error emitted by the response stream. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sequenceNumber(): Optional = sequenceNumber.getOptional("sequence_number") + + /** + * The HTTP status code associated with a WebSocket protocol error. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * The WebSocket lane that emitted this event. This field is present when the originating + * `response.create` event supplied a `stream_id`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamId(): Optional = streamId.getOptional("stream_id") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [sequenceNumber]. + * + * Unlike [sequenceNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sequence_number") + @ExcludeMissing + fun _sequenceNumber(): JsonField = sequenceNumber + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [streamId]. + * + * Unlike [streamId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stream_id") @ExcludeMissing fun _streamId(): JsonField = streamId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ResponseWsError]. + * + * The following fields are required: + * ```java + * .error() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponseWsError]. */ + class Builder internal constructor() { + + private var error: JsonField? = null + private var type: JsonValue = JsonValue.from("error") + private var sequenceNumber: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var streamId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responseWsError: ResponseWsError) = apply { + error = responseWsError.error + type = responseWsError.type + sequenceNumber = responseWsError.sequenceNumber + status = responseWsError.status + streamId = responseWsError.streamId + additionalProperties = responseWsError.additionalProperties.toMutableMap() + } + + /** Details about the error. */ + fun error(error: Error) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Error] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** The sequence number of an error emitted by the response stream. */ + fun sequenceNumber(sequenceNumber: Long) = sequenceNumber(JsonField.of(sequenceNumber)) + + /** + * Sets [Builder.sequenceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.sequenceNumber] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sequenceNumber(sequenceNumber: JsonField) = apply { + this.sequenceNumber = sequenceNumber + } + + /** The HTTP status code associated with a WebSocket protocol error. */ + fun status(status: Long) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** + * The WebSocket lane that emitted this event. This field is present when the + * originating `response.create` event supplied a `stream_id`. + */ + fun streamId(streamId: String) = streamId(JsonField.of(streamId)) + + /** + * Sets [Builder.streamId] to an arbitrary JSON value. + * + * You should usually call [Builder.streamId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun streamId(streamId: JsonField) = apply { this.streamId = streamId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResponseWsError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .error() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResponseWsError = + ResponseWsError( + checkRequired("error", error), + type, + sequenceNumber, + status, + streamId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ResponseWsError = apply { + if (validated) { + return@apply + } + + error().validate() + _type().let { + if (it != JsonValue.from("error")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + sequenceNumber() + status() + streamId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (error.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("error")) 1 else 0 } + + (if (sequenceNumber.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (streamId.asKnown().isPresent) 1 else 0) + + /** Details about the error. */ + class Error + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val code: JsonField, + private val message: JsonField, + private val param: JsonField, + private val type: JsonField, + private val headers: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + @JsonProperty("param") @ExcludeMissing param: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + ) : this(code, message, param, type, headers, mutableMapOf()) + + /** + * The error code that was emitted, if any. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun code(): Optional = code.getOptional("code") + + /** + * The human-readable error message that was emitted. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun message(): String = message.getRequired("message") + + /** + * The parameter name that was associated with the error, if any. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun param(): Optional = param.getOptional("param") + + /** + * The error type that was emitted. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): String = type.getRequired("type") + + /** + * The response headers that were emitted with the error, if any. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [param]. + * + * Unlike [param], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("param") @ExcludeMissing fun _param(): JsonField = param + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Error]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .param() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Error]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var param: JsonField? = null + private var type: JsonField? = null + private var headers: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(error: Error) = apply { + code = error.code + message = error.message + param = error.param + type = error.type + headers = error.headers + additionalProperties = error.additionalProperties.toMutableMap() + } + + /** The error code that was emitted, if any. */ + fun code(code: String?) = code(JsonField.ofNullable(code)) + + /** Alias for calling [Builder.code] with `code.orElse(null)`. */ + fun code(code: Optional) = code(code.getOrNull()) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + /** The human-readable error message that was emitted. */ + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** The parameter name that was associated with the error, if any. */ + fun param(param: String?) = param(JsonField.ofNullable(param)) + + /** Alias for calling [Builder.param] with `param.orElse(null)`. */ + fun param(param: Optional) = param(param.getOrNull()) + + /** + * Sets [Builder.param] to an arbitrary JSON value. + * + * You should usually call [Builder.param] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun param(param: JsonField) = apply { this.param = param } + + /** The error type that was emitted. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The response headers that were emitted with the error, if any. */ + fun headers(headers: Headers) = headers(JsonField.of(headers)) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Error]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .param() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Error = + Error( + checkRequired("code", code), + checkRequired("message", message), + checkRequired("param", param), + checkRequired("type", type), + headers, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Error = apply { + if (validated) { + return@apply + } + + code() + message() + param() + type() + headers().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (param.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + /** The response headers that were emitted with the error, if any. */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Error && + code == other.code && + message == other.message && + param == other.param && + type == other.type && + headers == other.headers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(code, message, param, type, headers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Error{code=$code, message=$message, param=$param, type=$type, headers=$headers, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseWsError && + error == other.error && + type == other.type && + sequenceNumber == other.sequenceNumber && + status == other.status && + streamId == other.streamId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(error, type, sequenceNumber, status, streamId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResponseWsError{error=$error, type=$type, sequenceNumber=$sequenceNumber, status=$status, streamId=$streamId, additionalProperties=$additionalProperties}" + } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/WebSearchTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/WebSearchTool.kt index 0c84af3b6..0edb23723 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/WebSearchTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/WebSearchTool.kt @@ -28,6 +28,7 @@ class WebSearchTool @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, + private val externalWebAccess: JsonField, private val filters: JsonField, private val searchContextSize: JsonField, private val userLocation: JsonField, @@ -37,6 +38,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("external_web_access") + @ExcludeMissing + externalWebAccess: JsonField = JsonMissing.of(), @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), @JsonProperty("search_context_size") @ExcludeMissing @@ -44,7 +48,7 @@ private constructor( @JsonProperty("user_location") @ExcludeMissing userLocation: JsonField = JsonMissing.of(), - ) : this(type, filters, searchContextSize, userLocation, mutableMapOf()) + ) : this(type, externalWebAccess, filters, searchContextSize, userLocation, mutableMapOf()) /** * The type of the web search tool. One of `web_search` or `web_search_2025_08_26`. @@ -54,6 +58,16 @@ private constructor( */ fun type(): Type = type.getRequired("type") + /** + * Allow live internet access for web search. Defaults to true when omitted. When false, the web + * search tool runs in offline/cache-only mode and will not fetch new external content. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalWebAccess(): Optional = + externalWebAccess.getOptional("external_web_access") + /** * Filters for the search. * @@ -87,6 +101,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [externalWebAccess]. + * + * Unlike [externalWebAccess], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_web_access") + @ExcludeMissing + fun _externalWebAccess(): JsonField = externalWebAccess + /** * Returns the raw JSON value of [filters]. * @@ -142,6 +166,7 @@ private constructor( class Builder internal constructor() { private var type: JsonField? = null + private var externalWebAccess: JsonField = JsonMissing.of() private var filters: JsonField = JsonMissing.of() private var searchContextSize: JsonField = JsonMissing.of() private var userLocation: JsonField = JsonMissing.of() @@ -150,6 +175,7 @@ private constructor( @JvmSynthetic internal fun from(webSearchTool: WebSearchTool) = apply { type = webSearchTool.type + externalWebAccess = webSearchTool.externalWebAccess filters = webSearchTool.filters searchContextSize = webSearchTool.searchContextSize userLocation = webSearchTool.userLocation @@ -167,6 +193,24 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** + * Allow live internet access for web search. Defaults to true when omitted. When false, the + * web search tool runs in offline/cache-only mode and will not fetch new external content. + */ + fun externalWebAccess(externalWebAccess: Boolean) = + externalWebAccess(JsonField.of(externalWebAccess)) + + /** + * Sets [Builder.externalWebAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.externalWebAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalWebAccess(externalWebAccess: JsonField) = apply { + this.externalWebAccess = externalWebAccess + } + /** Filters for the search. */ fun filters(filters: Filters?) = filters(JsonField.ofNullable(filters)) @@ -252,6 +296,7 @@ private constructor( fun build(): WebSearchTool = WebSearchTool( checkRequired("type", type), + externalWebAccess, filters, searchContextSize, userLocation, @@ -275,6 +320,7 @@ private constructor( } type().validate() + externalWebAccess() filters().ifPresent { it.validate() } searchContextSize().ifPresent { it.validate() } userLocation().ifPresent { it.validate() } @@ -297,6 +343,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalWebAccess.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.validity() ?: 0) + (searchContextSize.asKnown().getOrNull()?.validity() ?: 0) + (userLocation.asKnown().getOrNull()?.validity() ?: 0) @@ -1232,6 +1279,7 @@ private constructor( return other is WebSearchTool && type == other.type && + externalWebAccess == other.externalWebAccess && filters == other.filters && searchContextSize == other.searchContextSize && userLocation == other.userLocation && @@ -1239,11 +1287,18 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(type, filters, searchContextSize, userLocation, additionalProperties) + Objects.hash( + type, + externalWebAccess, + filters, + searchContextSize, + userLocation, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "WebSearchTool{type=$type, filters=$filters, searchContextSize=$searchContextSize, userLocation=$userLocation, additionalProperties=$additionalProperties}" + "WebSearchTool{type=$type, externalWebAccess=$externalWebAccess, filters=$filters, searchContextSize=$searchContextSize, userLocation=$userLocation, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt index 4ccbb14fc..a64bf65e2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt @@ -149,7 +149,7 @@ interface FileServiceAsync { fun delete(fileId: String, requestOptions: RequestOptions): CompletableFuture = delete(fileId, FileDeleteParams.none(), requestOptions) - /** Returns the contents of the specified file. */ + /** Returns a response containing the contents of the specified file. */ fun content(fileId: String): CompletableFuture = content(fileId, FileContentParams.none()) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt index 3acb40dd5..038982dc1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/FileService.kt @@ -140,7 +140,7 @@ interface FileService { fun delete(fileId: String, requestOptions: RequestOptions): FileDeleted = delete(fileId, FileDeleteParams.none(), requestOptions) - /** Returns the contents of the specified file. */ + /** Returns a response containing the contents of the specified file. */ @MustBeClosed fun content(fileId: String): HttpResponse = content(fileId, FileContentParams.none()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaMcpToolCallErrorTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaMcpToolCallErrorTest.kt new file mode 100644 index 000000000..7e9f1ffbf --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaMcpToolCallErrorTest.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.beta.responses + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.JsonValue +import com.openai.core.jsonMapper +import com.openai.errors.OpenAIInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaMcpToolCallErrorTest { + + @Test + fun ofMcpProtocol() { + val mcpProtocol = + BetaMcpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + + val betaMcpToolCallError = BetaMcpToolCallError.ofMcpProtocol(mcpProtocol) + + assertThat(betaMcpToolCallError.mcpProtocol()).contains(mcpProtocol) + assertThat(betaMcpToolCallError.mcpToolExecution()).isEmpty + assertThat(betaMcpToolCallError.http()).isEmpty + } + + @Test + fun ofMcpProtocolRoundtrip() { + val jsonMapper = jsonMapper() + val betaMcpToolCallError = + BetaMcpToolCallError.ofMcpProtocol( + BetaMcpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + ) + + val roundtrippedBetaMcpToolCallError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaMcpToolCallError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaMcpToolCallError).isEqualTo(betaMcpToolCallError) + } + + @Test + fun ofMcpToolExecution() { + val mcpToolExecution = + BetaMcpToolCallError.McpToolExecutionError.builder() + .content(JsonValue.from(mapOf())) + .build() + + val betaMcpToolCallError = BetaMcpToolCallError.ofMcpToolExecution(mcpToolExecution) + + assertThat(betaMcpToolCallError.mcpProtocol()).isEmpty + assertThat(betaMcpToolCallError.mcpToolExecution()).contains(mcpToolExecution) + assertThat(betaMcpToolCallError.http()).isEmpty + } + + @Test + fun ofMcpToolExecutionRoundtrip() { + val jsonMapper = jsonMapper() + val betaMcpToolCallError = + BetaMcpToolCallError.ofMcpToolExecution( + BetaMcpToolCallError.McpToolExecutionError.builder() + .content(JsonValue.from(mapOf())) + .build() + ) + + val roundtrippedBetaMcpToolCallError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaMcpToolCallError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaMcpToolCallError).isEqualTo(betaMcpToolCallError) + } + + @Test + fun ofHttp() { + val http = BetaMcpToolCallError.HttpError.builder().code(0L).message("message").build() + + val betaMcpToolCallError = BetaMcpToolCallError.ofHttp(http) + + assertThat(betaMcpToolCallError.mcpProtocol()).isEmpty + assertThat(betaMcpToolCallError.mcpToolExecution()).isEmpty + assertThat(betaMcpToolCallError.http()).contains(http) + } + + @Test + fun ofHttpRoundtrip() { + val jsonMapper = jsonMapper() + val betaMcpToolCallError = + BetaMcpToolCallError.ofHttp( + BetaMcpToolCallError.HttpError.builder().code(0L).message("message").build() + ) + + val roundtrippedBetaMcpToolCallError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaMcpToolCallError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaMcpToolCallError).isEqualTo(betaMcpToolCallError) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaMcpToolCallError = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { betaMcpToolCallError.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseInputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseInputItemTest.kt index d403429dd..adb46cf8b 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseInputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseInputItemTest.kt @@ -2656,7 +2656,12 @@ internal class BetaResponseInputItemTest { BetaResponseInputItem.McpCall.Agent.builder().agentName("agent_name").build() ) .approvalRequestId("approval_request_id") - .error("error") + .error( + BetaMcpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(BetaResponseInputItem.McpCall.Status.IN_PROGRESS) .build() @@ -2716,7 +2721,12 @@ internal class BetaResponseInputItemTest { .build() ) .approvalRequestId("approval_request_id") - .error("error") + .error( + BetaMcpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(BetaResponseInputItem.McpCall.Status.IN_PROGRESS) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseItemTest.kt index f9eaeeecd..68359b96e 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseItemTest.kt @@ -2647,7 +2647,12 @@ internal class BetaResponseItemTest { .serverLabel("server_label") .agent(BetaResponseItem.McpCall.Agent.builder().agentName("agent_name").build()) .approvalRequestId("approval_request_id") - .error("error") + .error( + BetaMcpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(BetaResponseItem.McpCall.Status.IN_PROGRESS) .build() @@ -2700,7 +2705,12 @@ internal class BetaResponseItemTest { .serverLabel("server_label") .agent(BetaResponseItem.McpCall.Agent.builder().agentName("agent_name").build()) .approvalRequestId("approval_request_id") - .error("error") + .error( + BetaMcpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(BetaResponseItem.McpCall.Status.IN_PROGRESS) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemTest.kt index e211d1a6a..38a65ad8a 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputItemTest.kt @@ -2308,7 +2308,12 @@ internal class BetaResponseOutputItemTest { BetaResponseOutputItem.McpCall.Agent.builder().agentName("agent_name").build() ) .approvalRequestId("approval_request_id") - .error("error") + .error( + BetaMcpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(BetaResponseOutputItem.McpCall.Status.IN_PROGRESS) .build() @@ -2364,7 +2369,12 @@ internal class BetaResponseOutputItemTest { .build() ) .approvalRequestId("approval_request_id") - .error("error") + .error( + BetaMcpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(BetaResponseOutputItem.McpCall.Status.IN_PROGRESS) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEventTest.kt index a299e788e..269ab1ef4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseOutputTextAnnotationAddedEventTest.kt @@ -3,7 +3,6 @@ package com.openai.models.beta.responses import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openai.core.JsonValue import com.openai.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,7 +13,13 @@ internal class BetaResponseOutputTextAnnotationAddedEventTest { fun create() { val betaResponseOutputTextAnnotationAddedEvent = BetaResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -27,8 +32,16 @@ internal class BetaResponseOutputTextAnnotationAddedEventTest { ) .build() - assertThat(betaResponseOutputTextAnnotationAddedEvent._annotation()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(betaResponseOutputTextAnnotationAddedEvent.annotation()) + .contains( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.ofFileCitation( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) + ) assertThat(betaResponseOutputTextAnnotationAddedEvent.annotationIndex()).isEqualTo(0L) assertThat(betaResponseOutputTextAnnotationAddedEvent.contentIndex()).isEqualTo(0L) assertThat(betaResponseOutputTextAnnotationAddedEvent.itemId()).isEqualTo("item_id") @@ -47,7 +60,13 @@ internal class BetaResponseOutputTextAnnotationAddedEventTest { val jsonMapper = jsonMapper() val betaResponseOutputTextAnnotationAddedEvent = BetaResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseStreamEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseStreamEventTest.kt index 36197cc3e..82572d3bd 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseStreamEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponseStreamEventTest.kt @@ -7328,7 +7328,13 @@ internal class BetaResponseStreamEventTest { fun ofResponseOutputTextAnnotationAdded() { val responseOutputTextAnnotationAdded = BetaResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -7408,7 +7414,13 @@ internal class BetaResponseStreamEventTest { val betaResponseStreamEvent = BetaResponseStreamEvent.ofResponseOutputTextAnnotationAdded( BetaResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponsesServerEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponsesServerEventTest.kt index e89195458..a09a669f1 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponsesServerEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaResponsesServerEventTest.kt @@ -41,7 +41,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -81,6 +80,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -132,7 +132,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -172,6 +171,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -228,7 +228,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -268,6 +267,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -326,7 +326,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -366,6 +365,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -428,7 +428,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -468,6 +467,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -533,7 +533,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -573,6 +572,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -637,7 +637,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -677,6 +676,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -740,7 +740,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -780,6 +779,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -843,7 +843,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -883,6 +882,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -1151,7 +1151,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -1191,6 +1190,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -1496,7 +1496,6 @@ internal class BetaResponsesServerEventTest { .contains(responseContentPartAdded) assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -1536,6 +1535,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -1649,7 +1649,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartDone()) .contains(responseContentPartDone) assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -1689,6 +1688,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -1983,7 +1983,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).contains(responseCreated) - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -2023,6 +2022,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -2268,99 +2268,6 @@ internal class BetaResponsesServerEventTest { assertThat(roundtrippedBetaResponsesServerEvent).isEqualTo(betaResponsesServerEvent) } - @Test - fun ofError() { - val error = - BetaResponseErrorEvent.builder() - .code("code") - .message("message") - .param("param") - .sequenceNumber(0L) - .agent(BetaResponseErrorEvent.Agent.builder().agentName("agent_name").build()) - .build() - - val betaResponsesServerEvent = BetaResponsesServerEvent.ofError(error) - - assertThat(betaResponsesServerEvent.responseAudioDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseAudioDone()).isEmpty - assertThat(betaResponsesServerEvent.responseAudioTranscriptDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseAudioTranscriptDone()).isEmpty - assertThat(betaResponsesServerEvent.responseCodeInterpreterCallCodeDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseCodeInterpreterCallCodeDone()).isEmpty - assertThat(betaResponsesServerEvent.responseCodeInterpreterCallCompleted()).isEmpty - assertThat(betaResponsesServerEvent.responseCodeInterpreterCallInProgress()).isEmpty - assertThat(betaResponsesServerEvent.responseCodeInterpreterCallInterpreting()).isEmpty - assertThat(betaResponsesServerEvent.responseCompleted()).isEmpty - assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty - assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty - assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).contains(error) - assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty - assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty - assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty - assertThat(betaResponsesServerEvent.responseFunctionCallArgumentsDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseFunctionCallArgumentsDone()).isEmpty - assertThat(betaResponsesServerEvent.responseInProgress()).isEmpty - assertThat(betaResponsesServerEvent.responseFailed()).isEmpty - assertThat(betaResponsesServerEvent.responseIncomplete()).isEmpty - assertThat(betaResponsesServerEvent.responseOutputItemAdded()).isEmpty - assertThat(betaResponsesServerEvent.responseOutputItemDone()).isEmpty - assertThat(betaResponsesServerEvent.responseReasoningSummaryPartAdded()).isEmpty - assertThat(betaResponsesServerEvent.responseReasoningSummaryPartDone()).isEmpty - assertThat(betaResponsesServerEvent.responseReasoningSummaryTextDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseReasoningSummaryTextDone()).isEmpty - assertThat(betaResponsesServerEvent.responseReasoningTextDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseReasoningTextDone()).isEmpty - assertThat(betaResponsesServerEvent.responseRefusalDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseRefusalDone()).isEmpty - assertThat(betaResponsesServerEvent.responseOutputTextDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseOutputTextDone()).isEmpty - assertThat(betaResponsesServerEvent.responseWebSearchCallCompleted()).isEmpty - assertThat(betaResponsesServerEvent.responseWebSearchCallInProgress()).isEmpty - assertThat(betaResponsesServerEvent.responseWebSearchCallSearching()).isEmpty - assertThat(betaResponsesServerEvent.responseImageGenerationCallCompleted()).isEmpty - assertThat(betaResponsesServerEvent.responseImageGenerationCallGenerating()).isEmpty - assertThat(betaResponsesServerEvent.responseImageGenerationCallInProgress()).isEmpty - assertThat(betaResponsesServerEvent.responseImageGenerationCallPartialImage()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpCallArgumentsDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpCallArgumentsDone()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpCallCompleted()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpCallFailed()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpCallInProgress()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpListToolsCompleted()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpListToolsFailed()).isEmpty - assertThat(betaResponsesServerEvent.responseMcpListToolsInProgress()).isEmpty - assertThat(betaResponsesServerEvent.responseOutputTextAnnotationAdded()).isEmpty - assertThat(betaResponsesServerEvent.responseQueued()).isEmpty - assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty - assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty - assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty - assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty - } - - @Test - fun ofErrorRoundtrip() { - val jsonMapper = jsonMapper() - val betaResponsesServerEvent = - BetaResponsesServerEvent.ofError( - BetaResponseErrorEvent.builder() - .code("code") - .message("message") - .param("param") - .sequenceNumber(0L) - .agent(BetaResponseErrorEvent.Agent.builder().agentName("agent_name").build()) - .build() - ) - - val roundtrippedBetaResponsesServerEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(betaResponsesServerEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBetaResponsesServerEvent).isEqualTo(betaResponsesServerEvent) - } - @Test fun ofResponseFileSearchCallCompleted() { val responseFileSearchCallCompleted = @@ -2393,7 +2300,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()) .contains(responseFileSearchCallCompleted) assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty @@ -2434,6 +2340,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -2496,7 +2403,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()) .contains(responseFileSearchCallInProgress) @@ -2537,6 +2443,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -2599,7 +2506,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()) @@ -2640,6 +2546,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -2703,7 +2610,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -2744,6 +2650,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -2809,7 +2716,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -2850,6 +2756,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -3120,7 +3027,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -3160,6 +3066,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -3644,7 +3551,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -3684,6 +3590,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -4167,7 +4074,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4207,6 +4113,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -4519,7 +4426,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4560,6 +4466,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -4692,7 +4599,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4733,6 +4639,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -4836,7 +4743,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4877,6 +4783,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -4948,7 +4855,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4989,6 +4895,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5060,7 +4967,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5101,6 +5007,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5167,7 +5074,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5208,6 +5114,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5272,7 +5179,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5313,6 +5219,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5377,7 +5284,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5418,6 +5324,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5480,7 +5387,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5520,6 +5426,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5580,7 +5487,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5620,6 +5526,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5690,7 +5597,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5731,6 +5637,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5813,7 +5720,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5854,6 +5760,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -5928,7 +5835,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5969,6 +5875,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6031,7 +5938,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6072,6 +5978,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6134,7 +6041,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6175,6 +6081,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6237,7 +6144,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6278,6 +6184,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6340,7 +6247,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6381,6 +6287,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6443,7 +6350,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6484,6 +6390,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6548,7 +6455,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6589,6 +6495,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6652,7 +6559,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6693,6 +6599,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6755,7 +6662,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6796,6 +6702,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6857,7 +6764,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6898,6 +6804,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -6956,7 +6863,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6996,6 +6902,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -7056,7 +6963,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7097,6 +7003,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -7157,7 +7064,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7198,6 +7104,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -7258,7 +7165,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7299,6 +7205,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -7361,7 +7268,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7402,6 +7308,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -7436,7 +7343,13 @@ internal class BetaResponsesServerEventTest { fun ofResponseOutputTextAnnotationAdded() { val responseOutputTextAnnotationAdded = BetaResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -7467,7 +7380,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7508,6 +7420,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -7518,7 +7431,13 @@ internal class BetaResponsesServerEventTest { val betaResponsesServerEvent = BetaResponsesServerEvent.ofResponseOutputTextAnnotationAdded( BetaResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + BetaResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -7778,7 +7697,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7818,6 +7736,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).contains(responseQueued) assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -8096,7 +8015,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -8137,6 +8055,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()) .contains(responseCustomToolCallInputDelta) assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -8201,7 +8120,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -8242,6 +8160,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()) .contains(responseCustomToolCallInputDone) + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty } @@ -8273,6 +8192,131 @@ internal class BetaResponsesServerEventTest { assertThat(roundtrippedBetaResponsesServerEvent).isEqualTo(betaResponsesServerEvent) } + @Test + fun ofError() { + val error = + BetaResponsesServerEvent.BetaResponseWsError.builder() + .error( + BetaResponsesServerEvent.BetaResponseWsError.Error.builder() + .code("code") + .message("message") + .param("param") + .type("type") + .headers( + BetaResponsesServerEvent.BetaResponseWsError.Error.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .agent( + BetaResponsesServerEvent.BetaResponseWsError.Agent.builder() + .agentName("agent_name") + .build() + ) + .sequenceNumber(0L) + .status(0L) + .streamId("stream_id") + .build() + + val betaResponsesServerEvent = BetaResponsesServerEvent.ofError(error) + + assertThat(betaResponsesServerEvent.responseAudioDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseAudioDone()).isEmpty + assertThat(betaResponsesServerEvent.responseAudioTranscriptDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseAudioTranscriptDone()).isEmpty + assertThat(betaResponsesServerEvent.responseCodeInterpreterCallCodeDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseCodeInterpreterCallCodeDone()).isEmpty + assertThat(betaResponsesServerEvent.responseCodeInterpreterCallCompleted()).isEmpty + assertThat(betaResponsesServerEvent.responseCodeInterpreterCallInProgress()).isEmpty + assertThat(betaResponsesServerEvent.responseCodeInterpreterCallInterpreting()).isEmpty + assertThat(betaResponsesServerEvent.responseCompleted()).isEmpty + assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty + assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty + assertThat(betaResponsesServerEvent.responseCreated()).isEmpty + assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty + assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty + assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty + assertThat(betaResponsesServerEvent.responseFunctionCallArgumentsDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseFunctionCallArgumentsDone()).isEmpty + assertThat(betaResponsesServerEvent.responseInProgress()).isEmpty + assertThat(betaResponsesServerEvent.responseFailed()).isEmpty + assertThat(betaResponsesServerEvent.responseIncomplete()).isEmpty + assertThat(betaResponsesServerEvent.responseOutputItemAdded()).isEmpty + assertThat(betaResponsesServerEvent.responseOutputItemDone()).isEmpty + assertThat(betaResponsesServerEvent.responseReasoningSummaryPartAdded()).isEmpty + assertThat(betaResponsesServerEvent.responseReasoningSummaryPartDone()).isEmpty + assertThat(betaResponsesServerEvent.responseReasoningSummaryTextDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseReasoningSummaryTextDone()).isEmpty + assertThat(betaResponsesServerEvent.responseReasoningTextDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseReasoningTextDone()).isEmpty + assertThat(betaResponsesServerEvent.responseRefusalDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseRefusalDone()).isEmpty + assertThat(betaResponsesServerEvent.responseOutputTextDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseOutputTextDone()).isEmpty + assertThat(betaResponsesServerEvent.responseWebSearchCallCompleted()).isEmpty + assertThat(betaResponsesServerEvent.responseWebSearchCallInProgress()).isEmpty + assertThat(betaResponsesServerEvent.responseWebSearchCallSearching()).isEmpty + assertThat(betaResponsesServerEvent.responseImageGenerationCallCompleted()).isEmpty + assertThat(betaResponsesServerEvent.responseImageGenerationCallGenerating()).isEmpty + assertThat(betaResponsesServerEvent.responseImageGenerationCallInProgress()).isEmpty + assertThat(betaResponsesServerEvent.responseImageGenerationCallPartialImage()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpCallArgumentsDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpCallArgumentsDone()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpCallCompleted()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpCallFailed()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpCallInProgress()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpListToolsCompleted()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpListToolsFailed()).isEmpty + assertThat(betaResponsesServerEvent.responseMcpListToolsInProgress()).isEmpty + assertThat(betaResponsesServerEvent.responseOutputTextAnnotationAdded()).isEmpty + assertThat(betaResponsesServerEvent.responseQueued()).isEmpty + assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty + assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).contains(error) + assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty + assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty + } + + @Test + fun ofErrorRoundtrip() { + val jsonMapper = jsonMapper() + val betaResponsesServerEvent = + BetaResponsesServerEvent.ofError( + BetaResponsesServerEvent.BetaResponseWsError.builder() + .error( + BetaResponsesServerEvent.BetaResponseWsError.Error.builder() + .code("code") + .message("message") + .param("param") + .type("type") + .headers( + BetaResponsesServerEvent.BetaResponseWsError.Error.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .agent( + BetaResponsesServerEvent.BetaResponseWsError.Agent.builder() + .agentName("agent_name") + .build() + ) + .sequenceNumber(0L) + .status(0L) + .streamId("stream_id") + .build() + ) + + val roundtrippedBetaResponsesServerEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaResponsesServerEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaResponsesServerEvent).isEqualTo(betaResponsesServerEvent) + } + @Test fun ofResponseInjectCreated() { val responseInjectCreated = @@ -8298,7 +8342,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -8338,6 +8381,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).contains(responseInjectCreated) assertThat(betaResponsesServerEvent.streamId()).contains("stream_id") assertThat(betaResponsesServerEvent.responseInjectFailed()).isEmpty @@ -8403,7 +8447,6 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseContentPartAdded()).isEmpty assertThat(betaResponsesServerEvent.responseContentPartDone()).isEmpty assertThat(betaResponsesServerEvent.responseCreated()).isEmpty - assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(betaResponsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -8443,6 +8486,7 @@ internal class BetaResponsesServerEventTest { assertThat(betaResponsesServerEvent.responseQueued()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(betaResponsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(betaResponsesServerEvent.error()).isEmpty assertThat(betaResponsesServerEvent.responseInjectCreated()).isEmpty assertThat(betaResponsesServerEvent.responseInjectFailed()).contains(responseInjectFailed) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaToolTest.kt index 6869a21cb..342d4dea1 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaToolTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaToolTest.kt @@ -267,6 +267,7 @@ internal class BetaToolTest { val webSearch = BetaWebSearchTool.builder() .type(BetaWebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(BetaWebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(BetaWebSearchTool.SearchContextSize.LOW) .userLocation( @@ -307,6 +308,7 @@ internal class BetaToolTest { BetaTool.ofWebSearch( BetaWebSearchTool.builder() .type(BetaWebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(BetaWebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(BetaWebSearchTool.SearchContextSize.LOW) .userLocation( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaWebSearchToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaWebSearchToolTest.kt index 2215ddb7d..b12a41b3d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaWebSearchToolTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/beta/responses/BetaWebSearchToolTest.kt @@ -14,6 +14,7 @@ internal class BetaWebSearchToolTest { val betaWebSearchTool = BetaWebSearchTool.builder() .type(BetaWebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(BetaWebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(BetaWebSearchTool.SearchContextSize.LOW) .userLocation( @@ -28,6 +29,7 @@ internal class BetaWebSearchToolTest { .build() assertThat(betaWebSearchTool.type()).isEqualTo(BetaWebSearchTool.Type.WEB_SEARCH) + assertThat(betaWebSearchTool.externalWebAccess()).contains(true) assertThat(betaWebSearchTool.filters()) .contains(BetaWebSearchTool.Filters.builder().addAllowedDomain("string").build()) assertThat(betaWebSearchTool.searchContextSize()) @@ -50,6 +52,7 @@ internal class BetaWebSearchToolTest { val betaWebSearchTool = BetaWebSearchTool.builder() .type(BetaWebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(BetaWebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(BetaWebSearchTool.SearchContextSize.LOW) .userLocation( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionChunkTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionChunkTest.kt index 0dc6fb007..6209708ea 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionChunkTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionChunkTest.kt @@ -180,6 +180,7 @@ internal class ChatCompletionChunkTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -187,6 +188,8 @@ internal class ChatCompletionChunkTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -358,6 +361,7 @@ internal class ChatCompletionChunkTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -365,6 +369,8 @@ internal class ChatCompletionChunkTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -541,6 +547,7 @@ internal class ChatCompletionChunkTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -548,6 +555,8 @@ internal class ChatCompletionChunkTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponseTest.kt index 1b66bb240..58ee0c63a 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponseTest.kt @@ -217,6 +217,7 @@ internal class ChatCompletionListPageResponseTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -224,6 +225,8 @@ internal class ChatCompletionListPageResponseTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -425,6 +428,7 @@ internal class ChatCompletionListPageResponseTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -432,6 +436,8 @@ internal class ChatCompletionListPageResponseTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -650,6 +656,7 @@ internal class ChatCompletionListPageResponseTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -657,6 +664,8 @@ internal class ChatCompletionListPageResponseTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionTest.kt index 286002ac1..06225d671 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionTest.kt @@ -191,6 +191,7 @@ internal class ChatCompletionTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -198,6 +199,8 @@ internal class ChatCompletionTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -378,6 +381,7 @@ internal class ChatCompletionTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -385,6 +389,8 @@ internal class ChatCompletionTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -572,6 +578,7 @@ internal class ChatCompletionTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -579,6 +586,8 @@ internal class ChatCompletionTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionTest.kt index 9ff8f0a5f..d8ace292a 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionTest.kt @@ -48,6 +48,7 @@ internal class CompletionTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -55,6 +56,8 @@ internal class CompletionTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -97,6 +100,7 @@ internal class CompletionTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -104,6 +108,8 @@ internal class CompletionTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -149,6 +155,7 @@ internal class CompletionTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -156,6 +163,8 @@ internal class CompletionTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionUsageTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionUsageTest.kt index b8cf14d17..b71a48eb4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionUsageTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/completions/CompletionUsageTest.kt @@ -22,6 +22,7 @@ internal class CompletionUsageTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -29,6 +30,8 @@ internal class CompletionUsageTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() @@ -43,6 +46,7 @@ internal class CompletionUsageTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) assertThat(completionUsage.promptTokensDetails()) @@ -51,6 +55,8 @@ internal class CompletionUsageTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) } @@ -69,6 +75,7 @@ internal class CompletionUsageTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -76,6 +83,8 @@ internal class CompletionUsageTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt index 2598ce339..b1a9d2b0a 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/conversations/items/ConversationItemTest.kt @@ -9,6 +9,7 @@ import com.openai.errors.OpenAIInvalidDataException import com.openai.models.conversations.Message import com.openai.models.responses.ComputerAction import com.openai.models.responses.FunctionTool +import com.openai.models.responses.McpToolCallError import com.openai.models.responses.ResponseApplyPatchToolCall import com.openai.models.responses.ResponseApplyPatchToolCallOutput import com.openai.models.responses.ResponseCodeInterpreterToolCall @@ -1963,7 +1964,9 @@ internal class ConversationItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + ) .output("output") .status(ConversationItem.McpCall.Status.IN_PROGRESS) .build() @@ -2011,7 +2014,12 @@ internal class ConversationItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(ConversationItem.McpCall.Status.IN_PROGRESS) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/models/ModelListPageResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/models/ModelListPageResponseTest.kt index 8d61bdfdf..bd954400a 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/models/ModelListPageResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/models/ModelListPageResponseTest.kt @@ -4,6 +4,7 @@ package com.openai.models.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openai.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,11 +14,25 @@ internal class ModelListPageResponseTest { fun create() { val modelListPageResponse = ModelListPageResponse.builder() - .addData(Model.builder().id("id").created(0L).ownedBy("owned_by").build()) + .addData( + Model.builder() + .id("id") + .created(0L) + .ownedBy("owned_by") + .shutdownDate(LocalDate.parse("2019-12-27")) + .build() + ) .build() assertThat(modelListPageResponse.data()) - .containsExactly(Model.builder().id("id").created(0L).ownedBy("owned_by").build()) + .containsExactly( + Model.builder() + .id("id") + .created(0L) + .ownedBy("owned_by") + .shutdownDate(LocalDate.parse("2019-12-27")) + .build() + ) } @Test @@ -25,7 +40,14 @@ internal class ModelListPageResponseTest { val jsonMapper = jsonMapper() val modelListPageResponse = ModelListPageResponse.builder() - .addData(Model.builder().id("id").created(0L).ownedBy("owned_by").build()) + .addData( + Model.builder() + .id("id") + .created(0L) + .ownedBy("owned_by") + .shutdownDate(LocalDate.parse("2019-12-27")) + .build() + ) .build() val roundtrippedModelListPageResponse = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/models/ModelTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/models/ModelTest.kt index ceb00ce25..6b7c88fe8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/models/ModelTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/models/ModelTest.kt @@ -4,6 +4,7 @@ package com.openai.models.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openai.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,17 +12,30 @@ internal class ModelTest { @Test fun create() { - val model = Model.builder().id("id").created(0L).ownedBy("owned_by").build() + val model = + Model.builder() + .id("id") + .created(0L) + .ownedBy("owned_by") + .shutdownDate(LocalDate.parse("2019-12-27")) + .build() assertThat(model.id()).isEqualTo("id") assertThat(model.created()).isEqualTo(0L) assertThat(model.ownedBy()).isEqualTo("owned_by") + assertThat(model.shutdownDate()).contains(LocalDate.parse("2019-12-27")) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val model = Model.builder().id("id").created(0L).ownedBy("owned_by").build() + val model = + Model.builder() + .id("id") + .created(0L) + .ownedBy("owned_by") + .shutdownDate(LocalDate.parse("2019-12-27")) + .build() val roundtrippedModel = jsonMapper.readValue(jsonMapper.writeValueAsString(model), jacksonTypeRef()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/McpToolCallErrorTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/McpToolCallErrorTest.kt new file mode 100644 index 000000000..f353d22e6 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/McpToolCallErrorTest.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.responses + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.JsonValue +import com.openai.core.jsonMapper +import com.openai.errors.OpenAIInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class McpToolCallErrorTest { + + @Test + fun ofProtocol() { + val protocol = + McpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + + val mcpToolCallError = McpToolCallError.ofProtocol(protocol) + + assertThat(mcpToolCallError.protocol()).contains(protocol) + assertThat(mcpToolCallError.toolExecution()).isEmpty + assertThat(mcpToolCallError.http()).isEmpty + } + + @Test + fun ofProtocolRoundtrip() { + val jsonMapper = jsonMapper() + val mcpToolCallError = + McpToolCallError.ofProtocol( + McpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + ) + + val roundtrippedMcpToolCallError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(mcpToolCallError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMcpToolCallError).isEqualTo(mcpToolCallError) + } + + @Test + fun ofToolExecution() { + val toolExecution = + McpToolCallError.McpToolExecutionError.builder() + .content(JsonValue.from(mapOf())) + .build() + + val mcpToolCallError = McpToolCallError.ofToolExecution(toolExecution) + + assertThat(mcpToolCallError.protocol()).isEmpty + assertThat(mcpToolCallError.toolExecution()).contains(toolExecution) + assertThat(mcpToolCallError.http()).isEmpty + } + + @Test + fun ofToolExecutionRoundtrip() { + val jsonMapper = jsonMapper() + val mcpToolCallError = + McpToolCallError.ofToolExecution( + McpToolCallError.McpToolExecutionError.builder() + .content(JsonValue.from(mapOf())) + .build() + ) + + val roundtrippedMcpToolCallError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(mcpToolCallError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMcpToolCallError).isEqualTo(mcpToolCallError) + } + + @Test + fun ofHttp() { + val http = McpToolCallError.HttpError.builder().code(0L).message("message").build() + + val mcpToolCallError = McpToolCallError.ofHttp(http) + + assertThat(mcpToolCallError.protocol()).isEmpty + assertThat(mcpToolCallError.toolExecution()).isEmpty + assertThat(mcpToolCallError.http()).contains(http) + } + + @Test + fun ofHttpRoundtrip() { + val jsonMapper = jsonMapper() + val mcpToolCallError = + McpToolCallError.ofHttp( + McpToolCallError.HttpError.builder().code(0L).message("message").build() + ) + + val roundtrippedMcpToolCallError = + jsonMapper.readValue( + jsonMapper.writeValueAsString(mcpToolCallError), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMcpToolCallError).isEqualTo(mcpToolCallError) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val mcpToolCallError = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { mcpToolCallError.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt index 60ee4ff21..fc6f018a9 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInputItemTest.kt @@ -2083,7 +2083,9 @@ internal class ResponseInputItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + ) .output("output") .status(ResponseInputItem.McpCall.Status.IN_PROGRESS) .build() @@ -2135,7 +2137,12 @@ internal class ResponseInputItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(ResponseInputItem.McpCall.Status.IN_PROGRESS) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt index da31f1833..5a352c4e5 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseItemTest.kt @@ -2077,7 +2077,9 @@ internal class ResponseItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + ) .output("output") .status(ResponseItem.McpCall.Status.IN_PROGRESS) .build() @@ -2126,7 +2128,12 @@ internal class ResponseItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(ResponseItem.McpCall.Status.IN_PROGRESS) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt index 25e29b043..3ad1f30cc 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputItemTest.kt @@ -1765,7 +1765,9 @@ internal class ResponseOutputItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder().code(0L).message("message").build() + ) .output("output") .status(ResponseOutputItem.McpCall.Status.IN_PROGRESS) .build() @@ -1813,7 +1815,12 @@ internal class ResponseOutputItemTest { .name("name") .serverLabel("server_label") .approvalRequestId("approval_request_id") - .error("error") + .error( + McpToolCallError.McpProtocolError.builder() + .code(0L) + .message("message") + .build() + ) .output("output") .status(ResponseOutputItem.McpCall.Status.IN_PROGRESS) .build() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEventTest.kt index 4bd73a0ec..fd2cb27e6 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseOutputTextAnnotationAddedEventTest.kt @@ -3,7 +3,6 @@ package com.openai.models.responses import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openai.core.JsonValue import com.openai.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,7 +13,13 @@ internal class ResponseOutputTextAnnotationAddedEventTest { fun create() { val responseOutputTextAnnotationAddedEvent = ResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + ResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -22,8 +27,16 @@ internal class ResponseOutputTextAnnotationAddedEventTest { .sequenceNumber(0L) .build() - assertThat(responseOutputTextAnnotationAddedEvent._annotation()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(responseOutputTextAnnotationAddedEvent.annotation()) + .contains( + ResponseOutputTextAnnotationAddedEvent.Annotation.ofFileCitation( + ResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) + ) assertThat(responseOutputTextAnnotationAddedEvent.annotationIndex()).isEqualTo(0L) assertThat(responseOutputTextAnnotationAddedEvent.contentIndex()).isEqualTo(0L) assertThat(responseOutputTextAnnotationAddedEvent.itemId()).isEqualTo("item_id") @@ -36,7 +49,13 @@ internal class ResponseOutputTextAnnotationAddedEventTest { val jsonMapper = jsonMapper() val responseOutputTextAnnotationAddedEvent = ResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + ResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt index 598c72f24..858646d62 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt @@ -6725,7 +6725,13 @@ internal class ResponseStreamEventTest { fun ofOutputTextAnnotationAdded() { val outputTextAnnotationAdded = ResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + ResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -6798,7 +6804,13 @@ internal class ResponseStreamEventTest { val responseStreamEvent = ResponseStreamEvent.ofOutputTextAnnotationAdded( ResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + ResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt index 8ffba3acb..28bc8528a 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt @@ -43,7 +43,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -83,6 +82,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -121,7 +121,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -161,6 +160,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -202,7 +202,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -242,6 +241,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -286,7 +286,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -326,6 +325,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -374,7 +374,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -414,6 +413,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -467,7 +467,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -507,6 +506,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -559,7 +559,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -599,6 +598,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -650,7 +650,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -690,6 +689,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -741,7 +741,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -781,6 +780,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -1032,7 +1032,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -1072,6 +1071,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -1361,7 +1361,6 @@ internal class ResponsesServerEventTest { .contains(responseContentPartAdded) assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -1401,6 +1400,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -1503,7 +1503,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).contains(responseContentPartDone) assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -1543,6 +1542,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -1821,7 +1821,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).contains(responseCreated) - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -1861,6 +1860,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -2097,95 +2097,6 @@ internal class ResponsesServerEventTest { assertThat(roundtrippedResponsesServerEvent).isEqualTo(responsesServerEvent) } - @Test - fun ofError() { - val error = - ResponseErrorEvent.builder() - .code("code") - .message("message") - .param("param") - .sequenceNumber(0L) - .build() - - val responsesServerEvent = ResponsesServerEvent.ofError(error) - - assertThat(responsesServerEvent.responseAudioDelta()).isEmpty - assertThat(responsesServerEvent.responseAudioDone()).isEmpty - assertThat(responsesServerEvent.responseAudioTranscriptDelta()).isEmpty - assertThat(responsesServerEvent.responseAudioTranscriptDone()).isEmpty - assertThat(responsesServerEvent.responseCodeInterpreterCallCodeDelta()).isEmpty - assertThat(responsesServerEvent.responseCodeInterpreterCallCodeDone()).isEmpty - assertThat(responsesServerEvent.responseCodeInterpreterCallCompleted()).isEmpty - assertThat(responsesServerEvent.responseCodeInterpreterCallInProgress()).isEmpty - assertThat(responsesServerEvent.responseCodeInterpreterCallInterpreting()).isEmpty - assertThat(responsesServerEvent.responseCompleted()).isEmpty - assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty - assertThat(responsesServerEvent.responseContentPartDone()).isEmpty - assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).contains(error) - assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty - assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty - assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty - assertThat(responsesServerEvent.responseFunctionCallArgumentsDelta()).isEmpty - assertThat(responsesServerEvent.responseFunctionCallArgumentsDone()).isEmpty - assertThat(responsesServerEvent.responseInProgress()).isEmpty - assertThat(responsesServerEvent.responseFailed()).isEmpty - assertThat(responsesServerEvent.responseIncomplete()).isEmpty - assertThat(responsesServerEvent.responseOutputItemAdded()).isEmpty - assertThat(responsesServerEvent.responseOutputItemDone()).isEmpty - assertThat(responsesServerEvent.responseReasoningSummaryPartAdded()).isEmpty - assertThat(responsesServerEvent.responseReasoningSummaryPartDone()).isEmpty - assertThat(responsesServerEvent.responseReasoningSummaryTextDelta()).isEmpty - assertThat(responsesServerEvent.responseReasoningSummaryTextDone()).isEmpty - assertThat(responsesServerEvent.responseReasoningTextDelta()).isEmpty - assertThat(responsesServerEvent.responseReasoningTextDone()).isEmpty - assertThat(responsesServerEvent.responseRefusalDelta()).isEmpty - assertThat(responsesServerEvent.responseRefusalDone()).isEmpty - assertThat(responsesServerEvent.responseOutputTextDelta()).isEmpty - assertThat(responsesServerEvent.responseOutputTextDone()).isEmpty - assertThat(responsesServerEvent.responseWebSearchCallCompleted()).isEmpty - assertThat(responsesServerEvent.responseWebSearchCallInProgress()).isEmpty - assertThat(responsesServerEvent.responseWebSearchCallSearching()).isEmpty - assertThat(responsesServerEvent.responseImageGenerationCallCompleted()).isEmpty - assertThat(responsesServerEvent.responseImageGenerationCallGenerating()).isEmpty - assertThat(responsesServerEvent.responseImageGenerationCallInProgress()).isEmpty - assertThat(responsesServerEvent.responseImageGenerationCallPartialImage()).isEmpty - assertThat(responsesServerEvent.responseMcpCallArgumentsDelta()).isEmpty - assertThat(responsesServerEvent.responseMcpCallArgumentsDone()).isEmpty - assertThat(responsesServerEvent.responseMcpCallCompleted()).isEmpty - assertThat(responsesServerEvent.responseMcpCallFailed()).isEmpty - assertThat(responsesServerEvent.responseMcpCallInProgress()).isEmpty - assertThat(responsesServerEvent.responseMcpListToolsCompleted()).isEmpty - assertThat(responsesServerEvent.responseMcpListToolsFailed()).isEmpty - assertThat(responsesServerEvent.responseMcpListToolsInProgress()).isEmpty - assertThat(responsesServerEvent.responseOutputTextAnnotationAdded()).isEmpty - assertThat(responsesServerEvent.responseQueued()).isEmpty - assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty - assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty - } - - @Test - fun ofErrorRoundtrip() { - val jsonMapper = jsonMapper() - val responsesServerEvent = - ResponsesServerEvent.ofError( - ResponseErrorEvent.builder() - .code("code") - .message("message") - .param("param") - .sequenceNumber(0L) - .build() - ) - - val roundtrippedResponsesServerEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(responsesServerEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedResponsesServerEvent).isEqualTo(responsesServerEvent) - } - @Test fun ofResponseFileSearchCallCompleted() { val responseFileSearchCallCompleted = @@ -2211,7 +2122,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()) .contains(responseFileSearchCallCompleted) assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty @@ -2252,6 +2162,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -2302,7 +2213,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()) .contains(responseFileSearchCallInProgress) @@ -2343,6 +2253,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -2391,7 +2302,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()) @@ -2432,6 +2342,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -2483,7 +2394,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -2524,6 +2434,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -2577,7 +2488,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -2618,6 +2528,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -2871,7 +2782,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -2911,6 +2821,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -3375,7 +3286,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -3415,6 +3325,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -3879,7 +3790,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -3919,6 +3829,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4212,7 +4123,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4252,6 +4162,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4364,7 +4275,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4404,6 +4314,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4488,7 +4399,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4529,6 +4439,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4586,7 +4497,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4627,6 +4537,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4682,7 +4593,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4723,6 +4633,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4777,7 +4688,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4818,6 +4728,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4870,7 +4781,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -4911,6 +4821,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -4963,7 +4874,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5004,6 +4914,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5055,7 +4966,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5095,6 +5005,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5146,7 +5057,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5186,6 +5096,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5250,7 +5161,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5290,6 +5200,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5366,7 +5277,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5406,6 +5316,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5468,7 +5379,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5509,6 +5419,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5557,7 +5468,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5598,6 +5508,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5646,7 +5557,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5687,6 +5597,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5737,7 +5648,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5778,6 +5688,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5828,7 +5739,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5869,6 +5779,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -5919,7 +5830,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -5960,6 +5870,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6012,7 +5923,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6053,6 +5963,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6104,7 +6015,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6145,6 +6055,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6195,7 +6106,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6236,6 +6146,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6285,7 +6196,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6326,6 +6236,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6374,7 +6285,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6414,6 +6324,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6462,7 +6373,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6503,6 +6413,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6551,7 +6462,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6592,6 +6502,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6640,7 +6551,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6681,6 +6591,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6729,7 +6640,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6770,6 +6680,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6797,7 +6708,13 @@ internal class ResponsesServerEventTest { fun ofResponseOutputTextAnnotationAdded() { val responseOutputTextAnnotationAdded = ResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + ResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -6823,7 +6740,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -6864,6 +6780,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -6872,7 +6789,13 @@ internal class ResponsesServerEventTest { val responsesServerEvent = ResponsesServerEvent.ofResponseOutputTextAnnotationAdded( ResponseOutputTextAnnotationAddedEvent.builder() - .annotation(JsonValue.from(mapOf())) + .annotation( + ResponseOutputTextAnnotationAddedEvent.Annotation.FileCitation.builder() + .fileId("file_id") + .filename("filename") + .index(0L) + .build() + ) .annotationIndex(0L) .contentIndex(0L) .itemId("item_id") @@ -7118,7 +7041,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7158,6 +7080,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseQueued()).contains(responseQueued) assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -7422,7 +7345,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7463,6 +7385,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseCustomToolCallInputDelta()) .contains(responseCustomToolCallInputDelta) assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -7513,7 +7436,6 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty assertThat(responsesServerEvent.responseContentPartDone()).isEmpty assertThat(responsesServerEvent.responseCreated()).isEmpty - assertThat(responsesServerEvent.error()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty @@ -7554,6 +7476,7 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty assertThat(responsesServerEvent.responseCustomToolCallInputDone()) .contains(responseCustomToolCallInputDone) + assertThat(responsesServerEvent.error()).isEmpty } @Test @@ -7609,6 +7532,119 @@ internal class ResponsesServerEventTest { assertThat(responsesServerEvent.isValid()).isFalse() } + @Test + fun ofError() { + val error = + ResponsesServerEvent.ResponseWsError.builder() + .error( + ResponsesServerEvent.ResponseWsError.Error.builder() + .code("code") + .message("message") + .param("param") + .type("type") + .headers( + ResponsesServerEvent.ResponseWsError.Error.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .sequenceNumber(0L) + .status(0L) + .streamId("stream_id") + .build() + + val responsesServerEvent = ResponsesServerEvent.ofError(error) + + assertThat(responsesServerEvent.responseAudioDelta()).isEmpty + assertThat(responsesServerEvent.responseAudioDone()).isEmpty + assertThat(responsesServerEvent.responseAudioTranscriptDelta()).isEmpty + assertThat(responsesServerEvent.responseAudioTranscriptDone()).isEmpty + assertThat(responsesServerEvent.responseCodeInterpreterCallCodeDelta()).isEmpty + assertThat(responsesServerEvent.responseCodeInterpreterCallCodeDone()).isEmpty + assertThat(responsesServerEvent.responseCodeInterpreterCallCompleted()).isEmpty + assertThat(responsesServerEvent.responseCodeInterpreterCallInProgress()).isEmpty + assertThat(responsesServerEvent.responseCodeInterpreterCallInterpreting()).isEmpty + assertThat(responsesServerEvent.responseCompleted()).isEmpty + assertThat(responsesServerEvent.responseContentPartAdded()).isEmpty + assertThat(responsesServerEvent.responseContentPartDone()).isEmpty + assertThat(responsesServerEvent.responseCreated()).isEmpty + assertThat(responsesServerEvent.responseFileSearchCallCompleted()).isEmpty + assertThat(responsesServerEvent.responseFileSearchCallInProgress()).isEmpty + assertThat(responsesServerEvent.responseFileSearchCallSearching()).isEmpty + assertThat(responsesServerEvent.responseFunctionCallArgumentsDelta()).isEmpty + assertThat(responsesServerEvent.responseFunctionCallArgumentsDone()).isEmpty + assertThat(responsesServerEvent.responseInProgress()).isEmpty + assertThat(responsesServerEvent.responseFailed()).isEmpty + assertThat(responsesServerEvent.responseIncomplete()).isEmpty + assertThat(responsesServerEvent.responseOutputItemAdded()).isEmpty + assertThat(responsesServerEvent.responseOutputItemDone()).isEmpty + assertThat(responsesServerEvent.responseReasoningSummaryPartAdded()).isEmpty + assertThat(responsesServerEvent.responseReasoningSummaryPartDone()).isEmpty + assertThat(responsesServerEvent.responseReasoningSummaryTextDelta()).isEmpty + assertThat(responsesServerEvent.responseReasoningSummaryTextDone()).isEmpty + assertThat(responsesServerEvent.responseReasoningTextDelta()).isEmpty + assertThat(responsesServerEvent.responseReasoningTextDone()).isEmpty + assertThat(responsesServerEvent.responseRefusalDelta()).isEmpty + assertThat(responsesServerEvent.responseRefusalDone()).isEmpty + assertThat(responsesServerEvent.responseOutputTextDelta()).isEmpty + assertThat(responsesServerEvent.responseOutputTextDone()).isEmpty + assertThat(responsesServerEvent.responseWebSearchCallCompleted()).isEmpty + assertThat(responsesServerEvent.responseWebSearchCallInProgress()).isEmpty + assertThat(responsesServerEvent.responseWebSearchCallSearching()).isEmpty + assertThat(responsesServerEvent.responseImageGenerationCallCompleted()).isEmpty + assertThat(responsesServerEvent.responseImageGenerationCallGenerating()).isEmpty + assertThat(responsesServerEvent.responseImageGenerationCallInProgress()).isEmpty + assertThat(responsesServerEvent.responseImageGenerationCallPartialImage()).isEmpty + assertThat(responsesServerEvent.responseMcpCallArgumentsDelta()).isEmpty + assertThat(responsesServerEvent.responseMcpCallArgumentsDone()).isEmpty + assertThat(responsesServerEvent.responseMcpCallCompleted()).isEmpty + assertThat(responsesServerEvent.responseMcpCallFailed()).isEmpty + assertThat(responsesServerEvent.responseMcpCallInProgress()).isEmpty + assertThat(responsesServerEvent.responseMcpListToolsCompleted()).isEmpty + assertThat(responsesServerEvent.responseMcpListToolsFailed()).isEmpty + assertThat(responsesServerEvent.responseMcpListToolsInProgress()).isEmpty + assertThat(responsesServerEvent.responseOutputTextAnnotationAdded()).isEmpty + assertThat(responsesServerEvent.responseQueued()).isEmpty + assertThat(responsesServerEvent.responseCustomToolCallInputDelta()).isEmpty + assertThat(responsesServerEvent.responseCustomToolCallInputDone()).isEmpty + assertThat(responsesServerEvent.error()).contains(error) + } + + @Test + fun ofErrorRoundtrip() { + val jsonMapper = jsonMapper() + val responsesServerEvent = + ResponsesServerEvent.ofError( + ResponsesServerEvent.ResponseWsError.builder() + .error( + ResponsesServerEvent.ResponseWsError.Error.builder() + .code("code") + .message("message") + .param("param") + .type("type") + .headers( + ResponsesServerEvent.ResponseWsError.Error.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .sequenceNumber(0L) + .status(0L) + .streamId("stream_id") + .build() + ) + + val roundtrippedResponsesServerEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responsesServerEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponsesServerEvent).isEqualTo(responsesServerEvent) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt index 7214f891f..52ce31cb9 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ToolTest.kt @@ -256,6 +256,7 @@ internal class ToolTest { val webSearch = WebSearchTool.builder() .type(WebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(WebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(WebSearchTool.SearchContextSize.LOW) .userLocation( @@ -296,6 +297,7 @@ internal class ToolTest { Tool.ofWebSearch( WebSearchTool.builder() .type(WebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(WebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(WebSearchTool.SearchContextSize.LOW) .userLocation( diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/WebSearchToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/WebSearchToolTest.kt index bfc7aaa37..18c26a175 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/WebSearchToolTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/WebSearchToolTest.kt @@ -14,6 +14,7 @@ internal class WebSearchToolTest { val webSearchTool = WebSearchTool.builder() .type(WebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(WebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(WebSearchTool.SearchContextSize.LOW) .userLocation( @@ -28,6 +29,7 @@ internal class WebSearchToolTest { .build() assertThat(webSearchTool.type()).isEqualTo(WebSearchTool.Type.WEB_SEARCH) + assertThat(webSearchTool.externalWebAccess()).contains(true) assertThat(webSearchTool.filters()) .contains(WebSearchTool.Filters.builder().addAllowedDomain("string").build()) assertThat(webSearchTool.searchContextSize()).contains(WebSearchTool.SearchContextSize.LOW) @@ -49,6 +51,7 @@ internal class WebSearchToolTest { val webSearchTool = WebSearchTool.builder() .type(WebSearchTool.Type.WEB_SEARCH) + .externalWebAccess(true) .filters(WebSearchTool.Filters.builder().addAllowedDomain("string").build()) .searchContextSize(WebSearchTool.SearchContextSize.LOW) .userLocation( diff --git a/openai-java-proguard-test/src/test/kotlin/com/openai/proguard/ProGuardCompatibilityTest.kt b/openai-java-proguard-test/src/test/kotlin/com/openai/proguard/ProGuardCompatibilityTest.kt index 4a75cf9a1..7d684c5ff 100644 --- a/openai-java-proguard-test/src/test/kotlin/com/openai/proguard/ProGuardCompatibilityTest.kt +++ b/openai-java-proguard-test/src/test/kotlin/com/openai/proguard/ProGuardCompatibilityTest.kt @@ -265,6 +265,7 @@ internal class ProGuardCompatibilityTest { .audioTokens(0L) .reasoningTokens(0L) .rejectedPredictionTokens(0L) + .textTokens(0L) .build() ) .promptTokensDetails( @@ -272,6 +273,8 @@ internal class ProGuardCompatibilityTest { .audioTokens(0L) .cacheWriteTokens(0L) .cachedTokens(0L) + .imageTokens(0L) + .textTokens(0L) .build() ) .build()