From ca9d10813f768a90a4e103da98a9bcc0dd7b2e0c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 23:51:12 +0000 Subject: [PATCH] chore: update SDK settings (#37) --- .github/workflows/ci.yml | 21 + .github/workflows/release-doctor.yml | 2 + .release-please-manifest.json | 2 +- .stats.yml | 4 +- README.md | 6 +- .../api/client/okhttp/OkHttpClient.kt | 23 +- .../api/client/BraintrustClient.kt | 19 - .../api/client/BraintrustClientAsync.kt | 19 - .../api/client/BraintrustClientAsyncImpl.kt | 36 +- .../api/client/BraintrustClientImpl.kt | 28 +- .../api/core/BaseDeserializer.kt | 20 +- .../braintrustdata/api/core/ClientOptions.kt | 140 +- .../com/braintrustdata/api/core/Properties.kt | 11 +- .../braintrustdata/api/core/RequestOptions.kt | 4 +- .../com/braintrustdata/api/core/Utils.kt | 10 +- .../com/braintrustdata/api/core/Values.kt | 141 +- .../api/core/http/BinaryResponseContent.kt | 10 +- .../api/core/http/HttpClient.kt | 6 +- .../api/core/http/HttpRequest.kt | 3 +- .../api/core/http/HttpRequestBody.kt | 11 +- .../api/core/http/HttpResponse.kt | 4 +- .../api/core/http/RetryingHttpClient.kt | 167 +- .../api/errors/BadRequestException.kt | 5 +- .../api/errors/BraintrustError.kt | 31 +- .../errors/BraintrustInvalidDataException.kt | 3 +- .../api/errors/BraintrustIoException.kt | 3 +- .../api/errors/BraintrustServiceException.kt | 7 +- .../api/errors/InternalServerException.kt | 7 +- .../api/errors/NotFoundException.kt | 5 +- .../api/errors/PermissionDeniedException.kt | 5 +- .../api/errors/RateLimitException.kt | 5 +- .../api/errors/UnauthorizedException.kt | 5 +- .../errors/UnexpectedStatusCodeException.kt | 8 +- .../errors/UnprocessableEntityException.kt | 5 +- .../com/braintrustdata/api/models/Acl.kt | 574 +- .../api/models/AclCreateParams.kt | 637 +- .../api/models/AclDeleteParams.kt | 129 +- .../braintrustdata/api/models/AclListPage.kt | 146 +- .../api/models/AclListPageAsync.kt | 175 +- .../api/models/AclListParams.kt | 410 +- .../api/models/AclReplaceParams.kt | 739 -- .../api/models/AclRetrieveParams.kt | 126 +- .../com/braintrustdata/api/models/ApiKey.kt | 185 +- .../api/models/ApiKeyCreateParams.kt | 230 +- .../api/models/ApiKeyCreateResponse.kt | 203 +- .../api/models/ApiKeyDeleteParams.kt | 129 +- .../api/models/ApiKeyListPage.kt | 146 +- .../api/models/ApiKeyListPageAsync.kt | 175 +- .../api/models/ApiKeyListParams.kt | 331 +- .../api/models/ApiKeyRetrieveParams.kt | 126 +- .../com/braintrustdata/api/models/Dataset.kt | 254 +- .../api/models/DatasetCreateParams.kt | 244 +- .../api/models/DatasetDeleteParams.kt | 129 +- .../api/models/DatasetFeedbackParams.kt | 397 +- .../api/models/DatasetFetchParams.kt | 248 +- .../api/models/DatasetFetchPostParams.kt | 727 +- .../api/models/DatasetFetchPostResponse.kt | 522 +- .../api/models/DatasetFetchResponse.kt | 522 +- .../api/models/DatasetInsertParams.kt | 1216 ++- .../api/models/DatasetInsertResponse.kt | 95 +- .../api/models/DatasetListPage.kt | 152 +- .../api/models/DatasetListPageAsync.kt | 185 +- .../api/models/DatasetListParams.kt | 347 +- .../api/models/DatasetReplaceParams.kt | 291 - .../api/models/DatasetRetrieveParams.kt | 126 +- .../api/models/DatasetSummarizeParams.kt | 147 +- .../api/models/DatasetSummarizeResponse.kt | 208 +- .../api/models/DatasetUpdateParams.kt | 287 +- .../braintrustdata/api/models/Experiment.kt | 637 +- .../api/models/ExperimentCreateParams.kt | 711 +- .../api/models/ExperimentDeleteParams.kt | 129 +- .../api/models/ExperimentFeedbackParams.kt | 480 +- .../api/models/ExperimentFetchParams.kt | 248 +- .../api/models/ExperimentFetchPostParams.kt | 727 +- .../api/models/ExperimentFetchPostResponse.kt | 1389 ++-- .../api/models/ExperimentFetchResponse.kt | 1389 ++-- .../api/models/ExperimentInsertParams.kt | 2765 ++++--- .../api/models/ExperimentInsertResponse.kt | 95 +- .../api/models/ExperimentListPage.kt | 156 +- .../api/models/ExperimentListPageAsync.kt | 185 +- .../api/models/ExperimentListParams.kt | 347 +- .../api/models/ExperimentReplaceParams.kt | 761 -- .../api/models/ExperimentRetrieveParams.kt | 126 +- .../api/models/ExperimentSummarizeParams.kt | 168 +- .../api/models/ExperimentSummarizeResponse.kt | 246 +- .../api/models/ExperimentUpdateParams.kt | 650 +- .../com/braintrustdata/api/models/Function.kt | 6694 +++++++++-------- .../api/models/FunctionCreateParams.kt | 6633 ++++++++-------- .../api/models/FunctionDeleteParams.kt | 129 +- .../api/models/FunctionFeedbackParams.kt | 562 -- .../api/models/FunctionListPage.kt | 152 +- .../api/models/FunctionListPageAsync.kt | 185 +- .../api/models/FunctionListParams.kt | 383 +- .../api/models/FunctionReplaceParams.kt | 6633 ++++++++-------- .../api/models/FunctionRetrieveParams.kt | 126 +- .../api/models/FunctionUpdateParams.kt | 6671 ++++++++-------- .../com/braintrustdata/api/models/Group.kt | 262 +- .../api/models/GroupCreateParams.kt | 332 +- .../api/models/GroupDeleteParams.kt | 129 +- .../api/models/GroupListPage.kt | 146 +- .../api/models/GroupListPageAsync.kt | 175 +- .../api/models/GroupListParams.kt | 331 +- .../api/models/GroupReplaceParams.kt | 332 +- .../api/models/GroupRetrieveParams.kt | 126 +- .../api/models/GroupUpdateParams.kt | 311 +- .../braintrustdata/api/models/Organization.kt | 206 +- .../api/models/OrganizationDeleteParams.kt | 129 +- .../api/models/OrganizationListPage.kt | 156 +- .../api/models/OrganizationListPageAsync.kt | 185 +- .../api/models/OrganizationListParams.kt | 327 +- .../models/OrganizationMemberUpdateParams.kt | 591 ++ .../OrganizationMemberUpdateResponse.kt | 204 + .../api/models/OrganizationRetrieveParams.kt | 126 +- .../api/models/OrganizationUpdateParams.kt | 314 +- .../com/braintrustdata/api/models/Project.kt | 249 +- .../api/models/ProjectCreateParams.kt | 230 +- .../api/models/ProjectDeleteParams.kt | 129 +- .../api/models/ProjectListPage.kt | 152 +- .../api/models/ProjectListPageAsync.kt | 185 +- .../api/models/ProjectListParams.kt | 331 +- .../api/models/ProjectLogFeedbackParams.kt | 480 +- .../api/models/ProjectLogFetchParams.kt | 248 +- .../api/models/ProjectLogFetchPostParams.kt | 727 +- .../api/models/ProjectLogFetchPostResponse.kt | 1370 ++-- .../api/models/ProjectLogFetchResponse.kt | 1370 ++-- .../api/models/ProjectLogInsertParams.kt | 2696 ++++--- .../api/models/ProjectLogInsertResponse.kt | 95 +- .../api/models/ProjectReplaceParams.kt | 278 - .../api/models/ProjectRetrieveParams.kt | 126 +- .../braintrustdata/api/models/ProjectScore.kt | 825 +- .../api/models/ProjectScoreCreateParams.kt | 736 +- .../api/models/ProjectScoreDeleteParams.kt | 129 +- .../api/models/ProjectScoreListPage.kt | 156 +- .../api/models/ProjectScoreListPageAsync.kt | 185 +- .../api/models/ProjectScoreListParams.kt | 343 +- .../api/models/ProjectScoreReplaceParams.kt | 736 +- .../api/models/ProjectScoreRetrieveParams.kt | 126 +- .../api/models/ProjectScoreUpdateParams.kt | 721 +- .../braintrustdata/api/models/ProjectTag.kt | 210 +- .../api/models/ProjectTagCreateParams.kt | 278 +- .../api/models/ProjectTagDeleteParams.kt | 129 +- .../api/models/ProjectTagListPage.kt | 156 +- .../api/models/ProjectTagListPageAsync.kt | 185 +- .../api/models/ProjectTagListParams.kt | 347 +- .../api/models/ProjectTagReplaceParams.kt | 278 +- .../api/models/ProjectTagRetrieveParams.kt | 126 +- .../api/models/ProjectTagUpdateParams.kt | 263 +- .../api/models/ProjectUpdateParams.kt | 285 +- .../com/braintrustdata/api/models/Prompt.kt | 5573 +++++++------- .../api/models/PromptCreateParams.kt | 5485 +++++++------- .../api/models/PromptDeleteParams.kt | 129 +- .../api/models/PromptFeedbackParams.kt | 562 -- .../api/models/PromptListPage.kt | 146 +- .../api/models/PromptListPageAsync.kt | 175 +- .../api/models/PromptListParams.kt | 383 +- .../api/models/PromptReplaceParams.kt | 5485 +++++++------- .../api/models/PromptRetrieveParams.kt | 126 +- .../api/models/PromptUpdateParams.kt | 5438 ++++++------- .../com/braintrustdata/api/models/Role.kt | 517 +- .../api/models/RoleCreateParams.kt | 546 +- .../api/models/RoleDeleteParams.kt | 129 +- .../braintrustdata/api/models/RoleListPage.kt | 146 +- .../api/models/RoleListPageAsync.kt | 175 +- .../api/models/RoleListParams.kt | 331 +- .../api/models/RoleReplaceParams.kt | 546 +- .../api/models/RoleRetrieveParams.kt | 126 +- .../api/models/RoleUpdateParams.kt | 756 +- .../api/models/TopLevelHelloWorldParams.kt | 101 +- .../com/braintrustdata/api/models/User.kt | 185 +- .../braintrustdata/api/models/UserListPage.kt | 146 +- .../api/models/UserListPageAsync.kt | 175 +- .../api/models/UserListParams.kt | 767 +- .../api/models/UserRetrieveParams.kt | 126 +- .../com/braintrustdata/api/models/View.kt | 751 +- .../api/models/ViewCreateParams.kt | 837 +-- .../api/models/ViewDeleteParams.kt | 311 +- .../braintrustdata/api/models/ViewListPage.kt | 146 +- .../api/models/ViewListPageAsync.kt | 175 +- .../api/models/ViewListParams.kt | 522 +- .../api/models/ViewReplaceParams.kt | 837 +-- .../api/models/ViewRetrieveParams.kt | 242 +- .../api/models/ViewUpdateParams.kt | 827 +- .../braintrustdata/api/services/Handlers.kt | 73 +- .../api/services/HttpRequestBodies.kt | 35 +- .../api/services/async/AclServiceAsync.kt | 63 +- .../api/services/async/AclServiceAsyncImpl.kt | 244 +- .../api/services/async/ApiKeyServiceAsync.kt | 59 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 240 +- .../api/services/async/DatasetServiceAsync.kt | 104 +- .../services/async/DatasetServiceAsyncImpl.kt | 530 +- .../services/async/ExperimentServiceAsync.kt | 108 +- .../async/ExperimentServiceAsyncImpl.kt | 536 +- .../services/async/FunctionServiceAsync.kt | 87 +- .../async/FunctionServiceAsyncImpl.kt | 373 +- .../api/services/async/GroupServiceAsync.kt | 84 +- .../services/async/GroupServiceAsyncImpl.kt | 351 +- .../async/OrganizationServiceAsync.kt | 68 +- .../async/OrganizationServiceAsyncImpl.kt | 252 +- .../async/ProjectScoreServiceAsync.kt | 87 +- .../async/ProjectScoreServiceAsyncImpl.kt | 354 +- .../api/services/async/ProjectServiceAsync.kt | 71 +- .../services/async/ProjectServiceAsyncImpl.kt | 298 +- .../services/async/ProjectTagServiceAsync.kt | 86 +- .../async/ProjectTagServiceAsyncImpl.kt | 353 +- .../api/services/async/PromptServiceAsync.kt | 90 +- .../services/async/PromptServiceAsyncImpl.kt | 376 +- .../api/services/async/RoleServiceAsync.kt | 84 +- .../services/async/RoleServiceAsyncImpl.kt | 351 +- .../services/async/TopLevelServiceAsync.kt | 45 +- .../async/TopLevelServiceAsyncImpl.kt | 75 +- .../api/services/async/UserServiceAsync.kt | 49 +- .../services/async/UserServiceAsyncImpl.kt | 141 +- .../api/services/async/ViewServiceAsync.kt | 85 +- .../services/async/ViewServiceAsyncImpl.kt | 350 +- .../async/organizations/MemberServiceAsync.kt | 20 + .../organizations/MemberServiceAsyncImpl.kt | 56 + .../services/async/project/LogServiceAsync.kt | 71 - .../async/project/LogServiceAsyncImpl.kt | 161 - .../async/projects/LogServiceAsync.kt | 63 +- .../async/projects/LogServiceAsyncImpl.kt | 231 +- .../api/services/blocking/AclService.kt | 52 +- .../api/services/blocking/AclServiceImpl.kt | 218 +- .../api/services/blocking/ApiKeyService.kt | 58 +- .../services/blocking/ApiKeyServiceImpl.kt | 220 +- .../api/services/blocking/DatasetService.kt | 103 +- .../services/blocking/DatasetServiceImpl.kt | 489 +- .../services/blocking/ExperimentService.kt | 107 +- .../blocking/ExperimentServiceImpl.kt | 520 +- .../api/services/blocking/FunctionService.kt | 86 +- .../services/blocking/FunctionServiceImpl.kt | 346 +- .../api/services/blocking/GroupService.kt | 83 +- .../api/services/blocking/GroupServiceImpl.kt | 313 +- .../services/blocking/OrganizationService.kt | 67 +- .../blocking/OrganizationServiceImpl.kt | 247 +- .../services/blocking/ProjectScoreService.kt | 86 +- .../blocking/ProjectScoreServiceImpl.kt | 347 +- .../api/services/blocking/ProjectService.kt | 70 +- .../services/blocking/ProjectServiceImpl.kt | 267 +- .../services/blocking/ProjectTagService.kt | 85 +- .../blocking/ProjectTagServiceImpl.kt | 346 +- .../api/services/blocking/PromptService.kt | 89 +- .../services/blocking/PromptServiceImpl.kt | 339 +- .../api/services/blocking/RoleService.kt | 83 +- .../api/services/blocking/RoleServiceImpl.kt | 313 +- .../api/services/blocking/TopLevelService.kt | 44 +- .../services/blocking/TopLevelServiceImpl.kt | 73 +- .../api/services/blocking/UserService.kt | 48 +- .../api/services/blocking/UserServiceImpl.kt | 127 +- .../api/services/blocking/ViewService.kt | 84 +- .../api/services/blocking/ViewServiceImpl.kt | 312 +- .../blocking/organizations/MemberService.kt | 19 + .../organizations/MemberServiceImpl.kt | 54 + .../services/blocking/project/LogService.kt | 71 - .../blocking/project/LogServiceImpl.kt | 161 - .../services/blocking/projects/LogService.kt | 62 +- .../blocking/projects/LogServiceImpl.kt | 221 +- .../braintrustdata/api/TestServerExtension.kt | 8 +- .../api/client/BraintrustClientTest.kt | 5 - .../api/core/http/HttpRequestTest.kt | 18 +- .../api/core/http/RetryingHttpClientTest.kt | 71 +- .../api/core/http/SerializerTest.kt | 40 +- .../api/models/AclCreateParamsTest.kt | 83 +- .../api/models/AclDeleteParamsTest.kt | 33 +- .../api/models/AclListParamsTest.kt | 78 +- .../api/models/AclReplaceParamsTest.kt | 56 - .../api/models/AclRetrieveParamsTest.kt | 34 +- .../api/models/ApiKeyCreateParamsTest.kt | 32 + .../api/models/ApiKeyCreateResponseTest.kt | 33 + .../api/models/ApiKeyDeleteParamsTest.kt | 26 + .../api/models/ApiKeyListParamsTest.kt | 53 + .../api/models/ApiKeyRetrieveParamsTest.kt | 26 + .../braintrustdata/api/models/ApiKeyTest.kt | 30 + .../api/models/DatasetCreateParamsTest.kt | 57 +- .../api/models/DatasetDeleteParamsTest.kt | 34 +- .../api/models/DatasetFeedbackParamsTest.kt | 123 +- .../api/models/DatasetFetchParamsTest.kt | 80 +- .../api/models/DatasetFetchPostParamsTest.kt | 133 +- .../models/DatasetFetchPostResponseTest.kt | 20 +- .../api/models/DatasetFetchResponseTest.kt | 20 +- .../api/models/DatasetInsertParamsTest.kt | 183 +- .../api/models/DatasetListParamsTest.kt | 81 +- .../api/models/DatasetReplaceParamsTest.kt | 42 - .../api/models/DatasetRetrieveParamsTest.kt | 36 +- .../api/models/DatasetSummarizeParamsTest.kt | 66 +- .../models/DatasetSummarizeResponseTest.kt | 8 +- .../braintrustdata/api/models/DatasetTest.kt | 10 +- .../api/models/DatasetUpdateParamsTest.kt | 75 +- .../api/models/ExperimentCreateParamsTest.kt | 169 +- .../api/models/ExperimentDeleteParamsTest.kt | 38 +- .../models/ExperimentFeedbackParamsTest.kt | 134 +- .../api/models/ExperimentFetchParamsTest.kt | 84 +- .../models/ExperimentFetchPostParamsTest.kt | 133 +- .../models/ExperimentFetchPostResponseTest.kt | 36 +- .../api/models/ExperimentFetchResponseTest.kt | 36 +- .../api/models/ExperimentInsertParamsTest.kt | 360 +- .../api/models/ExperimentListParamsTest.kt | 81 +- .../api/models/ExperimentReplaceParamsTest.kt | 103 - .../models/ExperimentRetrieveParamsTest.kt | 38 +- .../models/ExperimentSummarizeParamsTest.kt | 72 +- .../models/ExperimentSummarizeResponseTest.kt | 13 +- .../api/models/ExperimentTest.kt | 48 +- .../api/models/ExperimentUpdateParamsTest.kt | 176 +- .../api/models/FunctionCreateParamsTest.kt | 341 + .../api/models/FunctionDeleteParamsTest.kt | 28 + .../api/models/FunctionListParamsTest.kt | 64 + .../api/models/FunctionReplaceParamsTest.kt | 343 + .../api/models/FunctionRetrieveParamsTest.kt | 28 + .../braintrustdata/api/models/FunctionTest.kt | 205 + .../api/models/FunctionUpdateParamsTest.kt | 330 + .../api/models/GroupCreateParamsTest.kt | 69 +- .../api/models/GroupDeleteParamsTest.kt | 34 +- .../api/models/GroupListParamsTest.kt | 73 +- .../api/models/GroupReplaceParamsTest.kt | 69 +- .../api/models/GroupRetrieveParamsTest.kt | 34 +- .../braintrustdata/api/models/GroupTest.kt | 8 +- .../api/models/GroupUpdateParamsTest.kt | 95 +- .../models/OrganizationDeleteParamsTest.kt | 30 + .../api/models/OrganizationListParamsTest.kt | 56 + .../OrganizationMemberUpdateParamsTest.kt | 85 + .../OrganizationMemberUpdateResponseTest.kt | 22 + .../models/OrganizationRetrieveParamsTest.kt | 30 + .../api/models/OrganizationTest.kt | 33 + .../models/OrganizationUpdateParamsTest.kt | 65 + .../api/models/ProjectCreateParamsTest.kt | 44 +- .../api/models/ProjectDeleteParamsTest.kt | 34 +- .../api/models/ProjectListParamsTest.kt | 75 +- .../models/ProjectLogFeedbackParamsTest.kt | 134 +- .../api/models/ProjectLogFetchParamsTest.kt | 84 +- .../models/ProjectLogFetchPostParamsTest.kt | 133 +- .../models/ProjectLogFetchPostResponseTest.kt | 32 +- .../api/models/ProjectLogFetchResponseTest.kt | 32 +- .../api/models/ProjectLogInsertParamsTest.kt | 355 +- .../api/models/ProjectReplaceParamsTest.kt | 32 - .../api/models/ProjectRetrieveParamsTest.kt | 36 +- .../models/ProjectScoreCreateParamsTest.kt | 81 + .../models/ProjectScoreDeleteParamsTest.kt | 30 + .../api/models/ProjectScoreListParamsTest.kt | 59 + .../models/ProjectScoreReplaceParamsTest.kt | 81 + .../models/ProjectScoreRetrieveParamsTest.kt | 30 + .../api/models/ProjectScoreTest.kt | 69 + .../models/ProjectScoreUpdateParamsTest.kt | 90 + .../api/models/ProjectTagCreateParamsTest.kt | 50 + .../api/models/ProjectTagDeleteParamsTest.kt | 30 + .../api/models/ProjectTagListParamsTest.kt | 58 + .../api/models/ProjectTagReplaceParamsTest.kt | 50 + .../models/ProjectTagRetrieveParamsTest.kt | 30 + .../api/models/ProjectTagTest.kt | 32 + .../api/models/ProjectTagUpdateParamsTest.kt | 59 + .../braintrustdata/api/models/ProjectTest.kt | 7 +- .../api/models/ProjectUpdateParamsTest.kt | 82 +- .../api/models/PromptCreateParamsTest.kt | 417 +- .../api/models/PromptDeleteParamsTest.kt | 34 +- .../api/models/PromptFeedbackParamsTest.kt | 86 - .../api/models/PromptListParamsTest.kt | 91 +- .../api/models/PromptReplaceParamsTest.kt | 417 +- .../api/models/PromptRetrieveParamsTest.kt | 34 +- .../braintrustdata/api/models/PromptTest.kt | 104 +- .../api/models/PromptUpdateParamsTest.kt | 412 +- .../api/models/RoleCreateParamsTest.kt | 106 +- .../api/models/RoleDeleteParamsTest.kt | 34 +- .../api/models/RoleListParamsTest.kt | 73 +- .../api/models/RoleReplaceParamsTest.kt | 106 +- .../api/models/RoleRetrieveParamsTest.kt | 34 +- .../com/braintrustdata/api/models/RoleTest.kt | 27 +- .../api/models/RoleUpdateParamsTest.kt | 169 +- .../models/TopLevelHelloWorldParamsTest.kt | 16 +- .../api/models/UserListParamsTest.kt | 85 +- .../api/models/UserRetrieveParamsTest.kt | 34 +- .../com/braintrustdata/api/models/UserTest.kt | 16 +- .../api/models/ViewCreateParamsTest.kt | 119 + .../api/models/ViewDeleteParamsTest.kt | 59 + .../api/models/ViewListParamsTest.kt | 64 + .../api/models/ViewReplaceParamsTest.kt | 119 + .../api/models/ViewRetrieveParamsTest.kt | 59 + .../com/braintrustdata/api/models/ViewTest.kt | 75 + .../api/models/ViewUpdateParamsTest.kt | 130 + .../api/services/ErrorHandlingTest.kt | 47 +- .../api/services/ServiceParamsTest.kt | 9 +- .../api/services/blocking/AclServiceTest.kt | 32 +- .../services/blocking/ApiKeyServiceTest.kt | 79 + .../services/blocking/DatasetServiceTest.kt | 73 +- .../blocking/ExperimentServiceTest.kt | 135 +- .../services/blocking/FunctionServiceTest.kt | 425 ++ .../api/services/blocking/GroupServiceTest.kt | 34 +- .../blocking/OrganizationServiceTest.kt | 86 + .../blocking/ProjectScoreServiceTest.kt | 156 + .../services/blocking/ProjectServiceTest.kt | 35 +- .../blocking/ProjectTagServiceTest.kt | 126 + .../services/blocking/PromptServiceTest.kt | 359 +- .../api/services/blocking/RoleServiceTest.kt | 80 +- .../api/services/blocking/UserServiceTest.kt | 4 +- .../api/services/blocking/ViewServiceTest.kt | 204 + .../organizations/MemberServiceTest.kt | 47 + .../{project => projects}/LogServiceTest.kt | 40 +- .../main/kotlin/braintrust.publish.gradle.kts | 2 +- scripts/mock | 4 +- 396 files changed, 63553 insertions(+), 64139 deletions(-) delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclReplaceParams.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetReplaceParams.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentReplaceParams.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionFeedbackParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectReplaceParams.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptFeedbackParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/client/BraintrustClientTest.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetReplaceParamsTest.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptFeedbackParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/{project => projects}/LogServiceTest.kt (86%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 008e387..71594a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,4 +34,25 @@ jobs: - name: Run lints run: ./scripts/lint + test: + name: test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 17 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index b391081..88dee7a 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -1,6 +1,8 @@ name: Release Doctor on: pull_request: + branches: + - main workflow_dispatch: jobs: diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2aca35a..4208b5c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.5.0" + ".": "0.6.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 96e109f..5b58a35 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 88 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-9eeeeb30b963f3f5672794f8a99ccc3e67d4bb08639514a2c66bc9baf5942a06.yml +configured_endpoints: 87 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-d61f2ff056a756a7e0a176a137c86e1e2e77f51b87420ccc114e2c584c4fa9e5.yml diff --git a/README.md b/README.md index 3b94561..99cc763 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/). ## Documentation -The REST API documentation can be foundĀ [on www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec). +The REST API documentation can be foundĀ on [www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec). --- @@ -84,7 +84,9 @@ then pass that to the `create` method of the `projects` service. import com.braintrustdata.api.models.Project; import com.braintrustdata.api.models.ProjectCreateParams; -ProjectCreateParams params = ProjectCreateParams.builder().build(); +ProjectCreateParams params = ProjectCreateParams.builder() + .name("foobar") + .build(); Project project = client.projects().create(params); ``` diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index b67cbc2..a7ca15a 100644 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -1,31 +1,30 @@ package com.braintrustdata.api.client.okhttp -import com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpClient +import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpRequestBody import com.braintrustdata.api.core.http.HttpResponse -import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.errors.BraintrustIoException +import com.google.common.collect.ListMultimap +import com.google.common.collect.MultimapBuilder import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CompletableFuture -import java.util.concurrent.TimeUnit import okhttp3.Call import okhttp3.Callback -import okhttp3.HttpUrl -import okhttp3.Response -import okhttp3.Request -import okhttp3.RequestBody -import okhttp3.MediaType import okhttp3.Headers +import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Request +import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.Response import okio.BufferedSink class OkHttpClient @@ -34,7 +33,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { val timeout = requestOptions.timeout ?: return okHttpClient - return okHttpClient.newBuilder() + return okHttpClient + .newBuilder() .connectTimeout(timeout) .readTimeout(timeout) .writeTimeout(timeout) @@ -76,7 +76,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val override fun onFailure(call: Call, e: IOException) { future.completeExceptionally(BraintrustIoException("Request failed", e)) } - }) + } + ) return future } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index 3d5cf52..c9a8091 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -4,27 +4,8 @@ package com.braintrustdata.api.client -import java.time.Duration -import java.util.Base64 -import java.util.Optional -import java.util.concurrent.CompletableFuture -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.blocking.* -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface BraintrustClient { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index fc52cca..2057fbb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -4,27 +4,8 @@ package com.braintrustdata.api.client -import java.time.Duration -import java.util.Base64 -import java.util.Optional -import java.util.concurrent.CompletableFuture -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.async.* -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface BraintrustClientAsync { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index 6ca3ac1..18ad02b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -2,29 +2,17 @@ package com.braintrustdata.api.client -import java.time.Duration -import java.util.Base64 -import java.util.Optional -import java.util.concurrent.CompletableFuture import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.async.* -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler -class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOptions, ) : BraintrustClientAsync { +class BraintrustClientAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : BraintrustClientAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -34,7 +22,9 @@ class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOpt private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) } - private val experiments: ExperimentServiceAsync by lazy { ExperimentServiceAsyncImpl(clientOptions) } + private val experiments: ExperimentServiceAsync by lazy { + ExperimentServiceAsyncImpl(clientOptions) + } private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } @@ -48,15 +38,21 @@ class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOpt private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptions) } - private val projectScores: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptions) } + private val projectScores: ProjectScoreServiceAsync by lazy { + ProjectScoreServiceAsyncImpl(clientOptions) + } - private val projectTags: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptions) } + private val projectTags: ProjectTagServiceAsync by lazy { + ProjectTagServiceAsyncImpl(clientOptions) + } private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptions) } private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptions) } - private val organizations: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptions) } + private val organizations: OrganizationServiceAsync by lazy { + OrganizationServiceAsyncImpl(clientOptions) + } private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index 86a0107..c7bde57 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -2,29 +2,17 @@ package com.braintrustdata.api.client -import java.time.Duration -import java.util.Base64 -import java.util.Optional -import java.util.concurrent.CompletableFuture import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.blocking.* -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler -class BraintrustClientImpl constructor(private val clientOptions: ClientOptions, ) : BraintrustClient { +class BraintrustClientImpl +constructor( + private val clientOptions: ClientOptions, +) : BraintrustClient { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -48,7 +36,9 @@ class BraintrustClientImpl constructor(private val clientOptions: ClientOptions, private val users: UserService by lazy { UserServiceImpl(clientOptions) } - private val projectScores: ProjectScoreService by lazy { ProjectScoreServiceImpl(clientOptions) } + private val projectScores: ProjectScoreService by lazy { + ProjectScoreServiceImpl(clientOptions) + } private val projectTags: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptions) } @@ -56,7 +46,9 @@ class BraintrustClientImpl constructor(private val clientOptions: ClientOptions, private val views: ViewService by lazy { ViewServiceImpl(clientOptions) } - private val organizations: OrganizationService by lazy { OrganizationServiceImpl(clientOptions) } + private val organizations: OrganizationService by lazy { + OrganizationServiceImpl(clientOptions) + } private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt index a197b7f..a38e39b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt @@ -13,9 +13,13 @@ import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer import kotlin.reflect.KClass -abstract class BaseDeserializer(type: KClass) : StdDeserializer(type.java), ContextualDeserializer { +abstract class BaseDeserializer(type: KClass) : + StdDeserializer(type.java), ContextualDeserializer { - override fun createContextual(context: DeserializationContext, property: BeanProperty?): JsonDeserializer { + override fun createContextual( + context: DeserializationContext, + property: BeanProperty? + ): JsonDeserializer { return this } @@ -25,7 +29,11 @@ abstract class BaseDeserializer(type: KClass) : StdDeserializer(t protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference, validate: (T) -> Unit = {}): T? { + protected fun ObjectCodec.tryDeserialize( + node: JsonNode, + type: TypeReference, + validate: (T) -> Unit = {} + ): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { @@ -35,7 +43,11 @@ abstract class BaseDeserializer(type: KClass) : StdDeserializer(t } } - protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType, validate: (T) -> Unit = {}): T? { + protected fun ObjectCodec.tryDeserialize( + node: JsonNode, + type: JavaType, + validate: (T) -> Unit = {} + ): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 6ba9683..254d218 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -2,36 +2,32 @@ package com.braintrustdata.api.core +import com.braintrustdata.api.core.http.HttpClient +import com.braintrustdata.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.Multimap -import com.google.common.collect.ListMultimap import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.time.Clock -import java.util.Base64 -import com.braintrustdata.api.core.http.HttpClient -import com.braintrustdata.api.core.http.RetryingHttpClient - -class ClientOptions private constructor( - @get:JvmName("httpClient") val httpClient: HttpClient, - @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, - @get:JvmName("clock") val clock: Clock, - @get:JvmName("baseUrl") val baseUrl: String, - @get:JvmName("apiKey") val apiKey: String, - @get:JvmName("headers") val headers: ListMultimap, - @get:JvmName("queryParams") val queryParams: ListMultimap, - @get:JvmName("responseValidation") val responseValidation: Boolean, +class ClientOptions +private constructor( + @get:JvmName("httpClient") val httpClient: HttpClient, + @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + @get:JvmName("clock") val clock: Clock, + @get:JvmName("baseUrl") val baseUrl: String, + @get:JvmName("apiKey") val apiKey: String, + @get:JvmName("headers") val headers: ListMultimap, + @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("responseValidation") val responseValidation: Boolean, ) { companion object { - const val PRODUCTION_URL = "https://api.braintrustdata.com" + const val PRODUCTION_URL = "https://api.braintrust.dev" - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() - @JvmStatic - fun fromEnv(): ClientOptions = builder().fromEnv().build() + @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } class Builder { @@ -46,21 +42,13 @@ class ClientOptions private constructor( private var maxRetries: Int = 2 private var apiKey: String? = null - fun httpClient(httpClient: HttpClient) = apply { - this.httpClient = httpClient - } + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } - fun jsonMapper(jsonMapper: JsonMapper) = apply { - this.jsonMapper = jsonMapper - } + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } - fun baseUrl(baseUrl: String) = apply { - this.baseUrl = baseUrl - } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } - fun clock(clock: Clock) = apply { - this.clock = clock - } + fun clock(clock: Clock) = apply { this.clock = clock } fun headers(headers: Map>) = apply { this.headers.clear() @@ -79,9 +67,7 @@ class ClientOptions private constructor( headers.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.headers.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.headers.put(name, mutableListOf()) } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -100,64 +86,50 @@ class ClientOptions private constructor( queryParams.forEach(this::putQueryParams) } - fun removeQueryParam(name: String) = apply { - this.queryParams.put(name, mutableListOf()) - } + fun removeQueryParam(name: String) = apply { this.queryParams.put(name, mutableListOf()) } fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } - fun maxRetries(maxRetries: Int) = apply { - this.maxRetries = maxRetries - } + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - fun apiKey(apiKey: String) = apply { - this.apiKey = apiKey - } + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } - fun fromEnv() = apply { - System.getenv("BRAINTRUST_API_KEY")?.let { - apiKey(it) - } - } + fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } fun build(): ClientOptions { - checkNotNull(httpClient) { - "`httpClient` is required but was not set" - } - checkNotNull(apiKey) { - "`apiKey` is required but was not set" - } - - val headers = ArrayListMultimap.create() - val queryParams = ArrayListMultimap.create() - headers.put("X-Stainless-Lang", "java") - headers.put("X-Stainless-Arch", getOsArch()) - headers.put("X-Stainless-OS", getOsName()) - headers.put("X-Stainless-OS-Version", getOsVersion()) - headers.put("X-Stainless-Package-Version", getPackageVersion()) - headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - if (!apiKey.isNullOrEmpty()) { - headers.put("Authorization", "Bearer ${apiKey}") - } - this.headers.forEach(headers::replaceValues) - this.queryParams.forEach(queryParams::replaceValues) - - return ClientOptions( - RetryingHttpClient.builder() - .httpClient(httpClient!!) - .clock(clock) - .maxRetries(maxRetries) - .build(), - jsonMapper ?: jsonMapper(), - clock, - baseUrl, - apiKey!!, - headers.toUnmodifiable(), - queryParams.toUnmodifiable(), - responseValidation, - ) + checkNotNull(httpClient) { "`httpClient` is required but was not set" } + checkNotNull(apiKey) { "`apiKey` is required but was not set" } + + val headers = ArrayListMultimap.create() + val queryParams = ArrayListMultimap.create() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + if (!apiKey.isNullOrEmpty()) { + headers.put("Authorization", "Bearer ${apiKey}") + } + this.headers.forEach(headers::replaceValues) + this.queryParams.forEach(queryParams::replaceValues) + + return ClientOptions( + RetryingHttpClient.builder() + .httpClient(httpClient!!) + .clock(clock) + .maxRetries(maxRetries) + .build(), + jsonMapper ?: jsonMapper(), + clock, + baseUrl, + apiKey!!, + headers.toUnmodifiable(), + queryParams.toUnmodifiable(), + responseValidation, + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt index e04d139..1c59eee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt @@ -9,9 +9,12 @@ fun getOsArch(): String { return when (osArch) { null -> "unknown" - "i386", "x32", "x86" -> "x32" - "amd64", "x86_64" -> "x64" - "arm"-> "arm" + "i386", + "x32", + "x86" -> "x32" + "amd64", + "x86_64" -> "x64" + "arm" -> "arm" "aarch64" -> "arm64" else -> "other:${osArch}" } @@ -36,7 +39,7 @@ fun getOsVersion(): String { } fun getPackageVersion(): String { - return Properties::class.java.`package`.implementationVersion ?: "unknown"; + return Properties::class.java.`package`.implementationVersion ?: "unknown" } fun getJavaVersion(): String { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index 775a14c..7a8c8b2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -31,9 +31,7 @@ private constructor( this.responseValidation = responseValidation } - fun timeout(timeout: Duration) = apply { - this.timeout = timeout - } + fun timeout(timeout: Duration) = apply { this.timeout = timeout } fun build(): RequestOptions { return RequestOptions(responseValidation, timeout) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 1b7b195..dd23bef 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -2,10 +2,10 @@ package com.braintrustdata.api.core +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.google.common.collect.ImmutableListMultimap import com.google.common.collect.ListMultimap import com.google.common.collect.Multimaps -import com.braintrustdata.api.errors.BraintrustInvalidDataException import java.util.Collections @JvmSynthetic @@ -48,10 +48,10 @@ internal fun ListMultimap.toUnmodifiable(): ListMultimap { internal fun ListMultimap.getRequiredHeader(header: String): String { val value = entries() - .stream() - .filter { entry -> entry.key.equals(header, ignoreCase = true) } - .map { entry -> entry.value } - .findFirst() + .stream() + .filter { entry -> entry.key.equals(header, ignoreCase = true) } + .map { entry -> entry.value } + .findFirst() if (!value.isPresent) { throw BraintrustInvalidDataException("Could not find $header header") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 843db19..9ede4db 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -1,12 +1,12 @@ package com.braintrustdata.api.core +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JacksonAnnotationsInside import com.fasterxml.jackson.annotation.JsonAutoDetect import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.BeanProperty @@ -17,8 +17,6 @@ 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.databind.deser.ContextualDeserializer -import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.node.JsonNodeType.ARRAY import com.fasterxml.jackson.databind.node.JsonNodeType.BINARY import com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN @@ -29,15 +27,13 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer -import java.util.Optional +import java.nio.charset.Charset import java.util.Objects -import java.io.ByteArrayOutputStream +import java.util.Optional import org.apache.hc.core5.http.ContentType -import java.nio.charset.Charset -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(using = JsonField.Deserializer::class) -sealed class JsonField { +sealed class JsonField { fun isMissing(): Boolean = this is JsonMissing @@ -50,9 +46,9 @@ sealed class JsonField { } /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned - * by the API then this method will return an empty `Optional`, otherwise the - * returned `Optional` is given a `JsonValue`. + * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API + * then this method will return an empty `Optional`, otherwise the returned `Optional` is given + * a `JsonValue`. */ fun asUnknown(): Optional = when (this) { @@ -127,13 +123,12 @@ sealed class JsonField { is JsonValue -> accept(visitor as JsonValue.Visitor) } - interface Visitor: JsonValue.Visitor { + interface Visitor : JsonValue.Visitor { fun visitKnown(value: T): R = visitDefault() } companion object { - @JvmStatic - fun of(value: T): JsonField = KnownValue.of(value) + @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) @JvmStatic fun ofNullable(value: T?): JsonField = @@ -160,11 +155,8 @@ sealed class JsonField { } override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> { - return type?.let { - tryDeserialize(node, type) - }?.let { - of(it) - } ?: JsonValue.fromJsonNode(node) + return type?.let { tryDeserialize(node, type) }?.let { of(it) } + ?: JsonValue.fromJsonNode(node) } override fun getNullValue(context: DeserializationContext): JsonField<*> { @@ -174,11 +166,11 @@ sealed class JsonField { } @JsonDeserialize(using = JsonValue.Deserializer::class) -sealed class JsonValue: JsonField() { +sealed class JsonValue : JsonField() { - fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) - fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) fun accept(visitor: Visitor): R = when (this) { @@ -193,12 +185,19 @@ sealed class JsonValue: JsonField() { interface Visitor { fun visitNull(): R = visitDefault() + fun visitMissing(): R = visitDefault() + fun visitBoolean(value: Boolean): R = visitDefault() + fun visitNumber(value: Number): R = visitDefault() + fun visitString(value: String): R = visitDefault() + fun visitArray(values: List): R = visitDefault() + fun visitObject(values: Map): R = visitDefault() + fun visitDefault(): R { throw RuntimeException("Unexpected value") } @@ -224,8 +223,12 @@ sealed class JsonValue: JsonField() { BOOLEAN -> JsonBoolean.of(node.booleanValue()) NUMBER -> JsonNumber.of(node.numberValue()) STRING -> JsonString.of(node.textValue()) - ARRAY -> JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) - OBJECT -> JsonObject.of(node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap()) + ARRAY -> + JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> + JsonObject.of( + node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() + ) BINARY, POJO, null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") @@ -243,7 +246,10 @@ sealed class JsonValue: JsonField() { } } -class KnownValue private constructor(@com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T) : JsonField() { +class KnownValue +private constructor( + @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T +) : JsonField() { override fun equals(other: Any?): Boolean { if (this === other) { @@ -258,7 +264,7 @@ class KnownValue private constructor(@com.fasterxml.jackson.annotation. override fun toString() = value.toString() companion object { - @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) + @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) } } @@ -273,11 +279,14 @@ class JsonMissing : JsonValue() { @JvmStatic fun of() = INSTANCE } - class Serializer: BaseSerializer(JsonMissing::class) { - override fun serialize(value: JsonMissing, generator: JsonGenerator, provider: SerializerProvider) { + class Serializer : BaseSerializer(JsonMissing::class) { + override fun serialize( + value: JsonMissing, + generator: JsonGenerator, + provider: SerializerProvider + ) { throw RuntimeException("JsonMissing cannot be serialized") } - } } @@ -378,9 +387,7 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator - @JvmStatic - fun of(values: List) = JsonArray(values.toUnmodifiable()) + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toUnmodifiable()) } } @@ -417,18 +424,18 @@ private constructor( ) annotation class ExcludeMissing - @JacksonAnnotationsInside @JsonAutoDetect( getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE) + fieldVisibility = Visibility.NONE +) annotation class NoAutoDetect - -class MultipartFormValue internal constructor( +class MultipartFormValue +internal constructor( val name: String, val value: T, val contentType: ContentType, @@ -439,16 +446,20 @@ class MultipartFormValue internal constructor( override fun hashCode(): Int { if (hashCode == 0) { - hashCode = Objects.hash( - name, contentType, filename, when (value) { - is ByteArray -> value.contentHashCode() - is String -> value - is Boolean -> value - is Long -> value - is Double -> value - else -> value?.hashCode() - } - ) + hashCode = + Objects.hash( + name, + contentType, + filename, + when (value) { + is ByteArray -> value.contentHashCode() + is String -> value + is Boolean -> value + is Long -> value + is Double -> value + else -> value?.hashCode() + } + ) } return hashCode } @@ -459,7 +470,8 @@ class MultipartFormValue internal constructor( other as MultipartFormValue<*> - if (name != other.name || contentType != other.contentType || filename != other.filename) return false + if (name != other.name || contentType != other.contentType || filename != other.filename) + return false return when { value is ByteArray && other.value is ByteArray -> value contentEquals other.value @@ -471,10 +483,11 @@ class MultipartFormValue internal constructor( return "MultipartFormValue(name='$name', contentType=$contentType, filename=$filename, value=${valueToString()})" } - private fun valueToString(): String = when (value) { - is ByteArray -> "ByteArray of size ${value.size}" - else -> value.toString() - } + private fun valueToString(): String = + when (value) { + is ByteArray -> "ByteArray of size ${value.size}" + else -> value.toString() + } companion object { internal fun fromString( @@ -484,27 +497,27 @@ class MultipartFormValue internal constructor( ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromBoolean( - name: String, - value: Boolean, - contentType: ContentType, + name: String, + value: Boolean, + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromLong( - name: String, - value: Long, - contentType: ContentType, + name: String, + value: Long, + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromDouble( - name: String, - value: Double, - contentType: ContentType, + name: String, + value: Double, + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) - internal fun fromEnum( - name: String, - value: T, - contentType: ContentType + internal fun fromEnum( + name: String, + value: T, + contentType: ContentType ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromByteArray( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt index 3f9e001..c10ab40 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt @@ -1,14 +1,14 @@ package com.braintrustdata.api.core.http -import com.google.common.collect.ListMultimap -import java.io.Closeable -import java.io.InputStream import java.io.IOException +import java.io.InputStream import java.io.OutputStream +import java.lang.AutoCloseable +import java.util.Optional -interface BinaryResponseContent : Closeable { +interface BinaryResponseContent : AutoCloseable { - fun contentType(): String? + fun contentType(): Optional fun body(): InputStream diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index f016ed6..f416304 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -1,10 +1,10 @@ package com.braintrustdata.api.core.http -import java.io.Closeable -import java.util.concurrent.CompletableFuture import com.braintrustdata.api.core.RequestOptions +import java.lang.AutoCloseable +import java.util.concurrent.CompletableFuture -interface HttpClient : Closeable { +interface HttpClient : AutoCloseable { fun execute( request: HttpRequest, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index 6431e07..f4ba383 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -1,11 +1,10 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.core.toUnmodifiable import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap import com.google.common.collect.Multimap import com.google.common.collect.MultimapBuilder -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.RequestOptions class HttpRequest private constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt index 54f9629..e5c7df3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt @@ -1,10 +1,10 @@ package com.braintrustdata.api.core.http -import java.io.Closeable import java.io.IOException import java.io.OutputStream +import java.lang.AutoCloseable -interface HttpRequestBody : Closeable { +interface HttpRequestBody : AutoCloseable { @Throws(IOException::class) fun writeTo(outputStream: OutputStream) @@ -13,10 +13,11 @@ interface HttpRequestBody : Closeable { fun contentLength(): Long /** - * Determines if a request can be repeated in a meaningful way, for example before doing a retry. + * Determines if a request can be repeated in a meaningful way, for example before doing a + * retry. * - * The most typical case when a request can't be retried is if the request body is being streamed. In this case the - * body data isn't available on subsequent attempts. + * The most typical case when a request can't be retried is if the request body is being + * streamed. In this case the body data isn't available on subsequent attempts. */ fun repeatable(): Boolean diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt index 6363509..333dda6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt @@ -1,10 +1,10 @@ package com.braintrustdata.api.core.http import com.google.common.collect.ListMultimap -import java.io.Closeable import java.io.InputStream +import java.lang.AutoCloseable -interface HttpResponse : Closeable { +interface HttpResponse : AutoCloseable { fun statusCode(): Int diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 3f7966b..73fa01c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -2,9 +2,9 @@ package com.braintrustdata.api.core.http -import com.google.common.util.concurrent.MoreExecutors -import com.braintrustdata.api.errors.BraintrustIoException import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustIoException +import com.google.common.util.concurrent.MoreExecutors import java.io.IOException import java.time.Clock import java.time.Duration @@ -24,15 +24,15 @@ import kotlin.math.pow class RetryingHttpClient private constructor( - private val httpClient: HttpClient, - private val clock: Clock, - private val maxRetries: Int, - private val idempotencyHeader: String?, + private val httpClient: HttpClient, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, ) : HttpClient { override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) @@ -44,29 +44,29 @@ private constructor( while (true) { val response = - try { - val response = httpClient.execute(request, requestOptions) - if (++retries > maxRetries || !shouldRetry(response)) { - return response - } - - response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t - } + try { + val response = httpClient.execute(request, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } - null + response + } catch (t: Throwable) { + if (++retries > maxRetries || !shouldRetry(t)) { + throw t } + null + } + val backoffMillis = getRetryBackoffMillis(retries, response) Thread.sleep(backoffMillis.toMillis()) } } override fun executeAsync( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): CompletableFuture { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.executeAsync(request, requestOptions) @@ -78,31 +78,31 @@ private constructor( fun wrap(future: CompletableFuture): CompletableFuture { return future - .handleAsync( - fun( - response: HttpResponse?, - throwable: Throwable? - ): CompletableFuture { - if (response != null) { - if (++retries > maxRetries || !shouldRetry(response)) { - return CompletableFuture.completedFuture(response) - } - } else { - if (++retries > maxRetries || !shouldRetry(throwable!!)) { - val failedFuture = CompletableFuture() - failedFuture.completeExceptionally(throwable) - return failedFuture - } - } - - val backoffMillis = getRetryBackoffMillis(retries, response) - return sleepAsync(backoffMillis.toMillis()).thenCompose { - wrap(httpClient.executeAsync(request, requestOptions)) - } - }, - MoreExecutors.directExecutor() - ) - .thenCompose(Function.identity()) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable? + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffMillis = getRetryBackoffMillis(retries, response) + return sleepAsync(backoffMillis.toMillis()).thenCompose { + wrap(httpClient.executeAsync(request, requestOptions)) + } + }, + MoreExecutors.directExecutor() + ) + .thenCompose(Function.identity()) } return wrap(httpClient.executeAsync(request, requestOptions)) @@ -158,30 +158,38 @@ private constructor( private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After - response?.headers()?.let { headers -> - headers.get("Retry-After-Ms").getOrNull(0)?.toFloatOrNull()?.times(TimeUnit.MILLISECONDS.toNanos(1)) + response + ?.headers() + ?.let { headers -> + headers + .get("Retry-After-Ms") + .getOrNull(0) + ?.toFloatOrNull() + ?.times(TimeUnit.MILLISECONDS.toNanos(1)) ?: headers.get("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) - ?: try { - ChronoUnit.MILLIS.between( - OffsetDateTime.now(clock), - OffsetDateTime.parse( - retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME - ) + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME ) - } catch (e: DateTimeParseException) { - null - } + ) + } catch (e: DateTimeParseException) { + null + } } - }?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter } - } + ?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable + // amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter + } + } // Apply exponential backoff, but not more than the max. val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) @@ -195,12 +203,12 @@ private constructor( private fun sleepAsync(millis: Long): CompletableFuture { val future = CompletableFuture() TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis ) return future } @@ -209,8 +217,7 @@ private constructor( private val TIMER = Timer("RetryingHttpClient", true) - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -229,11 +236,11 @@ private constructor( fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } fun build(): HttpClient = - RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, - clock, - maxRetries, - idempotencyHeader, - ) + RetryingHttpClient( + checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + clock, + maxRetries, + idempotencyHeader, + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt index 560a870..aef5942 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt @@ -4,9 +4,10 @@ import com.google.common.collect.ListMultimap class BadRequestException constructor( - headers: ListMultimap, - private val error: BraintrustError, + headers: ListMultimap, + private val error: BraintrustError, ) : BraintrustServiceException(headers, "${error}") { override fun statusCode(): Int = 400 + fun error(): BraintrustError = error } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index 300edaf..e845c58 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -2,45 +2,42 @@ package com.braintrustdata.api.errors +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime import java.util.Objects -import java.util.UUID -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect @JsonDeserialize(builder = BraintrustError.Builder::class) @NoAutoDetect -class BraintrustError constructor(private val additionalProperties: Map, ) { +class BraintrustError +constructor( + private val additionalProperties: Map, +) { - @JsonAnyGetter - fun additionalProperties(): Map = additionalProperties + @JsonAnyGetter fun additionalProperties(): Map = additionalProperties fun toBuilder() = Builder() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is BraintrustError && - this.additionalProperties == other.additionalProperties + return other is BraintrustError && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(additionalProperties) + return Objects.hash(additionalProperties) } override fun toString() = "BraintrustError{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt index 78a326d..d1fdfde 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt @@ -2,4 +2,5 @@ package com.braintrustdata.api.errors class BraintrustInvalidDataException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : + BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt index b7e0d93..6fb793a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt @@ -2,4 +2,5 @@ package com.braintrustdata.api.errors class BraintrustIoException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : + BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt index 45106b2..99a6ed5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt @@ -5,10 +5,11 @@ import com.google.common.collect.ListMultimap abstract class BraintrustServiceException @JvmOverloads constructor( - private val headers: ListMultimap, - message: String? = null, - cause: Throwable? = null + private val headers: ListMultimap, + message: String? = null, + cause: Throwable? = null ) : BraintrustException(message, cause) { abstract fun statusCode(): Int + fun headers(): ListMultimap = headers } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt index 1a1f37d..9b10b43 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt @@ -4,10 +4,11 @@ import com.google.common.collect.ListMultimap class InternalServerException constructor( - private val statusCode: Int, - headers: ListMultimap, - private val error: BraintrustError, + private val statusCode: Int, + headers: ListMultimap, + private val error: BraintrustError, ) : BraintrustServiceException(headers, "${error}") { override fun statusCode(): Int = statusCode + fun error(): BraintrustError = error } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt index e020443..7939d7e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt @@ -4,9 +4,10 @@ import com.google.common.collect.ListMultimap class NotFoundException constructor( - headers: ListMultimap, - private val error: BraintrustError, + headers: ListMultimap, + private val error: BraintrustError, ) : BraintrustServiceException(headers, "${error}") { override fun statusCode(): Int = 404 + fun error(): BraintrustError = error } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt index 46fc8d7..f7fb822 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt @@ -4,9 +4,10 @@ import com.google.common.collect.ListMultimap class PermissionDeniedException constructor( - headers: ListMultimap, - private val error: BraintrustError, + headers: ListMultimap, + private val error: BraintrustError, ) : BraintrustServiceException(headers, "${error}") { override fun statusCode(): Int = 403 + fun error(): BraintrustError = error } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt index 4929e76..394df1c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt @@ -4,9 +4,10 @@ import com.google.common.collect.ListMultimap class RateLimitException constructor( - headers: ListMultimap, - private val error: BraintrustError, + headers: ListMultimap, + private val error: BraintrustError, ) : BraintrustServiceException(headers, "${error}") { override fun statusCode(): Int = 429 + fun error(): BraintrustError = error } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt index 2721718..d54fcfc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt @@ -4,9 +4,10 @@ import com.google.common.collect.ListMultimap class UnauthorizedException constructor( - headers: ListMultimap, - private val error: BraintrustError, + headers: ListMultimap, + private val error: BraintrustError, ) : BraintrustServiceException(headers, "${error}") { override fun statusCode(): Int = 401 + fun error(): BraintrustError = error } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt index f9cc712..c131779 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt @@ -3,8 +3,12 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class UnexpectedStatusCodeException -constructor(private val statusCode: Int, headers: ListMultimap, private val body: String) : - BraintrustServiceException(headers, "Unexpected status code: ${statusCode}") { +constructor( + private val statusCode: Int, + headers: ListMultimap, + private val body: String +) : BraintrustServiceException(headers, "Unexpected status code: ${statusCode}") { override fun statusCode(): Int = statusCode + fun body() = body } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt index 3d3ff3e..420f322 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt @@ -4,9 +4,10 @@ import com.google.common.collect.ListMultimap class UnprocessableEntityException constructor( - headers: ListMultimap, - private val error: BraintrustError, + headers: ListMultimap, + private val error: BraintrustError, ) : BraintrustServiceException(headers, "${error}") { override fun statusCode(): Int = 422 + fun error(): BraintrustError = error } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt index 04b7017..6a4a72b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt @@ -2,64 +2,48 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on + * a project, they will also have read permissions on any experiment, dataset, etc. created within + * that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @JsonDeserialize(builder = Acl.Builder::class) @NoAutoDetect -class Acl private constructor( - private val id: JsonField, - private val objectType: JsonField, - private val objectId: JsonField, - private val userId: JsonField, - private val groupId: JsonField, - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val roleId: JsonField, - private val _objectOrgId: JsonField, - private val created: JsonField, - private val additionalProperties: Map, - +class Acl +private constructor( + private val id: JsonField, + private val objectType: JsonField, + private val objectId: JsonField, + private val userId: JsonField, + private val groupId: JsonField, + private val permission: JsonField, + private val restrictObjectType: JsonField, + private val roleId: JsonField, + private val _objectOrgId: JsonField, + private val created: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -70,39 +54,34 @@ class Acl private constructor( fun id(): String = id.getRequired("id") /** The object type that the ACL applies to */ - fun objectType(): Optional = Optional.ofNullable(objectType.getNullable("object_type")) + fun objectType(): Optional = + Optional.ofNullable(objectType.getNullable("object_type")) /** The id of the object the ACL applies to */ fun objectId(): String = objectId.getRequired("object_id") /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** The organization the ACL's referred object belongs to */ @@ -112,69 +91,43 @@ class Acl private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Unique identifier for the acl */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType() = objectType + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId() = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ - @JsonProperty("group_id") - @ExcludeMissing - fun _groupId() = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId() = groupId - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - @JsonProperty("permission") - @ExcludeMissing - fun _permission() = permission + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("permission") @ExcludeMissing fun _permission() = permission /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType() = restrictObjectType - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - @JsonProperty("role_id") - @ExcludeMissing - fun _roleId() = roleId + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId() = roleId /** The organization the ACL's referred object belongs to */ - @JsonProperty("_object_org_id") - @ExcludeMissing - fun __objectOrgId() = _objectOrgId + @JsonProperty("_object_org_id") @ExcludeMissing fun __objectOrgId() = _objectOrgId /** Date of acl creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created @JsonAnyGetter @ExcludeMissing @@ -182,66 +135,67 @@ class Acl private constructor( fun validate(): Acl = apply { if (!validated) { - id() - objectType() - objectId() - userId() - groupId() - permission() - restrictObjectType() - roleId() - _objectOrgId() - created() - validated = true + id() + objectType() + objectId() + userId() + groupId() + permission() + restrictObjectType() + roleId() + _objectOrgId() + created() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Acl && - this.id == other.id && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.userId == other.userId && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this._objectOrgId == other._objectOrgId && - this.created == other.created && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Acl && + this.id == other.id && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.userId == other.userId && + this.groupId == other.groupId && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.roleId == other.roleId && + this._objectOrgId == other._objectOrgId && + this.created == other.created && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - _objectOrgId, - created, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + objectType, + objectId, + userId, + groupId, + permission, + restrictObjectType, + roleId, + _objectOrgId, + created, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" + override fun toString() = + "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -277,11 +231,7 @@ class Acl private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the acl */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) @@ -289,9 +239,7 @@ class Acl private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) @@ -299,67 +247,54 @@ class Acl private constructor( /** The id of the object the ACL applies to */ @JsonProperty("object_id") @ExcludeMissing - fun objectId(objectId: JsonField) = apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: String) = userId(JsonField.of(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: String) = groupId(JsonField.of(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ @JsonProperty("group_id") @ExcludeMissing - fun groupId(groupId: JsonField) = apply { - this.groupId = groupId - } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission) = permission(JsonField.of(permission)) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { this.permission = permission } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = restrictObjectType(JsonField.of(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType) = + restrictObjectType(JsonField.of(restrictObjectType)) /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing @@ -368,20 +303,16 @@ class Acl private constructor( } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(roleId: String) = roleId(JsonField.of(roleId)) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("role_id") @ExcludeMissing - fun roleId(roleId: JsonField) = apply { - this.roleId = roleId - } + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** The organization the ACL's referred object belongs to */ fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) @@ -399,9 +330,7 @@ class Acl private constructor( /** Date of acl creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -417,33 +346,36 @@ class Acl private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Acl = Acl( - id, - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - _objectOrgId, - created, - additionalProperties.toUnmodifiable(), - ) + fun build(): Acl = + Acl( + id, + objectType, + objectId, + userId, + groupId, + permission, + restrictObjectType, + roleId, + _objectOrgId, + created, + additionalProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -506,51 +438,55 @@ class Acl private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Permission + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && - this.value == other.value + return other is Permission && this.value == other.value } override fun hashCode() = value.hashCode() @@ -601,45 +537,49 @@ class Acl private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class RestrictObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && - this.value == other.value + return other is RestrictObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -702,35 +642,37 @@ class Acl private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt index 37354a5..05787a5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt @@ -2,52 +2,34 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class AclCreateParams constructor( - private val objectId: String, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class AclCreateParams +constructor( + private val objectId: String, + private val objectType: ObjectType?, + private val groupId: String?, + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val roleId: String?, + private val userId: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun objectId(): String = objectId @@ -66,94 +48,80 @@ class AclCreateParams constructor( @JvmSynthetic internal fun getBody(): AclCreateBody { - return AclCreateBody( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalBodyProperties, - ) + return AclCreateBody( + objectId, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @JsonDeserialize(builder = AclCreateBody.Builder::class) @NoAutoDetect - class AclCreateBody internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalProperties: Map, - + class AclCreateBody + internal constructor( + private val objectId: String?, + private val objectType: ObjectType?, + private val groupId: String?, + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val roleId: String?, + private val userId: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - fun objectId(): String? = objectId + @JsonProperty("object_id") fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(): ObjectType? = objectType - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - @JsonProperty("group_id") - fun groupId(): String? = groupId + @JsonProperty("object_type") fun objectType(): ObjectType? = objectType /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("permission") - fun permission(): Permission? = permission + @JsonProperty("group_id") fun groupId(): String? = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("permission") fun permission(): Permission? = permission /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") fun restrictObjectType(): RestrictObjectType? = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") - fun roleId(): String? = roleId + @JsonProperty("role_id") fun roleId(): String? = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - @JsonProperty("user_id") - fun userId(): String? = userId + @JsonProperty("user_id") fun userId(): String? = userId @JsonAnyGetter @ExcludeMissing @@ -162,43 +130,44 @@ class AclCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclCreateBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AclCreateBody && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.groupId == other.groupId && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.roleId == other.roleId && + this.userId == other.userId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + objectId, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -226,37 +195,28 @@ class AclCreateParams constructor( /** The id of the object the ACL applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ @JsonProperty("group_id") - fun groupId(groupId: String) = apply { - this.groupId = groupId - } + fun groupId(groupId: String) = apply { this.groupId = groupId } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { - this.permission = permission - } + fun permission(permission: Permission) = apply { this.permission = permission } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just + * the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { @@ -267,19 +227,13 @@ class AclCreateParams constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - @JsonProperty("role_id") - fun roleId(roleId: String) = apply { - this.roleId = roleId - } + @JsonProperty("role_id") fun roleId(roleId: String) = apply { this.roleId = roleId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - @JsonProperty("user_id") - fun userId(userId: String) = apply { - this.userId = userId - } + @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -295,18 +249,17 @@ class AclCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): AclCreateBody = AclCreateBody( - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toUnmodifiable(), - ) + fun build(): AclCreateBody = + AclCreateBody( + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toUnmodifiable(), + ) } } @@ -317,46 +270,46 @@ class AclCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclCreateParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is AclCreateParams && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.groupId == other.groupId && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.roleId == other.roleId && + this.userId == other.userId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + objectId, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -388,54 +341,38 @@ class AclCreateParams constructor( } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - fun groupId(groupId: String) = apply { - this.groupId = groupId - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun permission(permission: Permission) = apply { - this.permission = permission - } + fun groupId(groupId: String) = apply { this.groupId = groupId } + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: Permission) = apply { this.permission = permission } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { this.restrictObjectType = restrictObjectType } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: String) = apply { - this.roleId = roleId - } + fun roleId(roleId: String) = apply { this.roleId = roleId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: String) = apply { - this.userId = userId - } + fun userId(userId: String) = apply { this.userId = userId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -475,9 +412,7 @@ class AclCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -488,38 +423,40 @@ class AclCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): AclCreateParams = AclCreateParams( - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): AclCreateParams = + AclCreateParams( + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -582,51 +519,55 @@ class AclCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Permission + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && - this.value == other.value + return other is Permission && this.value == other.value } override fun hashCode() = value.hashCode() @@ -677,45 +618,49 @@ class AclCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class RestrictObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && - this.value == other.value + return other is RestrictObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -778,35 +723,37 @@ class AclCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 1d79792..6ffaefd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class AclDeleteParams constructor( - private val aclId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class AclDeleteParams +constructor( + private val aclId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun aclId(): String = aclId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class AclDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclDeleteParams && - this.aclId == other.aclId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is AclDeleteParams && + this.aclId == other.aclId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - aclId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + aclId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "AclDeleteParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "AclDeleteParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class AclDeleteParams constructor( } /** Acl id */ - fun aclId(aclId: String) = apply { - this.aclId = aclId - } + fun aclId(aclId: String) = apply { this.aclId = aclId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class AclDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class AclDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): AclDeleteParams = AclDeleteParams( - checkNotNull(aclId) { - "`aclId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): AclDeleteParams = + AclDeleteParams( + checkNotNull(aclId) { "`aclId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index 3aec859..b3c8096 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -2,79 +2,77 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.AclService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.services.blocking.AclService -class AclListPage private constructor(private val aclsService: AclService, private val params: AclListParams, private val response: Response, ) { +class AclListPage +private constructor( + private val aclsService: AclService, + private val params: AclListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclListPage && - this.aclsService == other.aclsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is AclListPage && + this.aclsService == other.aclsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - aclsService, - params, - response, - ) + return Objects.hash( + aclsService, + params, + response, + ) } - override fun toString() = "AclListPage{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = + "AclListPage{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AclListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + AclListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { aclsService.list(it) } + return getNextPageParams().map { aclsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +80,21 @@ class AclListPage private constructor(private val aclsService: AclService, priva companion object { @JvmStatic - fun of(aclsService: AclService, params: AclListParams, response: Response) = AclListPage( - aclsService, - params, - response, - ) + fun of(aclsService: AclService, params: AclListParams, response: Response) = + AclListPage( + aclsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +109,33 @@ class AclListPage private constructor(private val aclsService: AclService, priva fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "AclListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "AclListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +163,25 @@ class AclListPage private constructor(private val aclsService: AclService, priva } } - class AutoPager constructor(private val firstPage: AclListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: AclListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index fdb23c3..ec02e5b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -2,83 +2,80 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.AclServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.services.async.AclServiceAsync -class AclListPageAsync private constructor(private val aclsService: AclServiceAsync, private val params: AclListParams, private val response: Response, ) { +class AclListPageAsync +private constructor( + private val aclsService: AclServiceAsync, + private val params: AclListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclListPageAsync && - this.aclsService == other.aclsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is AclListPageAsync && + this.aclsService == other.aclsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - aclsService, - params, - response, - ) + return Objects.hash( + aclsService, + params, + response, + ) } - override fun toString() = "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = + "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AclListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + AclListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - aclsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { aclsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +83,21 @@ class AclListPageAsync private constructor(private val aclsService: AclServiceAs companion object { @JvmStatic - fun of(aclsService: AclServiceAsync, params: AclListParams, response: Response) = AclListPageAsync( - aclsService, - params, - response, - ) + fun of(aclsService: AclServiceAsync, params: AclListParams, response: Response) = + AclListPageAsync( + aclsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +112,33 @@ class AclListPageAsync private constructor(private val aclsService: AclServiceAs fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "AclListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "AclListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +166,32 @@ class AclListPageAsync private constructor(private val aclsService: AclServiceAs } } - class AutoPager constructor(private val firstPage: AclListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: AclListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Acl) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Acl) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt index c0353d0..67a9fac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt @@ -2,51 +2,38 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class AclListParams constructor( - private val objectId: String, - private val objectType: ObjectType?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class AclListParams +constructor( + private val objectId: String, + private val objectType: ObjectType?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun objectId(): String = objectId @@ -63,31 +50,18 @@ class AclListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { - params.put("object_id", listOf(it.toString())) - } - this.objectType.let { - params.put("object_type", listOf(it.toString())) - } - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.objectId.let { params.put("object_id", listOf(it.toString())) } + this.objectType.let { params.put("object_type", listOf(it.toString())) } + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -96,44 +70,44 @@ class AclListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclListParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is AclListParams && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - endingBefore, - ids, - limit, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + objectId, + objectType, + endingBefore, + ids, + limit, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -163,65 +137,49 @@ class AclListParams constructor( } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,9 +219,7 @@ class AclListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -274,37 +230,39 @@ class AclListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): AclListParams = AclListParams( - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - endingBefore, - ids, - limit, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): AclListParams = + AclListParams( + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + endingBefore, + ids, + limit, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -367,103 +325,109 @@ class AclListParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -473,34 +437,38 @@ class AclListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclReplaceParams.kt deleted file mode 100644 index 6593ffb..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclReplaceParams.kt +++ /dev/null @@ -1,739 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* -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.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional - -class AclReplaceParams -constructor( - private val objectId: String, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun objectId(): String = objectId - - fun objectType(): Optional = Optional.ofNullable(objectType) - - fun groupId(): Optional = Optional.ofNullable(groupId) - - fun permission(): Optional = Optional.ofNullable(permission) - - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType) - - fun roleId(): Optional = Optional.ofNullable(roleId) - - fun userId(): Optional = Optional.ofNullable(userId) - - @JvmSynthetic - internal fun getBody(): AclReplaceBody { - return AclReplaceBody( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL. - */ - @JsonDeserialize(builder = AclReplaceBody.Builder::class) - @NoAutoDetect - class AclReplaceBody - internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("group_id") fun groupId(): String? = groupId - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") fun permission(): Permission? = permission - - /** Optionally restricts the permission grant to just the specified object type */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - @JsonProperty("role_id") fun roleId(): String? = roleId - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("user_id") fun userId(): String? = userId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclReplaceBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AclReplaceBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var objectId: String? = null - private var objectType: ObjectType? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null - private var userId: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aclReplaceBody: AclReplaceBody) = apply { - this.objectId = aclReplaceBody.objectId - this.objectType = aclReplaceBody.objectType - this.groupId = aclReplaceBody.groupId - this.permission = aclReplaceBody.permission - this.restrictObjectType = aclReplaceBody.restrictObjectType - this.roleId = aclReplaceBody.roleId - this.userId = aclReplaceBody.userId - additionalProperties(aclReplaceBody.additionalProperties) - } - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } - - /** Optionally restricts the permission grant to just the specified object type */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { - this.restrictObjectType = restrictObjectType - } - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - @JsonProperty("role_id") fun roleId(roleId: String) = apply { this.roleId = roleId } - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): AclReplaceBody = - AclReplaceBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toUnmodifiable(), - ) - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclReplaceParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "AclReplaceParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var objectId: String? = null - private var objectType: ObjectType? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null - private var userId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aclReplaceParams: AclReplaceParams) = apply { - this.objectId = aclReplaceParams.objectId - this.objectType = aclReplaceParams.objectType - this.groupId = aclReplaceParams.groupId - this.permission = aclReplaceParams.permission - this.restrictObjectType = aclReplaceParams.restrictObjectType - this.roleId = aclReplaceParams.roleId - this.userId = aclReplaceParams.userId - additionalQueryParams(aclReplaceParams.additionalQueryParams) - additionalHeaders(aclReplaceParams.additionalHeaders) - additionalBodyProperties(aclReplaceParams.additionalBodyProperties) - } - - /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: String) = apply { this.groupId = groupId } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission) = apply { this.permission = permission } - - /** Optionally restricts the permission grant to just the specified object type */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { - this.restrictObjectType = restrictObjectType - } - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun roleId(roleId: String) = apply { this.roleId = roleId } - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: String) = apply { this.userId = userId } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): AclReplaceParams = - AclReplaceParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } - - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) - - @JvmField val PROJECT = ObjectType(JsonField.of("project")) - - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) - - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) - - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - @JvmField val PROJECT_SCORE = ObjectType(JsonField.of("project_score")) - - @JvmField val PROJECT_TAG = ObjectType(JsonField.of("project_tag")) - - @JvmField val GROUP = ObjectType(JsonField.of("group")) - - @JvmField val ROLE = ObjectType(JsonField.of("role")) - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - PROJECT_SCORE, - PROJECT_TAG, - GROUP, - ROLE, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - PROJECT_SCORE, - PROJECT_TAG, - GROUP, - ROLE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_SCORE -> Value.PROJECT_SCORE - PROJECT_TAG -> Value.PROJECT_TAG - GROUP -> Value.GROUP - ROLE -> Value.ROLE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_SCORE -> Known.PROJECT_SCORE - PROJECT_TAG -> Known.PROJECT_TAG - GROUP -> Known.GROUP - ROLE -> Known.ROLE - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Permission && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val CREATE = Permission(JsonField.of("create")) - - @JvmField val READ = Permission(JsonField.of("read")) - - @JvmField val UPDATE = Permission(JsonField.of("update")) - - @JvmField val DELETE = Permission(JsonField.of("delete")) - - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) - - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) - - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) - - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_acls")) - - @JvmStatic fun of(value: String) = Permission(JsonField.of(value)) - } - - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - enum class Value { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RestrictObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) - - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) - - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) - - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) - - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) - - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) - - @JvmField val PROJECT_SCORE = RestrictObjectType(JsonField.of("project_score")) - - @JvmField val PROJECT_TAG = RestrictObjectType(JsonField.of("project_tag")) - - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) - - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) - - @JvmStatic fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - PROJECT_SCORE, - PROJECT_TAG, - GROUP, - ROLE, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - PROJECT_SCORE, - PROJECT_TAG, - GROUP, - ROLE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_SCORE -> Value.PROJECT_SCORE - PROJECT_TAG -> Value.PROJECT_TAG - GROUP -> Value.GROUP - ROLE -> Value.ROLE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_SCORE -> Known.PROJECT_SCORE - PROJECT_TAG -> Known.PROJECT_TAG - GROUP -> Known.GROUP - ROLE -> Known.ROLE - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 9c1eb33..8d33204 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class AclRetrieveParams constructor( - private val aclId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class AclRetrieveParams +constructor( + private val aclId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun aclId(): String = aclId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class AclRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclRetrieveParams && - this.aclId == other.aclId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is AclRetrieveParams && + this.aclId == other.aclId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - aclId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + aclId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "AclRetrieveParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "AclRetrieveParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class AclRetrieveParams constructor( } /** Acl id */ - fun aclId(aclId: String) = apply { - this.aclId = aclId - } + fun aclId(aclId: String) = apply { this.aclId = aclId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class AclRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class AclRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): AclRetrieveParams = AclRetrieveParams( - checkNotNull(aclId) { - "`aclId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): AclRetrieveParams = + AclRetrieveParams( + checkNotNull(aclId) { "`aclId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index b0f397c..14eed08 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -2,48 +2,31 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ApiKey.Builder::class) @NoAutoDetect -class ApiKey private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val previewName: JsonField, - private val userId: JsonField, - private val orgId: JsonField, - private val additionalProperties: Map, - +class ApiKey +private constructor( + private val id: JsonField, + private val created: JsonField, + private val name: JsonField, + private val previewName: JsonField, + private val userId: JsonField, + private val orgId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -68,33 +51,21 @@ class ApiKey private constructor( fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) /** Unique identifier for the api key */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Date of api key creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Name of the api key */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("preview_name") - @ExcludeMissing - fun _previewName() = previewName + @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName /** Unique identifier for the user */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId @JsonAnyGetter @ExcludeMissing @@ -102,54 +73,55 @@ class ApiKey private constructor( fun validate(): ApiKey = apply { if (!validated) { - id() - created() - name() - previewName() - userId() - orgId() - validated = true + id() + created() + name() + previewName() + userId() + orgId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKey && - this.id == other.id && - this.created == other.created && - this.name == other.name && - this.previewName == other.previewName && - this.userId == other.userId && - this.orgId == other.orgId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ApiKey && + this.id == other.id && + this.created == other.created && + this.name == other.name && + this.previewName == other.previewName && + this.userId == other.userId && + this.orgId == other.orgId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - created, - name, - previewName, - userId, - orgId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + created, + name, + previewName, + userId, + orgId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" + override fun toString() = + "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -177,11 +149,7 @@ class ApiKey private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Date of api key creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -189,9 +157,7 @@ class ApiKey private constructor( /** Date of api key creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) @@ -199,17 +165,13 @@ class ApiKey private constructor( /** Name of the api key */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) @JsonProperty("preview_name") @ExcludeMissing - fun previewName(previewName: JsonField) = apply { - this.previewName = previewName - } + fun previewName(previewName: JsonField) = apply { this.previewName = previewName } /** Unique identifier for the user */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -217,9 +179,7 @@ class ApiKey private constructor( /** Unique identifier for the user */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -227,9 +187,7 @@ class ApiKey private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -245,14 +203,15 @@ class ApiKey private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ApiKey = ApiKey( - id, - created, - name, - previewName, - userId, - orgId, - additionalProperties.toUnmodifiable(), - ) + fun build(): ApiKey = + ApiKey( + id, + created, + name, + previewName, + userId, + orgId, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index c64d4d0..e5d0f3b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -2,47 +2,25 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ApiKeyCreateParams constructor( - private val name: String, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ApiKeyCreateParams +constructor( + private val name: String, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -51,36 +29,37 @@ class ApiKeyCreateParams constructor( @JvmSynthetic internal fun getBody(): ApiKeyCreateBody { - return ApiKeyCreateBody( - name, - orgName, - additionalBodyProperties, - ) + return ApiKeyCreateBody( + name, + orgName, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ApiKeyCreateBody.Builder::class) @NoAutoDetect - class ApiKeyCreateBody internal constructor(private val name: String?, private val orgName: String?, private val additionalProperties: Map, ) { + class ApiKeyCreateBody + internal constructor( + private val name: String?, + private val orgName: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ - @JsonProperty("org_name") - fun orgName(): String? = orgName + @JsonProperty("org_name") fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -89,33 +68,34 @@ class ApiKeyCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyCreateBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ApiKeyCreateBody && + this.name == other.name && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -132,20 +112,15 @@ class ApiKeyCreateParams constructor( } /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -161,13 +136,12 @@ class ApiKeyCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ApiKeyCreateBody = ApiKeyCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): ApiKeyCreateBody = + ApiKeyCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -178,36 +152,36 @@ class ApiKeyCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyCreateParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ApiKeyCreateParams && + this.name == other.name && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -229,18 +203,14 @@ class ApiKeyCreateParams constructor( } /** Name of the api key. Does not have to be unique */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -280,9 +250,7 @@ class ApiKeyCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -293,18 +261,18 @@ class ApiKeyCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ApiKeyCreateParams = ApiKeyCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ApiKeyCreateParams = + ApiKeyCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt index b9f8840..9f4b74f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt @@ -2,49 +2,32 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ApiKeyCreateResponse.Builder::class) @NoAutoDetect -class ApiKeyCreateResponse private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val previewName: JsonField, - private val userId: JsonField, - private val orgId: JsonField, - private val key: JsonField, - private val additionalProperties: Map, - +class ApiKeyCreateResponse +private constructor( + private val id: JsonField, + private val created: JsonField, + private val name: JsonField, + private val previewName: JsonField, + private val userId: JsonField, + private val orgId: JsonField, + private val key: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -72,38 +55,24 @@ class ApiKeyCreateResponse private constructor( fun key(): String = key.getRequired("key") /** Unique identifier for the api key */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Date of api key creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Name of the api key */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("preview_name") - @ExcludeMissing - fun _previewName() = previewName + @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName /** Unique identifier for the user */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") - @ExcludeMissing - fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key() = key @JsonAnyGetter @ExcludeMissing @@ -111,57 +80,58 @@ class ApiKeyCreateResponse private constructor( fun validate(): ApiKeyCreateResponse = apply { if (!validated) { - id() - created() - name() - previewName() - userId() - orgId() - key() - validated = true + id() + created() + name() + previewName() + userId() + orgId() + key() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyCreateResponse && - this.id == other.id && - this.created == other.created && - this.name == other.name && - this.previewName == other.previewName && - this.userId == other.userId && - this.orgId == other.orgId && - this.key == other.key && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ApiKeyCreateResponse && + this.id == other.id && + this.created == other.created && + this.name == other.name && + this.previewName == other.previewName && + this.userId == other.userId && + this.orgId == other.orgId && + this.key == other.key && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - created, - name, - previewName, - userId, - orgId, - key, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + created, + name, + previewName, + userId, + orgId, + key, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ApiKeyCreateResponse{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" + override fun toString() = + "ApiKeyCreateResponse{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -191,11 +161,7 @@ class ApiKeyCreateResponse private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Date of api key creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -203,9 +169,7 @@ class ApiKeyCreateResponse private constructor( /** Date of api key creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) @@ -213,17 +177,13 @@ class ApiKeyCreateResponse private constructor( /** Name of the api key */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) @JsonProperty("preview_name") @ExcludeMissing - fun previewName(previewName: JsonField) = apply { - this.previewName = previewName - } + fun previewName(previewName: JsonField) = apply { this.previewName = previewName } /** Unique identifier for the user */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -231,9 +191,7 @@ class ApiKeyCreateResponse private constructor( /** Unique identifier for the user */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -241,9 +199,7 @@ class ApiKeyCreateResponse private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** The raw API key. It will only be exposed this one time */ fun key(key: String) = key(JsonField.of(key)) @@ -251,9 +207,7 @@ class ApiKeyCreateResponse private constructor( /** The raw API key. It will only be exposed this one time */ @JsonProperty("key") @ExcludeMissing - fun key(key: JsonField) = apply { - this.key = key - } + fun key(key: JsonField) = apply { this.key = key } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -269,15 +223,16 @@ class ApiKeyCreateResponse private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ApiKeyCreateResponse = ApiKeyCreateResponse( - id, - created, - name, - previewName, - userId, - orgId, - key, - additionalProperties.toUnmodifiable(), - ) + fun build(): ApiKeyCreateResponse = + ApiKeyCreateResponse( + id, + created, + name, + previewName, + userId, + orgId, + key, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index 5c9a7e1..8b48e6d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ApiKeyDeleteParams constructor( - private val apiKeyId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ApiKeyDeleteParams +constructor( + private val apiKeyId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun apiKeyId(): String = apiKeyId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class ApiKeyDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyDeleteParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ApiKeyDeleteParams && + this.apiKeyId == other.apiKeyId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + apiKeyId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class ApiKeyDeleteParams constructor( } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { - this.apiKeyId = apiKeyId - } + fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class ApiKeyDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class ApiKeyDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( - checkNotNull(apiKeyId) { - "`apiKeyId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ApiKeyDeleteParams = + ApiKeyDeleteParams( + checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 498a933..6369da7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -2,79 +2,77 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.ApiKeyService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.services.blocking.ApiKeyService -class ApiKeyListPage private constructor(private val apiKeysService: ApiKeyService, private val params: ApiKeyListParams, private val response: Response, ) { +class ApiKeyListPage +private constructor( + private val apiKeysService: ApiKeyService, + private val params: ApiKeyListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyListPage && - this.apiKeysService == other.apiKeysService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ApiKeyListPage && + this.apiKeysService == other.apiKeysService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - apiKeysService, - params, - response, - ) + return Objects.hash( + apiKeysService, + params, + response, + ) } - override fun toString() = "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = + "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { apiKeysService.list(it) } + return getNextPageParams().map { apiKeysService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +80,21 @@ class ApiKeyListPage private constructor(private val apiKeysService: ApiKeyServi companion object { @JvmStatic - fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = ApiKeyListPage( - apiKeysService, - params, - response, - ) + fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = + ApiKeyListPage( + apiKeysService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +109,33 @@ class ApiKeyListPage private constructor(private val apiKeysService: ApiKeyServi fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ApiKeyListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ApiKeyListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +163,25 @@ class ApiKeyListPage private constructor(private val apiKeysService: ApiKeyServi } } - class AutoPager constructor(private val firstPage: ApiKeyListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: ApiKeyListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 29bf221..d874255 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -2,83 +2,80 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.ApiKeyServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.services.async.ApiKeyServiceAsync -class ApiKeyListPageAsync private constructor(private val apiKeysService: ApiKeyServiceAsync, private val params: ApiKeyListParams, private val response: Response, ) { +class ApiKeyListPageAsync +private constructor( + private val apiKeysService: ApiKeyServiceAsync, + private val params: ApiKeyListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyListPageAsync && - this.apiKeysService == other.apiKeysService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ApiKeyListPageAsync && + this.apiKeysService == other.apiKeysService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - apiKeysService, - params, - response, - ) + return Objects.hash( + apiKeysService, + params, + response, + ) } - override fun toString() = "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = + "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - apiKeysService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { apiKeysService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +83,21 @@ class ApiKeyListPageAsync private constructor(private val apiKeysService: ApiKey companion object { @JvmStatic - fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = ApiKeyListPageAsync( - apiKeysService, - params, - response, - ) + fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = + ApiKeyListPageAsync( + apiKeysService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +112,33 @@ class ApiKeyListPageAsync private constructor(private val apiKeysService: ApiKey fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ApiKeyListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ApiKeyListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +166,32 @@ class ApiKeyListPageAsync private constructor(private val apiKeysService: ApiKey } } - class AutoPager constructor(private val firstPage: ApiKeyListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: ApiKeyListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (ApiKey) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (ApiKey) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index aa40964..045d94a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -2,51 +2,35 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ApiKeyListParams constructor( - private val apiKeyName: String?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ApiKeyListParams +constructor( + private val apiKeyName: String?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun apiKeyName(): Optional = Optional.ofNullable(apiKeyName) @@ -63,31 +47,18 @@ class ApiKeyListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.apiKeyName?.let { - params.put("api_key_name", listOf(it.toString())) - } - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.apiKeyName?.let { params.put("api_key_name", listOf(it.toString())) } + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -96,44 +67,44 @@ class ApiKeyListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyListParams && - this.apiKeyName == other.apiKeyName && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ApiKeyListParams && + this.apiKeyName == other.apiKeyName && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + apiKeyName, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -163,65 +134,49 @@ class ApiKeyListParams constructor( } /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: String) = apply { - this.apiKeyName = apiKeyName - } + fun apiKeyName(apiKeyName: String) = apply { this.apiKeyName = apiKeyName } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,9 +216,7 @@ class ApiKeyListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -274,87 +227,93 @@ class ApiKeyListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ApiKeyListParams = ApiKeyListParams( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ApiKeyListParams = + ApiKeyListParams( + apiKeyName, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -364,34 +323,38 @@ class ApiKeyListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 1b38c08..3480deb2c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class ApiKeyRetrieveParams constructor( - private val apiKeyId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ApiKeyRetrieveParams +constructor( + private val apiKeyId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun apiKeyId(): String = apiKeyId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class ApiKeyRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyRetrieveParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ApiKeyRetrieveParams && + this.apiKeyId == other.apiKeyId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + apiKeyId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class ApiKeyRetrieveParams constructor( } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { - this.apiKeyId = apiKeyId - } + fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class ApiKeyRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class ApiKeyRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( - checkNotNull(apiKeyId) { - "`apiKeyId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ApiKeyRetrieveParams = + ApiKeyRetrieveParams( + checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 80079d2..39624b7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -2,50 +2,33 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Dataset.Builder::class) @NoAutoDetect -class Dataset private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val created: JsonField, - private val deletedAt: JsonField, - private val userId: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, - +class Dataset +private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val created: JsonField, + private val deletedAt: JsonField, + private val userId: JsonField, + private val metadata: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -62,13 +45,15 @@ class Dataset private constructor( fun name(): String = name.getRequired("name") /** Textual description of the dataset */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Date of dataset creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Identifies the user who created the dataset */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) @@ -77,44 +62,28 @@ class Dataset private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Unique identifier for the dataset */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Textual description of the dataset */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** Date of dataset creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Date of dataset deletion, or null if the dataset is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt /** Identifies the user who created the dataset */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata @JsonAnyGetter @ExcludeMissing @@ -122,60 +91,61 @@ class Dataset private constructor( fun validate(): Dataset = apply { if (!validated) { - id() - projectId() - name() - description() - created() - deletedAt() - userId() - metadata().map { it.validate() } - validated = true + id() + projectId() + name() + description() + created() + deletedAt() + userId() + metadata().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Dataset && - this.id == other.id && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.created == other.created && - this.deletedAt == other.deletedAt && - this.userId == other.userId && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Dataset && + this.id == other.id && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.created == other.created && + this.deletedAt == other.deletedAt && + this.userId == other.userId && + this.metadata == other.metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - projectId, - name, - description, - created, - deletedAt, - userId, - metadata, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + projectId, + name, + description, + created, + deletedAt, + userId, + metadata, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = + "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -207,11 +177,7 @@ class Dataset private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the dataset */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -219,9 +185,7 @@ class Dataset private constructor( /** Unique identifier for the project that the dataset belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) @@ -229,9 +193,7 @@ class Dataset private constructor( /** Name of the dataset. Within a project, dataset names are unique */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the dataset */ fun description(description: String) = description(JsonField.of(description)) @@ -239,9 +201,7 @@ class Dataset private constructor( /** Textual description of the dataset */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** Date of dataset creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -249,9 +209,7 @@ class Dataset private constructor( /** Date of dataset creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of dataset deletion, or null if the dataset is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -259,9 +217,7 @@ class Dataset private constructor( /** Date of dataset deletion, or null if the dataset is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Identifies the user who created the dataset */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -269,9 +225,7 @@ class Dataset private constructor( /** Identifies the user who created the dataset */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -279,9 +233,7 @@ class Dataset private constructor( /** User-controlled metadata about the dataset */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -297,23 +249,27 @@ class Dataset private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Dataset = Dataset( - id, - projectId, - name, - description, - created, - deletedAt, - userId, - metadata, - additionalProperties.toUnmodifiable(), - ) + fun build(): Dataset = + Dataset( + id, + projectId, + name, + description, + created, + deletedAt, + userId, + metadata, + additionalProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the dataset */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -325,34 +281,32 @@ class Dataset private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 6f8ac3f..27919b2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -2,48 +2,26 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class DatasetCreateParams constructor( - private val name: String, - private val description: String?, - private val projectId: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class DatasetCreateParams +constructor( + private val name: String, + private val description: String?, + private val projectId: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -54,43 +32,38 @@ class DatasetCreateParams constructor( @JvmSynthetic internal fun getBody(): DatasetCreateBody { - return DatasetCreateBody( - name, - description, - projectId, - additionalBodyProperties, - ) + return DatasetCreateBody( + name, + description, + projectId, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = DatasetCreateBody.Builder::class) @NoAutoDetect - class DatasetCreateBody internal constructor( - private val name: String?, - private val description: String?, - private val projectId: String?, - private val additionalProperties: Map, - + class DatasetCreateBody + internal constructor( + private val name: String?, + private val description: String?, + private val projectId: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Textual description of the dataset */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId @JsonAnyGetter @ExcludeMissing @@ -99,35 +72,36 @@ class DatasetCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetCreateBody && - this.name == other.name && - this.description == other.description && - this.projectId == other.projectId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetCreateBody && + this.name == other.name && + this.description == other.description && + this.projectId == other.projectId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - description, - projectId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + projectId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "DatasetCreateBody{name=$name, description=$description, projectId=$projectId, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetCreateBody{name=$name, description=$description, projectId=$projectId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,22 +120,15 @@ class DatasetCreateParams constructor( } /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Textual description of the dataset */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Unique identifier for the project that the dataset belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -177,14 +144,13 @@ class DatasetCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetCreateBody = DatasetCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - projectId, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetCreateBody = + DatasetCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + description, + projectId, + additionalProperties.toUnmodifiable(), + ) } } @@ -195,38 +161,38 @@ class DatasetCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetCreateParams && - this.name == other.name && - this.description == other.description && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetCreateParams && + this.name == other.name && + this.description == other.description && + this.projectId == other.projectId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - projectId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + projectId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetCreateParams{name=$name, description=$description, projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetCreateParams{name=$name, description=$description, projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -250,19 +216,13 @@ class DatasetCreateParams constructor( } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Textual description of the dataset */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -302,9 +262,7 @@ class DatasetCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -315,19 +273,19 @@ class DatasetCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetCreateParams = DatasetCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - projectId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetCreateParams = + DatasetCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + description, + projectId, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 4221411..29ce38b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class DatasetDeleteParams constructor( - private val datasetId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class DatasetDeleteParams +constructor( + private val datasetId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class DatasetDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetDeleteParams && - this.datasetId == other.datasetId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetDeleteParams && + this.datasetId == other.datasetId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetDeleteParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetDeleteParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class DatasetDeleteParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class DatasetDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class DatasetDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): DatasetDeleteParams = DatasetDeleteParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): DatasetDeleteParams = + DatasetDeleteParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index b7d700e..ace1923 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -2,47 +2,28 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* +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.databind.annotation.JsonDeserialize +import java.util.Objects -class DatasetFeedbackParams constructor( - private val datasetId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class DatasetFeedbackParams +constructor( + private val datasetId: String, + private val feedback: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -51,31 +32,32 @@ class DatasetFeedbackParams constructor( @JvmSynthetic internal fun getBody(): DatasetFeedbackBody { - return DatasetFeedbackBody(feedback, additionalBodyProperties) + return DatasetFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetFeedbackBody.Builder::class) @NoAutoDetect - class DatasetFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { + class DatasetFeedbackBody + internal constructor( + private val feedback: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** A list of dataset feedback items */ - @JsonProperty("feedback") - fun feedback(): List? = feedback + @JsonProperty("feedback") fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -84,28 +66,28 @@ class DatasetFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is DatasetFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties + return other is DatasetFeedbackBody && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode } - override fun toString() = "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -121,9 +103,7 @@ class DatasetFeedbackParams constructor( /** A list of dataset feedback items */ @JsonProperty("feedback") - fun feedback(feedback: List) = apply { - this.feedback = feedback - } + fun feedback(feedback: List) = apply { this.feedback = feedback } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -139,9 +119,12 @@ class DatasetFeedbackParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetFeedbackBody = DatasetFeedbackBody(checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) + fun build(): DatasetFeedbackBody = + DatasetFeedbackBody( + checkNotNull(feedback) { "`feedback` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) } } @@ -152,36 +135,36 @@ class DatasetFeedbackParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFeedbackParams && - this.datasetId == other.datasetId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetFeedbackParams && + this.datasetId == other.datasetId && + this.feedback == other.feedback && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + feedback, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -203,9 +186,7 @@ class DatasetFeedbackParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset feedback items */ fun feedback(feedback: List) = apply { @@ -214,9 +195,7 @@ class DatasetFeedbackParams constructor( } /** A list of dataset feedback items */ - fun addFeedback(feedback: Feedback) = apply { - this.feedback.add(feedback) - } + fun addFeedback(feedback: Feedback) = apply { this.feedback.add(feedback) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,9 +235,7 @@ class DatasetFeedbackParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -269,57 +246,52 @@ class DatasetFeedbackParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetFeedbackParams = DatasetFeedbackParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetFeedbackParams = + DatasetFeedbackParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + checkNotNull(feedback) { "`feedback` is required but was not set" } + .toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Feedback.Builder::class) @NoAutoDetect - class Feedback private constructor( - private val id: String?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - + class Feedback + private constructor( + private val id: String?, + private val comment: String?, + private val metadata: Metadata?, + private val source: Source?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** - * The id of the dataset event to log feedback for. This is the row `id` returned - * by `POST /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` */ - @JsonProperty("id") - fun id(): String? = id + @JsonProperty("id") fun id(): String? = id /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") - fun comment(): String? = comment + @JsonProperty("comment") fun comment(): String? = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata + @JsonProperty("metadata") fun metadata(): Metadata? = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(): Source? = source + @JsonProperty("source") fun source(): Source? = source @JsonAnyGetter @ExcludeMissing @@ -328,37 +300,38 @@ class DatasetFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Feedback && + this.id == other.id && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Feedback{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + override fun toString() = + "Feedback{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -379,34 +352,23 @@ class DatasetFeedbackParams constructor( } /** - * The id of the dataset event to log feedback for. This is the row `id` returned - * by `POST /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned by + * `POST /v1/dataset/{dataset_id}/insert` */ - @JsonProperty("id") - fun id(id: String) = apply { - this.id = id - } + @JsonProperty("id") fun id(id: String) = apply { this.id = id } /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") - fun comment(comment: String) = apply { - this.comment = comment - } + @JsonProperty("comment") fun comment(comment: String) = apply { this.comment = comment } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you + * can log it here and access it in the Braintrust UI. */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(source: Source) = apply { - this.source = source - } + @JsonProperty("source") fun source(source: Source) = apply { this.source = source } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -422,24 +384,26 @@ class DatasetFeedbackParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Feedback = Feedback( - checkNotNull(id) { - "`id` is required but was not set" - }, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) + fun build(): Feedback = + Feedback( + checkNotNull(id) { "`id` is required but was not set" }, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -450,27 +414,25 @@ class DatasetFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -492,26 +454,29 @@ class DatasetFeedbackParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } - class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Source + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Source && - this.value == other.value + return other is Source && this.value == other.value } override fun hashCode() = value.hashCode() @@ -542,19 +507,21 @@ class DatasetFeedbackParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } + fun known(): Known = + when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 6179cc6..744f7a2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -2,50 +2,23 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class DatasetFetchParams constructor( - private val datasetId: String, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class DatasetFetchParams +constructor( + private val datasetId: String, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -60,31 +33,22 @@ class DatasetFetchParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.maxRootSpanId?.let { - params.put("max_root_span_id", listOf(it.toString())) - } - this.maxXactId?.let { - params.put("max_xact_id", listOf(it.toString())) - } - this.version?.let { - params.put("version", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } + this.version?.let { params.put("version", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -94,42 +58,42 @@ class DatasetFetchParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchParams && - this.datasetId == other.datasetId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetFetchParams && + this.datasetId == other.datasetId && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -157,72 +121,60 @@ class DatasetFetchParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -262,9 +214,7 @@ class DatasetFetchParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -275,21 +225,21 @@ class DatasetFetchParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): DatasetFetchParams = DatasetFetchParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): DatasetFetchParams = + DatasetFetchParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index f3c30b6..a597f97 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -2,52 +2,34 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class DatasetFetchPostParams constructor( - private val datasetId: String, - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class DatasetFetchPostParams +constructor( + private val datasetId: String, + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -66,120 +48,110 @@ class DatasetFetchPostParams constructor( @JvmSynthetic internal fun getBody(): DatasetFetchPostBody { - return DatasetFetchPostBody( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) + return DatasetFetchPostBody( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetFetchPostBody.Builder::class) @NoAutoDetect - class DatasetFetchPostBody internal constructor( - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, - + class DatasetFetchPostBody + internal constructor( + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - fun cursor(): String? = cursor + @JsonProperty("cursor") fun cursor(): String? = cursor /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ - @JsonProperty("filters") - fun filters(): List? = filters + @JsonProperty("filters") fun filters(): List? = filters /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - @JsonProperty("limit") - fun limit(): Long? = limit + @JsonProperty("limit") fun limit(): Long? = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_root_span_id") - fun maxRootSpanId(): String? = maxRootSpanId + @JsonProperty("max_root_span_id") fun maxRootSpanId(): String? = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_xact_id") - fun maxXactId(): String? = maxXactId + @JsonProperty("max_xact_id") fun maxXactId(): String? = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") - fun version(): String? = version + @JsonProperty("version") fun version(): String? = version @JsonAnyGetter @ExcludeMissing @@ -188,41 +160,42 @@ class DatasetFetchPostParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetFetchPostBody && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -247,92 +220,76 @@ class DatasetFetchPostParams constructor( } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - fun cursor(cursor: String) = apply { - this.cursor = cursor - } + @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters + * are supported, but we may add more in the future */ @JsonProperty("filters") - fun filters(filters: List) = apply { - this.filters = filters - } + fun filters(filters: List) = apply { this.filters = filters } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ - @JsonProperty("limit") - fun limit(limit: Long) = apply { - this.limit = limit - } + @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ - @JsonProperty("version") - fun version(version: String) = apply { - this.version = version - } + @JsonProperty("version") fun version(version: String) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -348,15 +305,16 @@ class DatasetFetchPostParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetFetchPostBody = DatasetFetchPostBody( - cursor, - filters?.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetFetchPostBody = + DatasetFetchPostBody( + cursor, + filters?.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toUnmodifiable(), + ) } } @@ -367,46 +325,46 @@ class DatasetFetchPostParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchPostParams && - this.datasetId == other.datasetId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetFetchPostParams && + this.datasetId == other.datasetId && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -438,24 +396,20 @@ class DatasetFetchPostParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: String) = apply { - this.cursor = cursor - } + fun cursor(cursor: String) = apply { this.cursor = cursor } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ fun filters(filters: List) = apply { this.filters.clear() @@ -463,75 +417,63 @@ class DatasetFetchPostParams constructor( } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ - fun addFilter(filter: Filter) = apply { - this.filters.add(filter) - } + fun addFilter(filter: Filter) = apply { this.filters.add(filter) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -571,9 +513,7 @@ class DatasetFetchPostParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -584,65 +524,60 @@ class DatasetFetchPostParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetFetchPostParams = DatasetFetchPostParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - cursor, - if(filters.size == 0) null else filters.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetFetchPostParams = + DatasetFetchPostParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + cursor, + if (filters.size == 0) null else filters.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** - * A path-lookup filter describes an equality comparison against a specific - * sub-field in the event row. For instance, if you wish to filter on the value of - * `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` and `value="hello"` + * A path-lookup filter describes an equality comparison against a specific sub-field in the + * event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": + * {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` */ @JsonDeserialize(builder = Filter.Builder::class) @NoAutoDetect - class Filter private constructor( - private val type: Type?, - private val path: List?, - private val value: JsonValue?, - private val additionalProperties: Map, - + class Filter + private constructor( + private val type: Type?, + private val path: List?, + private val value: JsonValue?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - fun type(): Type? = type + @JsonProperty("type") fun type(): Type? = type /** - * List of fields describing the path to the value to be checked against. For - * instance, if you wish to filter on the value of `c` in - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For instance, if + * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` */ - @JsonProperty("path") - fun path(): List? = path + @JsonProperty("path") fun path(): List? = path /** - * The value to compare equality-wise against the event value at the specified - * `path`. The value must be a "primitive", that is, any JSON-serializable object - * except for objects and arrays. For instance, if you wish to filter on the value - * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `value="hello"` + * The value to compare equality-wise against the event value at the specified `path`. The + * value must be a "primitive", that is, any JSON-serializable object except for objects and + * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` */ - @JsonProperty("value") - fun value(): JsonValue? = value + @JsonProperty("value") fun value(): JsonValue? = value @JsonAnyGetter @ExcludeMissing @@ -651,35 +586,36 @@ class DatasetFetchPostParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Filter && + this.type == other.type && + this.path == other.path && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + path, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -698,32 +634,22 @@ class DatasetFetchPostParams constructor( } /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - fun type(type: Type) = apply { - this.type = type - } + @JsonProperty("type") fun type(type: Type) = apply { this.type = type } /** - * List of fields describing the path to the value to be checked against. For - * instance, if you wish to filter on the value of `c` in - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For instance, + * if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": + * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` */ - @JsonProperty("path") - fun path(path: List) = apply { - this.path = path - } + @JsonProperty("path") fun path(path: List) = apply { this.path = path } /** - * The value to compare equality-wise against the event value at the specified - * `path`. The value must be a "primitive", that is, any JSON-serializable object - * except for objects and arrays. For instance, if you wish to filter on the value - * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `value="hello"` + * The value to compare equality-wise against the event value at the specified `path`. + * The value must be a "primitive", that is, any JSON-serializable object except for + * objects and arrays. For instance, if you wish to filter on the value of "input.a.b.c" + * in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` */ - @JsonProperty("value") - fun value(value: JsonValue) = apply { - this.value = value - } + @JsonProperty("value") fun value(value: JsonValue) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -739,30 +665,29 @@ class DatasetFetchPostParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Filter = Filter( - checkNotNull(type) { - "`type` is required but was not set" - }, - checkNotNull(path) { - "`path` is required but was not set" - }.toUnmodifiable(), - value, - additionalProperties.toUnmodifiable(), - ) + fun build(): Filter = + Filter( + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(path) { "`path` is required but was not set" }.toUnmodifiable(), + value, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -785,15 +710,17 @@ class DatasetFetchPostParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + PATH_LOOKUP -> Value.PATH_LOOKUP + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PATH_LOOKUP -> Known.PATH_LOOKUP + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt index fa8e12d..cd4cfe0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt @@ -2,40 +2,28 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = DatasetFetchPostResponse.Builder::class) @NoAutoDetect -class DatasetFetchPostResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { +class DatasetFetchPostResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { private var validated: Boolean = false @@ -47,25 +35,21 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events() = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -73,42 +57,43 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField fun validate(): DatasetFetchPostResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchPostResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetFetchPostResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "DatasetFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -130,29 +115,25 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { - this.events = events - } + fun events(events: JsonField>) = apply { this.events = events } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String) = cursor(JsonField.of(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -168,29 +149,30 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetFetchPostResponse = DatasetFetchPostResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetFetchPostResponse = + DatasetFetchPostResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Event.Builder::class) @NoAutoDetect - class Event private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val datasetId: JsonField, - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val additionalProperties: Map, - + class Event + private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val datasetId: JsonField, + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val spanId: JsonField, + private val rootSpanId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -198,16 +180,15 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField private var hashCode: Int = 0 /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -221,8 +202,7 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField fun datasetId(): String = datasetId.getRequired("dataset_id") /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ fun input(): JsonValue = input @@ -233,11 +213,11 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField fun expected(): JsonValue = expected /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -245,10 +225,9 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") @@ -256,84 +235,59 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun _datasetId() = datasetId + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId() = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId /** The `span_id` of the root of the trace this dataset event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId @JsonAnyGetter @ExcludeMissing @@ -341,69 +295,70 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField fun validate(): Event = apply { if (!validated) { - id() - _xactId() - created() - projectId() - datasetId() - input() - expected() - metadata().map { it.validate() } - tags() - spanId() - rootSpanId() - validated = true + id() + _xactId() + created() + projectId() + datasetId() + input() + expected() + metadata().map { it.validate() } + tags() + spanId() + rootSpanId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.datasetId == other.datasetId && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.spanId == other.spanId && - this.rootSpanId == other.rootSpanId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Event && + this.id == other.id && + this._xactId == other._xactId && + this.created == other.created && + this.projectId == other.projectId && + this.datasetId == other.datasetId && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.spanId == other.spanId && + this.rootSpanId == other.rootSpanId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags, - spanId, - rootSpanId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + _xactId, + created, + projectId, + datasetId, + input, + expected, + metadata, + tags, + spanId, + rootSpanId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Event{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" + override fun toString() = + "Event{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -438,40 +393,34 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -479,9 +428,7 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField /** The timestamp the dataset event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -489,9 +436,7 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField /** Unique identifier for the project that the dataset belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) @@ -499,9 +444,7 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField /** Unique identifier for the dataset */ @JsonProperty("dataset_id") @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** * The argument that uniquely define an input case (an arbitrary, JSON serializable @@ -509,9 +452,7 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -519,31 +460,27 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -551,29 +488,23 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for + * full details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for + * full details on tracing */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** The `span_id` of the root of the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) @@ -581,9 +512,7 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField /** The `span_id` of the root of the trace this dataset event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -599,32 +528,36 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField this.additionalProperties.putAll(additionalProperties) } - fun build(): Event = Event( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - spanId, - rootSpanId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Event = + Event( + id, + _xactId, + created, + projectId, + datasetId, + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + spanId, + rootSpanId, + additionalProperties.toUnmodifiable(), + ) } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -636,34 +569,32 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -685,9 +616,10 @@ class DatasetFetchPostResponse private constructor(private val events: JsonField this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt index 302afb6..518716a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt @@ -2,40 +2,28 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = DatasetFetchResponse.Builder::class) @NoAutoDetect -class DatasetFetchResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { +class DatasetFetchResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { private var validated: Boolean = false @@ -47,25 +35,21 @@ class DatasetFetchResponse private constructor(private val events: JsonField = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events() = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -73,42 +57,43 @@ class DatasetFetchResponse private constructor(private val events: JsonField>) = apply { - this.events = events - } + fun events(events: JsonField>) = apply { this.events = events } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String) = cursor(JsonField.of(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -168,29 +149,30 @@ class DatasetFetchResponse private constructor(private val events: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val datasetId: JsonField, - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val additionalProperties: Map, - + class Event + private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val datasetId: JsonField, + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val spanId: JsonField, + private val rootSpanId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -198,16 +180,15 @@ class DatasetFetchResponse private constructor(private val events: JsonField = Optional.ofNullable(metadata.getNullable("metadata")) @@ -245,10 +225,9 @@ class DatasetFetchResponse private constructor(private val events: JsonField> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") @@ -256,84 +235,59 @@ class DatasetFetchResponse private constructor(private val events: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -479,9 +428,7 @@ class DatasetFetchResponse private constructor(private val events: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -489,9 +436,7 @@ class DatasetFetchResponse private constructor(private val events: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) @@ -499,9 +444,7 @@ class DatasetFetchResponse private constructor(private val events: JsonField) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** * The argument that uniquely define an input case (an arbitrary, JSON serializable @@ -509,9 +452,7 @@ class DatasetFetchResponse private constructor(private val events: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -551,29 +488,23 @@ class DatasetFetchResponse private constructor(private val events: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for + * full details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for + * full details on tracing */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** The `span_id` of the root of the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) @@ -581,9 +512,7 @@ class DatasetFetchResponse private constructor(private val events: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -599,32 +528,36 @@ class DatasetFetchResponse private constructor(private val events: JsonField, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -636,34 +569,32 @@ class DatasetFetchResponse private constructor(private val events: JsonField) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 635ab75..64a774f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -2,47 +2,38 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class DatasetInsertParams constructor( - private val datasetId: String, - private val events: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class DatasetInsertParams +constructor( + private val datasetId: String, + private val events: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -51,31 +42,32 @@ class DatasetInsertParams constructor( @JvmSynthetic internal fun getBody(): DatasetInsertBody { - return DatasetInsertBody(events, additionalBodyProperties) + return DatasetInsertBody(events, additionalBodyProperties) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetInsertBody.Builder::class) @NoAutoDetect - class DatasetInsertBody internal constructor(private val events: List?, private val additionalProperties: Map, ) { + class DatasetInsertBody + internal constructor( + private val events: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** A list of dataset events to insert */ - @JsonProperty("events") - fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -84,28 +76,28 @@ class DatasetInsertParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is DatasetInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties + return other is DatasetInsertBody && + this.events == other.events && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode } - override fun toString() = "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -120,10 +112,7 @@ class DatasetInsertParams constructor( } /** A list of dataset events to insert */ - @JsonProperty("events") - fun events(events: List) = apply { - this.events = events - } + @JsonProperty("events") fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -139,9 +128,12 @@ class DatasetInsertParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetInsertBody = DatasetInsertBody(checkNotNull(events) { - "`events` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) + fun build(): DatasetInsertBody = + DatasetInsertBody( + checkNotNull(events) { "`events` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) } } @@ -152,36 +144,36 @@ class DatasetInsertParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetInsertParams && - this.datasetId == other.datasetId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetInsertParams && + this.datasetId == other.datasetId && + this.events == other.events && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + events, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -203,9 +195,7 @@ class DatasetInsertParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset events to insert */ fun events(events: List) = apply { @@ -214,9 +204,7 @@ class DatasetInsertParams constructor( } /** A list of dataset events to insert */ - fun addEvent(event: Event) = apply { - this.events.add(event) - } + fun addEvent(event: Event) = apply { this.events.add(event) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,9 +244,7 @@ class DatasetInsertParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -269,143 +255,169 @@ class DatasetInsertParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetInsertParams = DatasetInsertParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - checkNotNull(events) { - "`events` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetInsertParams = + DatasetInsertParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Event.Deserializer::class) @JsonSerialize(using = Event.Serializer::class) - class Event private constructor(private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, private val _json: JsonValue? = null, ) { + class Event + private constructor( + private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, + private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun insertDatasetEventReplace(): Optional = Optional.ofNullable(insertDatasetEventReplace) - fun insertDatasetEventMerge(): Optional = Optional.ofNullable(insertDatasetEventMerge) + fun insertDatasetEventReplace(): Optional = + Optional.ofNullable(insertDatasetEventReplace) + + fun insertDatasetEventMerge(): Optional = + Optional.ofNullable(insertDatasetEventMerge) fun isInsertDatasetEventReplace(): Boolean = insertDatasetEventReplace != null + fun isInsertDatasetEventMerge(): Boolean = insertDatasetEventMerge != null - fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") - fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") + fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = + insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") + + fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = + insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - insertDatasetEventReplace != null -> visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) - insertDatasetEventMerge != null -> visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) - else -> visitor.unknown(_json) - } + return when { + insertDatasetEventReplace != null -> + visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) + insertDatasetEventMerge != null -> + visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) + else -> visitor.unknown(_json) + } } fun validate(): Event = apply { if (!validated) { - if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertDatasetEventReplace?.validate() - insertDatasetEventMerge?.validate() - validated = true + if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { + throw BraintrustInvalidDataException("Unknown Event: $_json") + } + insertDatasetEventReplace?.validate() + insertDatasetEventMerge?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Event && - this.insertDatasetEventReplace == other.insertDatasetEventReplace && - this.insertDatasetEventMerge == other.insertDatasetEventMerge + return other is Event && + this.insertDatasetEventReplace == other.insertDatasetEventReplace && + this.insertDatasetEventMerge == other.insertDatasetEventMerge } override fun hashCode(): Int { - return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) + return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) } override fun toString(): String { - return when { - insertDatasetEventReplace != null -> "Event{insertDatasetEventReplace=$insertDatasetEventReplace}" - insertDatasetEventMerge != null -> "Event{insertDatasetEventMerge=$insertDatasetEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } + return when { + insertDatasetEventReplace != null -> + "Event{insertDatasetEventReplace=$insertDatasetEventReplace}" + insertDatasetEventMerge != null -> + "Event{insertDatasetEventMerge=$insertDatasetEventMerge}" + _json != null -> "Event{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Event") + } } companion object { @JvmStatic - fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = Event(insertDatasetEventReplace = insertDatasetEventReplace) + fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = + Event(insertDatasetEventReplace = insertDatasetEventReplace) @JvmStatic - fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = Event(insertDatasetEventMerge = insertDatasetEventMerge) + fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = + Event(insertDatasetEventMerge = insertDatasetEventMerge) } interface Visitor { - fun visitInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace): T + fun visitInsertDatasetEventReplace( + insertDatasetEventReplace: InsertDatasetEventReplace + ): T fun visitInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") + throw BraintrustInvalidDataException("Unknown Event: $json") } } class Deserializer : BaseDeserializer(Event::class) { override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Event(insertDatasetEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Event(insertDatasetEventMerge = it, _json = json) - } - - return Event(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Event(insertDatasetEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Event(insertDatasetEventMerge = it, _json = json) + } + + return Event(_json = json) } } class Serializer : BaseSerializer(Event::class) { - override fun serialize(value: Event, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.insertDatasetEventReplace != null -> generator.writeObject(value.insertDatasetEventReplace) - value.insertDatasetEventMerge != null -> generator.writeObject(value.insertDatasetEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } + override fun serialize( + value: Event, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.insertDatasetEventReplace != null -> + generator.writeObject(value.insertDatasetEventReplace) + value.insertDatasetEventMerge != null -> + generator.writeObject(value.insertDatasetEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Event") + } } } @JsonDeserialize(builder = InsertDatasetEventReplace.Builder::class) @NoAutoDetect - class InsertDatasetEventReplace private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, - + class InsertDatasetEventReplace + private constructor( + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -427,148 +439,133 @@ class DatasetInsertParams constructor( /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** The timestamp the dataset event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun created(): Optional = + Optional.ofNullable(created.getNullable("created")) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + fun _isMerge(): Optional = + Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships + * are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": + * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, + * only the root span row `"abc"` will show up in the summary view. You can view the + * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" + * row. */ - fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + fun _parentId(): Optional = + Optional.ofNullable(_parentId.getNullable("_parent_id")) /** * The argument that uniquely define an input case (an arbitrary, JSON serializable * object) */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships + * are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": + * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, + * only the root span row `"abc"` will show up in the summary view. You can view the + * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" + * row. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun __parentId() = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId @JsonAnyGetter @ExcludeMissing @@ -576,63 +573,64 @@ class DatasetInsertParams constructor( fun validate(): InsertDatasetEventReplace = apply { if (!validated) { - input() - expected() - metadata().map { it.validate() } - tags() - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true + input() + expected() + metadata().map { it.validate() } + tags() + id() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventReplace && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertDatasetEventReplace && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + expected, + metadata, + tags, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -668,9 +666,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -678,9 +674,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** * A dictionary with additional data about the test example, model outputs, or just @@ -700,9 +694,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -710,9 +702,7 @@ class DatasetInsertParams constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust @@ -726,9 +716,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -736,19 +724,18 @@ class DatasetInsertParams constructor( /** The timestamp the dataset event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will + * not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean) = + _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will + * not show up in subsequent fetches for this dataset */ @JsonProperty("_object_delete") @ExcludeMissing @@ -762,12 +749,12 @@ class DatasetInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) @@ -777,54 +764,50 @@ class DatasetInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical * relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": + * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a + * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": + * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in + * the summary view. You can view the full trace hierarchy (in this case, the + * `"llm_call"` row) by clicking on the "abc" row. */ fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical * relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": + * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a + * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": + * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in + * the summary view. You can view the full trace hierarchy (in this case, the + * `"llm_call"` row) by clicking on the "abc" row. */ @JsonProperty("_parent_id") @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { - this._parentId = _parentId - } + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -836,34 +819,39 @@ class DatasetInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): InsertDatasetEventReplace = InsertDatasetEventReplace( - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertDatasetEventReplace = + InsertDatasetEventReplace( + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -875,34 +863,33 @@ class DatasetInsertParams constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -924,9 +911,10 @@ class DatasetInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } @@ -935,18 +923,18 @@ class DatasetInsertParams constructor( @JsonDeserialize(builder = InsertDatasetEventMerge.Builder::class) @NoAutoDetect - class InsertDatasetEventMerge private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, - + class InsertDatasetEventMerge + private constructor( + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -968,150 +956,132 @@ class DatasetInsertParams constructor( /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** The timestamp the dataset event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun created(): Optional = + Optional.ofNullable(created.getNullable("created")) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each + * path is a list of field names. The deep merge will not descend below any of the + * specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, + * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced + * `input.a` and `output`, but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** * The argument that uniquely define an input case (an arbitrary, JSON serializable * object) */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each + * path is a list of field names. The deep merge will not descend below any of the + * specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, + * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced + * `input.a` and `output`, but have still deep-merged `input` and `input.c`. */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths @JsonAnyGetter @ExcludeMissing @@ -1119,63 +1089,64 @@ class DatasetInsertParams constructor( fun validate(): InsertDatasetEventMerge = apply { if (!validated) { - input() - expected() - metadata().map { it.validate() } - tags() - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true + input() + expected() + metadata().map { it.validate() } + tags() + id() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventMerge && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertDatasetEventMerge && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + expected, + metadata, + tags, + id, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1211,9 +1182,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -1221,9 +1190,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** * A dictionary with additional data about the test example, model outputs, or just @@ -1243,9 +1210,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -1253,9 +1218,7 @@ class DatasetInsertParams constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust @@ -1269,9 +1232,7 @@ class DatasetInsertParams constructor( */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -1279,19 +1240,18 @@ class DatasetInsertParams constructor( /** The timestamp the dataset event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will + * not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean) = + _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will + * not show up in subsequent fetches for this dataset */ @JsonProperty("_object_delete") @ExcludeMissing @@ -1305,12 +1265,12 @@ class DatasetInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) @@ -1320,50 +1280,49 @@ class DatasetInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where + * each path is a list of field names. The deep merge will not descend below any of + * the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will + * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": + * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have + * replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ - fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + fun _mergePaths(_mergePaths: List>) = + _mergePaths(JsonField.of(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where + * each path is a list of field names. The deep merge will not descend below any of + * the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will + * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": + * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have + * replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing @@ -1381,34 +1340,39 @@ class DatasetInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): InsertDatasetEventMerge = InsertDatasetEventMerge( - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertDatasetEventMerge = + InsertDatasetEventMerge( + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + id, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1420,34 +1384,33 @@ class DatasetInsertParams constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1469,9 +1432,10 @@ class DatasetInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt index bd8b0ed..831b00e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt @@ -2,58 +2,39 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = DatasetInsertResponse.Builder::class) @NoAutoDetect -class DatasetInsertResponse private constructor(private val rowIds: JsonField>, private val additionalProperties: Map, ) { +class DatasetInsertResponse +private constructor( + private val rowIds: JsonField>, + private val additionalProperties: Map, +) { private var validated: Boolean = false private var hashCode: Int = 0 /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ fun rowIds(): List = rowIds.getRequired("row_ids") /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ - @JsonProperty("row_ids") - @ExcludeMissing - fun _rowIds() = rowIds + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds @JsonAnyGetter @ExcludeMissing @@ -61,36 +42,36 @@ class DatasetInsertResponse private constructor(private val rowIds: JsonField
  • ) = rowIds(JsonField.of(rowIds)) /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ @JsonProperty("row_ids") @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { - this.rowIds = rowIds - } + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -134,6 +113,10 @@ class DatasetInsertResponse private constructor(private val rowIds: JsonField
  • = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetListPage && - this.datasetsService == other.datasetsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is DatasetListPage && + this.datasetsService == other.datasetsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - datasetsService, - params, - response, - ) + return Objects.hash( + datasetsService, + params, + response, + ) } - override fun toString() = "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = + "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + DatasetListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + DatasetListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { datasetsService.list(it) } + return getNextPageParams().map { datasetsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +86,21 @@ class DatasetListPage private constructor(private val datasetsService: DatasetSe companion object { @JvmStatic - fun of(datasetsService: DatasetService, params: DatasetListParams, response: Response) = DatasetListPage( - datasetsService, - params, - response, - ) + fun of(datasetsService: DatasetService, params: DatasetListParams, response: Response) = + DatasetListPage( + datasetsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +115,33 @@ class DatasetListPage private constructor(private val datasetsService: DatasetSe fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "DatasetListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +169,25 @@ class DatasetListPage private constructor(private val datasetsService: DatasetSe } } - class AutoPager constructor(private val firstPage: DatasetListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: DatasetListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index a125215..ab1096f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -2,83 +2,86 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.DatasetServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Dataset -import com.braintrustdata.api.services.async.DatasetServiceAsync -class DatasetListPageAsync private constructor(private val datasetsService: DatasetServiceAsync, private val params: DatasetListParams, private val response: Response, ) { +class DatasetListPageAsync +private constructor( + private val datasetsService: DatasetServiceAsync, + private val params: DatasetListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetListPageAsync && - this.datasetsService == other.datasetsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is DatasetListPageAsync && + this.datasetsService == other.datasetsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - datasetsService, - params, - response, - ) + return Objects.hash( + datasetsService, + params, + response, + ) } - override fun toString() = "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = + "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + DatasetListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + DatasetListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - datasetsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { datasetsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +89,25 @@ class DatasetListPageAsync private constructor(private val datasetsService: Data companion object { @JvmStatic - fun of(datasetsService: DatasetServiceAsync, params: DatasetListParams, response: Response) = DatasetListPageAsync( - datasetsService, - params, - response, - ) + fun of( + datasetsService: DatasetServiceAsync, + params: DatasetListParams, + response: Response + ) = + DatasetListPageAsync( + datasetsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +122,33 @@ class DatasetListPageAsync private constructor(private val datasetsService: Data fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "DatasetListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +176,32 @@ class DatasetListPageAsync private constructor(private val datasetsService: Data } } - class AutoPager constructor(private val firstPage: DatasetListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: DatasetListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Dataset) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Dataset) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index d78abd9..1aca4a3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -2,52 +2,36 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class DatasetListParams constructor( - private val datasetName: String?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class DatasetListParams +constructor( + private val datasetName: String?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetName(): Optional = Optional.ofNullable(datasetName) @@ -66,34 +50,19 @@ class DatasetListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.datasetName?.let { - params.put("dataset_name", listOf(it.toString())) - } - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.datasetName?.let { params.put("dataset_name", listOf(it.toString())) } + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -102,46 +71,46 @@ class DatasetListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetListParams && - this.datasetName == other.datasetName && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetListParams && + this.datasetName == other.datasetName && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetName, + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -173,70 +142,52 @@ class DatasetListParams constructor( } /** Name of the dataset to search for */ - fun datasetName(datasetName: String) = apply { - this.datasetName = datasetName - } + fun datasetName(datasetName: String) = apply { this.datasetName = datasetName } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -276,9 +227,7 @@ class DatasetListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -289,88 +238,94 @@ class DatasetListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetListParams = DatasetListParams( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetListParams = + DatasetListParams( + datasetName, + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -380,34 +335,38 @@ class DatasetListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetReplaceParams.kt deleted file mode 100644 index fdae08c..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetReplaceParams.kt +++ /dev/null @@ -1,291 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional - -class DatasetReplaceParams -constructor( - private val name: String, - private val description: String?, - private val projectId: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun description(): Optional = Optional.ofNullable(description) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - @JvmSynthetic - internal fun getBody(): DatasetReplaceBody { - return DatasetReplaceBody( - name, - description, - projectId, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JsonDeserialize(builder = DatasetReplaceBody.Builder::class) - @NoAutoDetect - class DatasetReplaceBody - internal constructor( - private val name: String?, - private val description: String?, - private val projectId: String?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(): String? = name - - /** Textual description of the dataset */ - @JsonProperty("description") fun description(): String? = description - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetReplaceBody && - this.name == other.name && - this.description == other.description && - this.projectId == other.projectId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - projectId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetReplaceBody{name=$name, description=$description, projectId=$projectId, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: String? = null - private var description: String? = null - private var projectId: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(datasetReplaceBody: DatasetReplaceBody) = apply { - this.name = datasetReplaceBody.name - this.description = datasetReplaceBody.description - this.projectId = datasetReplaceBody.projectId - additionalProperties(datasetReplaceBody.additionalProperties) - } - - /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - /** Textual description of the dataset */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): DatasetReplaceBody = - DatasetReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - description, - projectId, - additionalProperties.toUnmodifiable(), - ) - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetReplaceParams && - this.name == other.name && - this.description == other.description && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - name, - description, - projectId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "DatasetReplaceParams{name=$name, description=$description, projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var name: String? = null - private var description: String? = null - private var projectId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(datasetReplaceParams: DatasetReplaceParams) = apply { - this.name = datasetReplaceParams.name - this.description = datasetReplaceParams.description - this.projectId = datasetReplaceParams.projectId - additionalQueryParams(datasetReplaceParams.additionalQueryParams) - additionalHeaders(datasetReplaceParams.additionalHeaders) - additionalBodyProperties(datasetReplaceParams.additionalBodyProperties) - } - - /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { this.name = name } - - /** Textual description of the dataset */ - fun description(description: String) = apply { this.description = description } - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): DatasetReplaceParams = - DatasetReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - projectId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index c132509..68acf5a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class DatasetRetrieveParams constructor( - private val datasetId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class DatasetRetrieveParams +constructor( + private val datasetId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class DatasetRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetRetrieveParams && - this.datasetId == other.datasetId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetRetrieveParams && + this.datasetId == other.datasetId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetRetrieveParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetRetrieveParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class DatasetRetrieveParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class DatasetRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class DatasetRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): DatasetRetrieveParams = DatasetRetrieveParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): DatasetRetrieveParams = + DatasetRetrieveParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 5670b14..427f1f0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -2,47 +2,20 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class DatasetSummarizeParams constructor( - private val datasetId: String, - private val summarizeData: Boolean?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class DatasetSummarizeParams +constructor( + private val datasetId: String, + private val summarizeData: Boolean?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -51,22 +24,19 @@ class DatasetSummarizeParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.summarizeData?.let { - params.put("summarize_data", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.summarizeData?.let { params.put("summarize_data", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -76,36 +46,36 @@ class DatasetSummarizeParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetSummarizeParams && - this.datasetId == other.datasetId && - this.summarizeData == other.summarizeData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetSummarizeParams && + this.datasetId == other.datasetId && + this.summarizeData == other.summarizeData && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - summarizeData, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + summarizeData, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -127,17 +97,12 @@ class DatasetSummarizeParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be - * returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ - fun summarizeData(summarizeData: Boolean) = apply { - this.summarizeData = summarizeData - } + fun summarizeData(summarizeData: Boolean) = apply { this.summarizeData = summarizeData } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -177,9 +142,7 @@ class DatasetSummarizeParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -190,18 +153,18 @@ class DatasetSummarizeParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetSummarizeParams = DatasetSummarizeParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - summarizeData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetSummarizeParams = + DatasetSummarizeParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + summarizeData, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt index 8eea8f9..c9669ea 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt @@ -2,48 +2,30 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Summary of a dataset */ @JsonDeserialize(builder = DatasetSummarizeResponse.Builder::class) @NoAutoDetect -class DatasetSummarizeResponse private constructor( - private val projectName: JsonField, - private val datasetName: JsonField, - private val projectUrl: JsonField, - private val datasetUrl: JsonField, - private val dataSummary: JsonField, - private val additionalProperties: Map, - +class DatasetSummarizeResponse +private constructor( + private val projectName: JsonField, + private val datasetName: JsonField, + private val projectUrl: JsonField, + private val datasetUrl: JsonField, + private val dataSummary: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -63,32 +45,23 @@ class DatasetSummarizeResponse private constructor( fun datasetUrl(): String = datasetUrl.getRequired("dataset_url") /** Summary of a dataset's data */ - fun dataSummary(): Optional = Optional.ofNullable(dataSummary.getNullable("data_summary")) + fun dataSummary(): Optional = + Optional.ofNullable(dataSummary.getNullable("data_summary")) /** Name of the project that the dataset belongs to */ - @JsonProperty("project_name") - @ExcludeMissing - fun _projectName() = projectName + @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName /** Name of the dataset */ - @JsonProperty("dataset_name") - @ExcludeMissing - fun _datasetName() = datasetName + @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName() = datasetName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing - fun _projectUrl() = projectUrl + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") - @ExcludeMissing - fun _datasetUrl() = datasetUrl + @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl() = datasetUrl /** Summary of a dataset's data */ - @JsonProperty("data_summary") - @ExcludeMissing - fun _dataSummary() = dataSummary + @JsonProperty("data_summary") @ExcludeMissing fun _dataSummary() = dataSummary @JsonAnyGetter @ExcludeMissing @@ -96,51 +69,52 @@ class DatasetSummarizeResponse private constructor( fun validate(): DatasetSummarizeResponse = apply { if (!validated) { - projectName() - datasetName() - projectUrl() - datasetUrl() - dataSummary().map { it.validate() } - validated = true + projectName() + datasetName() + projectUrl() + datasetUrl() + dataSummary().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetSummarizeResponse && - this.projectName == other.projectName && - this.datasetName == other.datasetName && - this.projectUrl == other.projectUrl && - this.datasetUrl == other.datasetUrl && - this.dataSummary == other.dataSummary && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetSummarizeResponse && + this.projectName == other.projectName && + this.datasetName == other.datasetName && + this.projectUrl == other.projectUrl && + this.datasetUrl == other.datasetUrl && + this.dataSummary == other.dataSummary && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - projectName, - datasetName, - projectUrl, - datasetUrl, - dataSummary, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + projectName, + datasetName, + projectUrl, + datasetUrl, + dataSummary, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "DatasetSummarizeResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetSummarizeResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -168,9 +142,7 @@ class DatasetSummarizeResponse private constructor( /** Name of the project that the dataset belongs to */ @JsonProperty("project_name") @ExcludeMissing - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } /** Name of the dataset */ fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) @@ -178,9 +150,7 @@ class DatasetSummarizeResponse private constructor( /** Name of the dataset */ @JsonProperty("dataset_name") @ExcludeMissing - fun datasetName(datasetName: JsonField) = apply { - this.datasetName = datasetName - } + fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) @@ -188,9 +158,7 @@ class DatasetSummarizeResponse private constructor( /** URL to the project's page in the Braintrust app */ @JsonProperty("project_url") @ExcludeMissing - fun projectUrl(projectUrl: JsonField) = apply { - this.projectUrl = projectUrl - } + fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } /** URL to the dataset's page in the Braintrust app */ fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) @@ -198,9 +166,7 @@ class DatasetSummarizeResponse private constructor( /** URL to the dataset's page in the Braintrust app */ @JsonProperty("dataset_url") @ExcludeMissing - fun datasetUrl(datasetUrl: JsonField) = apply { - this.datasetUrl = datasetUrl - } + fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } /** Summary of a dataset's data */ fun dataSummary(dataSummary: DataSummary) = dataSummary(JsonField.of(dataSummary)) @@ -226,20 +192,25 @@ class DatasetSummarizeResponse private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetSummarizeResponse = DatasetSummarizeResponse( - projectName, - datasetName, - projectUrl, - datasetUrl, - dataSummary, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetSummarizeResponse = + DatasetSummarizeResponse( + projectName, + datasetName, + projectUrl, + datasetUrl, + dataSummary, + additionalProperties.toUnmodifiable(), + ) } /** Summary of a dataset's data */ @JsonDeserialize(builder = DataSummary.Builder::class) @NoAutoDetect - class DataSummary private constructor(private val totalRecords: JsonField, private val additionalProperties: Map, ) { + class DataSummary + private constructor( + private val totalRecords: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -249,9 +220,7 @@ class DatasetSummarizeResponse private constructor( fun totalRecords(): Long = totalRecords.getRequired("total_records") /** Total number of records in the dataset */ - @JsonProperty("total_records") - @ExcludeMissing - fun _totalRecords() = totalRecords + @JsonProperty("total_records") @ExcludeMissing fun _totalRecords() = totalRecords @JsonAnyGetter @ExcludeMissing @@ -259,36 +228,36 @@ class DatasetSummarizeResponse private constructor( fun validate(): DataSummary = apply { if (!validated) { - totalRecords() - validated = true + totalRecords() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is DataSummary && - this.totalRecords == other.totalRecords && - this.additionalProperties == other.additionalProperties + return other is DataSummary && + this.totalRecords == other.totalRecords && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(totalRecords, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(totalRecords, additionalProperties) + } + return hashCode } - override fun toString() = "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" + override fun toString() = + "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -326,7 +295,8 @@ class DatasetSummarizeResponse private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DataSummary = DataSummary(totalRecords, additionalProperties.toUnmodifiable()) + fun build(): DataSummary = + DataSummary(totalRecords, additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index b8f36cf..1ab15c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -2,49 +2,27 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class DatasetUpdateParams constructor( - private val datasetId: String, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class DatasetUpdateParams +constructor( + private val datasetId: String, + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -57,50 +35,45 @@ class DatasetUpdateParams constructor( @JvmSynthetic internal fun getBody(): DatasetUpdateBody { - return DatasetUpdateBody( - description, - metadata, - name, - additionalBodyProperties, - ) + return DatasetUpdateBody( + description, + metadata, + name, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetUpdateBody.Builder::class) @NoAutoDetect - class DatasetUpdateBody internal constructor( - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val additionalProperties: Map, - + class DatasetUpdateBody + internal constructor( + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Textual description of the dataset */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata + @JsonProperty("metadata") fun metadata(): Metadata? = metadata /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name @JsonAnyGetter @ExcludeMissing @@ -109,35 +82,36 @@ class DatasetUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetUpdateBody && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetUpdateBody && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - description, - metadata, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + description, + metadata, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -157,21 +131,14 @@ class DatasetUpdateParams constructor( /** Textual description of the dataset */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** User-controlled metadata about the dataset */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -187,12 +154,13 @@ class DatasetUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetUpdateBody = DatasetUpdateBody( - description, - metadata, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetUpdateBody = + DatasetUpdateBody( + description, + metadata, + name, + additionalProperties.toUnmodifiable(), + ) } } @@ -203,40 +171,40 @@ class DatasetUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetUpdateParams && - this.datasetId == other.datasetId && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetUpdateParams && + this.datasetId == other.datasetId && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - description, - metadata, - name, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + description, + metadata, + name, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -262,24 +230,16 @@ class DatasetUpdateParams constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** Textual description of the dataset */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -319,9 +279,7 @@ class DatasetUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -332,27 +290,30 @@ class DatasetUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetUpdateParams = DatasetUpdateParams( - checkNotNull(datasetId) { - "`datasetId` is required but was not set" - }, - description, - metadata, - name, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetUpdateParams = + DatasetUpdateParams( + checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + description, + metadata, + name, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the dataset */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -363,27 +324,25 @@ class DatasetUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index eb0e3d3..c749d38 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -2,56 +2,39 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Experiment.Builder::class) @NoAutoDetect -class Experiment private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val created: JsonField, - private val repoInfo: JsonField, - private val commit: JsonField, - private val baseExpId: JsonField, - private val deletedAt: JsonField, - private val datasetId: JsonField, - private val datasetVersion: JsonField, - private val public_: JsonField, - private val userId: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, - +class Experiment +private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val created: JsonField, + private val repoInfo: JsonField, + private val commit: JsonField, + private val baseExpId: JsonField, + private val deletedAt: JsonField, + private val datasetId: JsonField, + private val datasetVersion: JsonField, + private val public_: JsonField, + private val userId: JsonField, + private val metadata: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -68,7 +51,8 @@ class Experiment private constructor( fun name(): String = name.getRequired("name") /** Textual description of the experiment */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Date of experiment creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) @@ -83,23 +67,22 @@ class Experiment private constructor( fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ fun public_(): Boolean = public_.getRequired("public") @@ -110,83 +93,52 @@ class Experiment private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Unique identifier for the experiment */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Textual description of the experiment */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** Date of experiment creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun _repoInfo() = repoInfo + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo() = repoInfo /** Commit, taken directly from `repo_info.commit` */ - @JsonProperty("commit") - @ExcludeMissing - fun _commit() = commit + @JsonProperty("commit") @ExcludeMissing fun _commit() = commit /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - @ExcludeMissing - fun _baseExpId() = baseExpId + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId() = baseExpId /** Date of experiment deletion, or null if the experiment is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun _datasetId() = datasetId + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") - @ExcludeMissing - fun _datasetVersion() = datasetVersion + @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion() = datasetVersion /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ - @JsonProperty("public") - @ExcludeMissing - fun _public_() = public_ + @JsonProperty("public") @ExcludeMissing fun _public_() = public_ /** Identifies the user who created the experiment */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata @JsonAnyGetter @ExcludeMissing @@ -194,78 +146,79 @@ class Experiment private constructor( fun validate(): Experiment = apply { if (!validated) { - id() - projectId() - name() - description() - created() - repoInfo().map { it.validate() } - commit() - baseExpId() - deletedAt() - datasetId() - datasetVersion() - public_() - userId() - metadata().map { it.validate() } - validated = true + id() + projectId() + name() + description() + created() + repoInfo().map { it.validate() } + commit() + baseExpId() + deletedAt() + datasetId() + datasetVersion() + public_() + userId() + metadata().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Experiment && - this.id == other.id && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.created == other.created && - this.repoInfo == other.repoInfo && - this.commit == other.commit && - this.baseExpId == other.baseExpId && - this.deletedAt == other.deletedAt && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.public_ == other.public_ && - this.userId == other.userId && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Experiment && + this.id == other.id && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.created == other.created && + this.repoInfo == other.repoInfo && + this.commit == other.commit && + this.baseExpId == other.baseExpId && + this.deletedAt == other.deletedAt && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.public_ == other.public_ && + this.userId == other.userId && + this.metadata == other.metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - projectId, - name, - description, - created, - repoInfo, - commit, - baseExpId, - deletedAt, - datasetId, - datasetVersion, - public_, - userId, - metadata, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + projectId, + name, + description, + created, + repoInfo, + commit, + baseExpId, + deletedAt, + datasetId, + datasetVersion, + public_, + userId, + metadata, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = + "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -309,11 +262,7 @@ class Experiment private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the experiment */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -321,9 +270,7 @@ class Experiment private constructor( /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String) = name(JsonField.of(name)) @@ -331,9 +278,7 @@ class Experiment private constructor( /** Name of the experiment. Within a project, experiment names are unique */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the experiment */ fun description(description: String) = description(JsonField.of(description)) @@ -341,9 +286,7 @@ class Experiment private constructor( /** Textual description of the experiment */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** Date of experiment creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -351,9 +294,7 @@ class Experiment private constructor( /** Date of experiment creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo) = repoInfo(JsonField.of(repoInfo)) @@ -361,9 +302,7 @@ class Experiment private constructor( /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") @ExcludeMissing - fun repoInfo(repoInfo: JsonField) = apply { - this.repoInfo = repoInfo - } + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } /** Commit, taken directly from `repo_info.commit` */ fun commit(commit: String) = commit(JsonField.of(commit)) @@ -371,9 +310,7 @@ class Experiment private constructor( /** Commit, taken directly from `repo_info.commit` */ @JsonProperty("commit") @ExcludeMissing - fun commit(commit: JsonField) = apply { - this.commit = commit - } + fun commit(commit: JsonField) = apply { this.commit = commit } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String) = baseExpId(JsonField.of(baseExpId)) @@ -381,9 +318,7 @@ class Experiment private constructor( /** Id of default base experiment to compare against when viewing this experiment */ @JsonProperty("base_exp_id") @ExcludeMissing - fun baseExpId(baseExpId: JsonField) = apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -391,35 +326,29 @@ class Experiment private constructor( /** Date of experiment deletion, or null if the experiment is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ @JsonProperty("dataset_id") @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ fun datasetVersion(datasetVersion: String) = datasetVersion(JsonField.of(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -428,20 +357,18 @@ class Experiment private constructor( } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean) = public_(JsonField.of(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ @JsonProperty("public") @ExcludeMissing - fun public_(public_: JsonField) = apply { - this.public_ = public_ - } + fun public_(public_: JsonField) = apply { this.public_ = public_ } /** Identifies the user who created the experiment */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -449,9 +376,7 @@ class Experiment private constructor( /** Identifies the user who created the experiment */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -459,9 +384,7 @@ class Experiment private constructor( /** User-controlled metadata about the experiment */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -477,29 +400,33 @@ class Experiment private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Experiment = Experiment( - id, - projectId, - name, - description, - created, - repoInfo, - commit, - baseExpId, - deletedAt, - datasetId, - datasetVersion, - public_, - userId, - metadata, - additionalProperties.toUnmodifiable(), - ) + fun build(): Experiment = + Experiment( + id, + projectId, + name, + description, + created, + repoInfo, + commit, + baseExpId, + deletedAt, + datasetId, + datasetVersion, + public_, + userId, + metadata, + additionalProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the experiment */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -511,34 +438,32 @@ class Experiment private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -571,18 +496,18 @@ class Experiment private constructor( /** Metadata about the state of the repo when the experiment was created */ @JsonDeserialize(builder = RepoInfo.Builder::class) @NoAutoDetect - class RepoInfo private constructor( - private val commit: JsonField, - private val branch: JsonField, - private val tag: JsonField, - private val dirty: JsonField, - private val authorName: JsonField, - private val authorEmail: JsonField, - private val commitMessage: JsonField, - private val commitTime: JsonField, - private val gitDiff: JsonField, - private val additionalProperties: Map, - + class RepoInfo + private constructor( + private val commit: JsonField, + private val branch: JsonField, + private val tag: JsonField, + private val dirty: JsonField, + private val authorName: JsonField, + private val authorEmail: JsonField, + private val commitMessage: JsonField, + private val commitTime: JsonField, + private val gitDiff: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -602,70 +527,56 @@ class Experiment private constructor( fun dirty(): Optional = Optional.ofNullable(dirty.getNullable("dirty")) /** Name of the author of the most recent commit */ - fun authorName(): Optional = Optional.ofNullable(authorName.getNullable("author_name")) + fun authorName(): Optional = + Optional.ofNullable(authorName.getNullable("author_name")) /** Email of the author of the most recent commit */ - fun authorEmail(): Optional = Optional.ofNullable(authorEmail.getNullable("author_email")) + fun authorEmail(): Optional = + Optional.ofNullable(authorEmail.getNullable("author_email")) /** Most recent commit message */ - fun commitMessage(): Optional = Optional.ofNullable(commitMessage.getNullable("commit_message")) + fun commitMessage(): Optional = + Optional.ofNullable(commitMessage.getNullable("commit_message")) /** Time of the most recent commit */ - fun commitTime(): Optional = Optional.ofNullable(commitTime.getNullable("commit_time")) + fun commitTime(): Optional = + Optional.ofNullable(commitTime.getNullable("commit_time")) /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. */ fun gitDiff(): Optional = Optional.ofNullable(gitDiff.getNullable("git_diff")) /** SHA of most recent commit */ - @JsonProperty("commit") - @ExcludeMissing - fun _commit() = commit + @JsonProperty("commit") @ExcludeMissing fun _commit() = commit /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") - @ExcludeMissing - fun _branch() = branch + @JsonProperty("branch") @ExcludeMissing fun _branch() = branch /** Name of the tag on the most recent commit */ - @JsonProperty("tag") - @ExcludeMissing - fun _tag() = tag + @JsonProperty("tag") @ExcludeMissing fun _tag() = tag /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") - @ExcludeMissing - fun _dirty() = dirty + @JsonProperty("dirty") @ExcludeMissing fun _dirty() = dirty /** Name of the author of the most recent commit */ - @JsonProperty("author_name") - @ExcludeMissing - fun _authorName() = authorName + @JsonProperty("author_name") @ExcludeMissing fun _authorName() = authorName /** Email of the author of the most recent commit */ - @JsonProperty("author_email") - @ExcludeMissing - fun _authorEmail() = authorEmail + @JsonProperty("author_email") @ExcludeMissing fun _authorEmail() = authorEmail /** Most recent commit message */ - @JsonProperty("commit_message") - @ExcludeMissing - fun _commitMessage() = commitMessage + @JsonProperty("commit_message") @ExcludeMissing fun _commitMessage() = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") - @ExcludeMissing - fun _commitTime() = commitTime + @JsonProperty("commit_time") @ExcludeMissing fun _commitTime() = commitTime /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. */ - @JsonProperty("git_diff") - @ExcludeMissing - fun _gitDiff() = gitDiff + @JsonProperty("git_diff") @ExcludeMissing fun _gitDiff() = gitDiff @JsonAnyGetter @ExcludeMissing @@ -673,63 +584,64 @@ class Experiment private constructor( fun validate(): RepoInfo = apply { if (!validated) { - commit() - branch() - tag() - dirty() - authorName() - authorEmail() - commitMessage() - commitTime() - gitDiff() - validated = true + commit() + branch() + tag() + dirty() + authorName() + authorEmail() + commitMessage() + commitTime() + gitDiff() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RepoInfo && - this.commit == other.commit && - this.branch == other.branch && - this.tag == other.tag && - this.dirty == other.dirty && - this.authorName == other.authorName && - this.authorEmail == other.authorEmail && - this.commitMessage == other.commitMessage && - this.commitTime == other.commitTime && - this.gitDiff == other.gitDiff && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RepoInfo && + this.commit == other.commit && + this.branch == other.branch && + this.tag == other.tag && + this.dirty == other.dirty && + this.authorName == other.authorName && + this.authorEmail == other.authorEmail && + this.commitMessage == other.commitMessage && + this.commitTime == other.commitTime && + this.gitDiff == other.gitDiff && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" + override fun toString() = + "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -765,9 +677,7 @@ class Experiment private constructor( /** SHA of most recent commit */ @JsonProperty("commit") @ExcludeMissing - fun commit(commit: JsonField) = apply { - this.commit = commit - } + fun commit(commit: JsonField) = apply { this.commit = commit } /** Name of the branch the most recent commit belongs to */ fun branch(branch: String) = branch(JsonField.of(branch)) @@ -775,9 +685,7 @@ class Experiment private constructor( /** Name of the branch the most recent commit belongs to */ @JsonProperty("branch") @ExcludeMissing - fun branch(branch: JsonField) = apply { - this.branch = branch - } + fun branch(branch: JsonField) = apply { this.branch = branch } /** Name of the tag on the most recent commit */ fun tag(tag: String) = tag(JsonField.of(tag)) @@ -785,9 +693,7 @@ class Experiment private constructor( /** Name of the tag on the most recent commit */ @JsonProperty("tag") @ExcludeMissing - fun tag(tag: JsonField) = apply { - this.tag = tag - } + fun tag(tag: JsonField) = apply { this.tag = tag } /** Whether or not the repo had uncommitted changes when snapshotted */ fun dirty(dirty: Boolean) = dirty(JsonField.of(dirty)) @@ -795,9 +701,7 @@ class Experiment private constructor( /** Whether or not the repo had uncommitted changes when snapshotted */ @JsonProperty("dirty") @ExcludeMissing - fun dirty(dirty: JsonField) = apply { - this.dirty = dirty - } + fun dirty(dirty: JsonField) = apply { this.dirty = dirty } /** Name of the author of the most recent commit */ fun authorName(authorName: String) = authorName(JsonField.of(authorName)) @@ -805,9 +709,7 @@ class Experiment private constructor( /** Name of the author of the most recent commit */ @JsonProperty("author_name") @ExcludeMissing - fun authorName(authorName: JsonField) = apply { - this.authorName = authorName - } + fun authorName(authorName: JsonField) = apply { this.authorName = authorName } /** Email of the author of the most recent commit */ fun authorEmail(authorEmail: String) = authorEmail(JsonField.of(authorEmail)) @@ -835,25 +737,21 @@ class Experiment private constructor( /** Time of the most recent commit */ @JsonProperty("commit_time") @ExcludeMissing - fun commitTime(commitTime: JsonField) = apply { - this.commitTime = commitTime - } + fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of + * the repo and the most recent commit. */ fun gitDiff(gitDiff: String) = gitDiff(JsonField.of(gitDiff)) /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of + * the repo and the most recent commit. */ @JsonProperty("git_diff") @ExcludeMissing - fun gitDiff(gitDiff: JsonField) = apply { - this.gitDiff = gitDiff - } + fun gitDiff(gitDiff: JsonField) = apply { this.gitDiff = gitDiff } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -869,18 +767,19 @@ class Experiment private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RepoInfo = RepoInfo( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties.toUnmodifiable(), - ) + fun build(): RepoInfo = + RepoInfo( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties.toUnmodifiable(), + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index fb5ddce..e3ec83d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -2,55 +2,33 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ExperimentCreateParams constructor( - private val projectId: String, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ExperimentCreateParams +constructor( + private val projectId: String, + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val ensureNew: Boolean?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -75,99 +53,85 @@ class ExperimentCreateParams constructor( @JvmSynthetic internal fun getBody(): ExperimentCreateBody { - return ExperimentCreateBody( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalBodyProperties, - ) + return ExperimentCreateBody( + projectId, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ExperimentCreateBody.Builder::class) @NoAutoDetect - class ExperimentCreateBody internal constructor( - private val projectId: String?, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalProperties: Map, - + class ExperimentCreateBody + internal constructor( + private val projectId: String?, + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val ensureNew: Boolean?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - fun baseExpId(): String? = baseExpId + @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") - fun datasetId(): String? = datasetId + @JsonProperty("dataset_id") fun datasetId(): String? = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") - fun datasetVersion(): String? = datasetVersion + @JsonProperty("dataset_version") fun datasetVersion(): String? = datasetVersion /** Textual description of the experiment */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ - @JsonProperty("ensure_new") - fun ensureNew(): Boolean? = ensureNew + @JsonProperty("ensure_new") fun ensureNew(): Boolean? = ensureNew /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata + @JsonProperty("metadata") fun metadata(): Metadata? = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - @JsonProperty("public") - fun public_(): Boolean? = public_ + @JsonProperty("public") fun public_(): Boolean? = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - fun repoInfo(): RepoInfo? = repoInfo + @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo @JsonAnyGetter @ExcludeMissing @@ -176,49 +140,50 @@ class ExperimentCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentCreateBody && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentCreateBody && + this.projectId == other.projectId && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.ensureNew == other.ensureNew && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + projectId, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -252,28 +217,22 @@ class ExperimentCreateParams constructor( /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Id of default base experiment to compare against when viewing this experiment */ @JsonProperty("base_exp_id") - fun baseExpId(baseExpId: String) = apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } /** * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ @JsonProperty("dataset_id") - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") fun datasetVersion(datasetVersion: String) = apply { @@ -282,47 +241,32 @@ class ExperimentCreateParams constructor( /** Textual description of the experiment */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. */ @JsonProperty("ensure_new") - fun ensureNew(ensureNew: Boolean) = apply { - this.ensureNew = ensureNew - } + fun ensureNew(ensureNew: Boolean) = apply { this.ensureNew = ensureNew } /** User-controlled metadata about the experiment */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - @JsonProperty("public") - fun public_(public_: Boolean) = apply { - this.public_ = public_ - } + @JsonProperty("public") fun public_(public_: Boolean) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { - this.repoInfo = repoInfo - } + fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -338,21 +282,20 @@ class ExperimentCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentCreateBody = ExperimentCreateBody( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentCreateBody = + ExperimentCreateBody( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalProperties.toUnmodifiable(), + ) } } @@ -363,52 +306,52 @@ class ExperimentCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentCreateParams && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentCreateParams && + this.projectId == other.projectId && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.ensureNew == other.ensureNew && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -446,68 +389,46 @@ class ExperimentCreateParams constructor( } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: String) = apply { this.datasetVersion = datasetVersion } /** Textual description of the experiment */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ - fun ensureNew(ensureNew: Boolean) = apply { - this.ensureNew = ensureNew - } + fun ensureNew(ensureNew: Boolean) = apply { this.ensureNew = ensureNew } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: Boolean) = apply { - this.public_ = public_ - } + fun public_(public_: Boolean) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { - this.repoInfo = repoInfo - } + fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -547,9 +468,7 @@ class ExperimentCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -560,33 +479,36 @@ class ExperimentCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentCreateParams = ExperimentCreateParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentCreateParams = + ExperimentCreateParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the experiment */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -597,27 +519,25 @@ class ExperimentCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -650,60 +570,51 @@ class ExperimentCreateParams constructor( /** Metadata about the state of the repo when the experiment was created */ @JsonDeserialize(builder = RepoInfo.Builder::class) @NoAutoDetect - class RepoInfo private constructor( - private val commit: String?, - private val branch: String?, - private val tag: String?, - private val dirty: Boolean?, - private val authorName: String?, - private val authorEmail: String?, - private val commitMessage: String?, - private val commitTime: String?, - private val gitDiff: String?, - private val additionalProperties: Map, - + class RepoInfo + private constructor( + private val commit: String?, + private val branch: String?, + private val tag: String?, + private val dirty: Boolean?, + private val authorName: String?, + private val authorEmail: String?, + private val commitMessage: String?, + private val commitTime: String?, + private val gitDiff: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** SHA of most recent commit */ - @JsonProperty("commit") - fun commit(): String? = commit + @JsonProperty("commit") fun commit(): String? = commit /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") - fun branch(): String? = branch + @JsonProperty("branch") fun branch(): String? = branch /** Name of the tag on the most recent commit */ - @JsonProperty("tag") - fun tag(): String? = tag + @JsonProperty("tag") fun tag(): String? = tag /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") - fun dirty(): Boolean? = dirty + @JsonProperty("dirty") fun dirty(): Boolean? = dirty /** Name of the author of the most recent commit */ - @JsonProperty("author_name") - fun authorName(): String? = authorName + @JsonProperty("author_name") fun authorName(): String? = authorName /** Email of the author of the most recent commit */ - @JsonProperty("author_email") - fun authorEmail(): String? = authorEmail + @JsonProperty("author_email") fun authorEmail(): String? = authorEmail /** Most recent commit message */ - @JsonProperty("commit_message") - fun commitMessage(): String? = commitMessage + @JsonProperty("commit_message") fun commitMessage(): String? = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") - fun commitTime(): String? = commitTime + @JsonProperty("commit_time") fun commitTime(): String? = commitTime /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. */ - @JsonProperty("git_diff") - fun gitDiff(): String? = gitDiff + @JsonProperty("git_diff") fun gitDiff(): String? = gitDiff @JsonAnyGetter @ExcludeMissing @@ -712,47 +623,48 @@ class ExperimentCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RepoInfo && - this.commit == other.commit && - this.branch == other.branch && - this.tag == other.tag && - this.dirty == other.dirty && - this.authorName == other.authorName && - this.authorEmail == other.authorEmail && - this.commitMessage == other.commitMessage && - this.commitTime == other.commitTime && - this.gitDiff == other.gitDiff && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RepoInfo && + this.commit == other.commit && + this.branch == other.branch && + this.tag == other.tag && + this.dirty == other.dirty && + this.authorName == other.authorName && + this.authorEmail == other.authorEmail && + this.commitMessage == other.commitMessage && + this.commitTime == other.commitTime && + this.gitDiff == other.gitDiff && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" + override fun toString() = + "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -783,61 +695,39 @@ class ExperimentCreateParams constructor( } /** SHA of most recent commit */ - @JsonProperty("commit") - fun commit(commit: String) = apply { - this.commit = commit - } + @JsonProperty("commit") fun commit(commit: String) = apply { this.commit = commit } /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") - fun branch(branch: String) = apply { - this.branch = branch - } + @JsonProperty("branch") fun branch(branch: String) = apply { this.branch = branch } /** Name of the tag on the most recent commit */ - @JsonProperty("tag") - fun tag(tag: String) = apply { - this.tag = tag - } + @JsonProperty("tag") fun tag(tag: String) = apply { this.tag = tag } /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") - fun dirty(dirty: Boolean) = apply { - this.dirty = dirty - } + @JsonProperty("dirty") fun dirty(dirty: Boolean) = apply { this.dirty = dirty } /** Name of the author of the most recent commit */ @JsonProperty("author_name") - fun authorName(authorName: String) = apply { - this.authorName = authorName - } + fun authorName(authorName: String) = apply { this.authorName = authorName } /** Email of the author of the most recent commit */ @JsonProperty("author_email") - fun authorEmail(authorEmail: String) = apply { - this.authorEmail = authorEmail - } + fun authorEmail(authorEmail: String) = apply { this.authorEmail = authorEmail } /** Most recent commit message */ @JsonProperty("commit_message") - fun commitMessage(commitMessage: String) = apply { - this.commitMessage = commitMessage - } + fun commitMessage(commitMessage: String) = apply { this.commitMessage = commitMessage } /** Time of the most recent commit */ @JsonProperty("commit_time") - fun commitTime(commitTime: String) = apply { - this.commitTime = commitTime - } + fun commitTime(commitTime: String) = apply { this.commitTime = commitTime } /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of + * the repo and the most recent commit. */ @JsonProperty("git_diff") - fun gitDiff(gitDiff: String) = apply { - this.gitDiff = gitDiff - } + fun gitDiff(gitDiff: String) = apply { this.gitDiff = gitDiff } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -853,18 +743,19 @@ class ExperimentCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RepoInfo = RepoInfo( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties.toUnmodifiable(), - ) + fun build(): RepoInfo = + RepoInfo( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties.toUnmodifiable(), + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 6b8bd2c..e3e57b2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ExperimentDeleteParams constructor( - private val experimentId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ExperimentDeleteParams +constructor( + private val experimentId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class ExperimentDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentDeleteParams && - this.experimentId == other.experimentId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentDeleteParams && + this.experimentId == other.experimentId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentDeleteParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentDeleteParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class ExperimentDeleteParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class ExperimentDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class ExperimentDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ExperimentDeleteParams = ExperimentDeleteParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExperimentDeleteParams = + ExperimentDeleteParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 85b9b6d..b160982 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -2,47 +2,28 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* +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.databind.annotation.JsonDeserialize +import java.util.Objects -class ExperimentFeedbackParams constructor( - private val experimentId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ExperimentFeedbackParams +constructor( + private val experimentId: String, + private val feedback: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -51,31 +32,32 @@ class ExperimentFeedbackParams constructor( @JvmSynthetic internal fun getBody(): ExperimentFeedbackBody { - return ExperimentFeedbackBody(feedback, additionalBodyProperties) + return ExperimentFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentFeedbackBody.Builder::class) @NoAutoDetect - class ExperimentFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { + class ExperimentFeedbackBody + internal constructor( + private val feedback: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** A list of experiment feedback items */ - @JsonProperty("feedback") - fun feedback(): List? = feedback + @JsonProperty("feedback") fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -84,28 +66,28 @@ class ExperimentFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ExperimentFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties + return other is ExperimentFeedbackBody && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode } - override fun toString() = "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -121,9 +103,7 @@ class ExperimentFeedbackParams constructor( /** A list of experiment feedback items */ @JsonProperty("feedback") - fun feedback(feedback: List) = apply { - this.feedback = feedback - } + fun feedback(feedback: List) = apply { this.feedback = feedback } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -139,9 +119,12 @@ class ExperimentFeedbackParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentFeedbackBody = ExperimentFeedbackBody(checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) + fun build(): ExperimentFeedbackBody = + ExperimentFeedbackBody( + checkNotNull(feedback) { "`feedback` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) } } @@ -152,36 +135,36 @@ class ExperimentFeedbackParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFeedbackParams && - this.experimentId == other.experimentId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentFeedbackParams && + this.experimentId == other.experimentId && + this.feedback == other.feedback && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + feedback, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -203,9 +186,7 @@ class ExperimentFeedbackParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment feedback items */ fun feedback(feedback: List) = apply { @@ -214,9 +195,7 @@ class ExperimentFeedbackParams constructor( } /** A list of experiment feedback items */ - fun addFeedback(feedback: Feedback) = apply { - this.feedback.add(feedback) - } + fun addFeedback(feedback: Feedback) = apply { this.feedback.add(feedback) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,9 +235,7 @@ class ExperimentFeedbackParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -269,73 +246,66 @@ class ExperimentFeedbackParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentFeedbackParams = + ExperimentFeedbackParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + checkNotNull(feedback) { "`feedback` is required but was not set" } + .toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Feedback.Builder::class) @NoAutoDetect - class Feedback private constructor( - private val id: String?, - private val scores: Scores?, - private val expected: JsonValue?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - + class Feedback + private constructor( + private val id: String?, + private val scores: Scores?, + private val expected: JsonValue?, + private val comment: String?, + private val metadata: Metadata?, + private val source: Source?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** - * The id of the experiment event to log feedback for. This is the row `id` - * returned by `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` returned by + * `POST /v1/experiment/{experiment_id}/insert` */ - @JsonProperty("id") - fun id(): String? = id + @JsonProperty("id") fun id(): String? = id /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event */ - @JsonProperty("scores") - fun scores(): Scores? = scores + @JsonProperty("scores") fun scores(): Scores? = scores /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") - fun expected(): JsonValue? = expected + @JsonProperty("expected") fun expected(): JsonValue? = expected /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") - fun comment(): String? = comment + @JsonProperty("comment") fun comment(): String? = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata + @JsonProperty("metadata") fun metadata(): Metadata? = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(): Source? = source + @JsonProperty("source") fun source(): Source? = source @JsonAnyGetter @ExcludeMissing @@ -344,41 +314,42 @@ class ExperimentFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Feedback && + this.id == other.id && + this.scores == other.scores && + this.expected == other.expected && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Feedback{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + override fun toString() = + "Feedback{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -403,52 +374,36 @@ class ExperimentFeedbackParams constructor( } /** - * The id of the experiment event to log feedback for. This is the row `id` - * returned by `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` returned by + * `POST /v1/experiment/{experiment_id}/insert` */ - @JsonProperty("id") - fun id(id: String) = apply { - this.id = id - } + @JsonProperty("id") fun id(id: String) = apply { this.id = id } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged + * into the existing scores for the experiment event */ - @JsonProperty("scores") - fun scores(scores: Scores) = apply { - this.scores = scores - } + @JsonProperty("scores") fun scores(scores: Scores) = apply { this.scores = scores } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ @JsonProperty("expected") - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") - fun comment(comment: String) = apply { - this.comment = comment - } + @JsonProperty("comment") fun comment(comment: String) = apply { this.comment = comment } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you + * can log it here and access it in the Braintrust UI. */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(source: Source) = apply { - this.source = source - } + @JsonProperty("source") fun source(source: Source) = apply { this.source = source } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -464,26 +419,28 @@ class ExperimentFeedbackParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Feedback = Feedback( - checkNotNull(id) { - "`id` is required but was not set" - }, - scores, - expected, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) + fun build(): Feedback = + Feedback( + checkNotNull(id) { "`id` is required but was not set" }, + scores, + expected, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -494,27 +451,25 @@ class ExperimentFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -536,21 +491,25 @@ class ExperimentFeedbackParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -561,27 +520,25 @@ class ExperimentFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -603,26 +560,29 @@ class ExperimentFeedbackParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } } - class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Source + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Source && - this.value == other.value + return other is Source && this.value == other.value } override fun hashCode() = value.hashCode() @@ -653,19 +613,21 @@ class ExperimentFeedbackParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } + fun known(): Known = + when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index e889054..a09a503 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -2,50 +2,23 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ExperimentFetchParams constructor( - private val experimentId: String, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ExperimentFetchParams +constructor( + private val experimentId: String, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -60,31 +33,22 @@ class ExperimentFetchParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.maxRootSpanId?.let { - params.put("max_root_span_id", listOf(it.toString())) - } - this.maxXactId?.let { - params.put("max_xact_id", listOf(it.toString())) - } - this.version?.let { - params.put("version", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } + this.version?.let { params.put("version", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -94,42 +58,42 @@ class ExperimentFetchParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchParams && - this.experimentId == other.experimentId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentFetchParams && + this.experimentId == other.experimentId && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -157,72 +121,60 @@ class ExperimentFetchParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -262,9 +214,7 @@ class ExperimentFetchParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -275,21 +225,21 @@ class ExperimentFetchParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ExperimentFetchParams = ExperimentFetchParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExperimentFetchParams = + ExperimentFetchParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index fc42ecc..b8c52f0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -2,52 +2,34 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ExperimentFetchPostParams constructor( - private val experimentId: String, - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ExperimentFetchPostParams +constructor( + private val experimentId: String, + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -66,120 +48,110 @@ class ExperimentFetchPostParams constructor( @JvmSynthetic internal fun getBody(): ExperimentFetchPostBody { - return ExperimentFetchPostBody( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) + return ExperimentFetchPostBody( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentFetchPostBody.Builder::class) @NoAutoDetect - class ExperimentFetchPostBody internal constructor( - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, - + class ExperimentFetchPostBody + internal constructor( + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - fun cursor(): String? = cursor + @JsonProperty("cursor") fun cursor(): String? = cursor /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ - @JsonProperty("filters") - fun filters(): List? = filters + @JsonProperty("filters") fun filters(): List? = filters /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - @JsonProperty("limit") - fun limit(): Long? = limit + @JsonProperty("limit") fun limit(): Long? = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_root_span_id") - fun maxRootSpanId(): String? = maxRootSpanId + @JsonProperty("max_root_span_id") fun maxRootSpanId(): String? = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_xact_id") - fun maxXactId(): String? = maxXactId + @JsonProperty("max_xact_id") fun maxXactId(): String? = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") - fun version(): String? = version + @JsonProperty("version") fun version(): String? = version @JsonAnyGetter @ExcludeMissing @@ -188,41 +160,42 @@ class ExperimentFetchPostParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentFetchPostBody && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -247,92 +220,76 @@ class ExperimentFetchPostParams constructor( } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - fun cursor(cursor: String) = apply { - this.cursor = cursor - } + @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters + * are supported, but we may add more in the future */ @JsonProperty("filters") - fun filters(filters: List) = apply { - this.filters = filters - } + fun filters(filters: List) = apply { this.filters = filters } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ - @JsonProperty("limit") - fun limit(limit: Long) = apply { - this.limit = limit - } + @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ - @JsonProperty("version") - fun version(version: String) = apply { - this.version = version - } + @JsonProperty("version") fun version(version: String) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -348,15 +305,16 @@ class ExperimentFetchPostParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentFetchPostBody = ExperimentFetchPostBody( - cursor, - filters?.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentFetchPostBody = + ExperimentFetchPostBody( + cursor, + filters?.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toUnmodifiable(), + ) } } @@ -367,46 +325,46 @@ class ExperimentFetchPostParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchPostParams && - this.experimentId == other.experimentId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentFetchPostParams && + this.experimentId == other.experimentId && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -438,24 +396,20 @@ class ExperimentFetchPostParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: String) = apply { - this.cursor = cursor - } + fun cursor(cursor: String) = apply { this.cursor = cursor } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ fun filters(filters: List) = apply { this.filters.clear() @@ -463,75 +417,63 @@ class ExperimentFetchPostParams constructor( } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ - fun addFilter(filter: Filter) = apply { - this.filters.add(filter) - } + fun addFilter(filter: Filter) = apply { this.filters.add(filter) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -571,9 +513,7 @@ class ExperimentFetchPostParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -584,65 +524,60 @@ class ExperimentFetchPostParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - cursor, - if(filters.size == 0) null else filters.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentFetchPostParams = + ExperimentFetchPostParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + cursor, + if (filters.size == 0) null else filters.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** - * A path-lookup filter describes an equality comparison against a specific - * sub-field in the event row. For instance, if you wish to filter on the value of - * `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` and `value="hello"` + * A path-lookup filter describes an equality comparison against a specific sub-field in the + * event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": + * {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` */ @JsonDeserialize(builder = Filter.Builder::class) @NoAutoDetect - class Filter private constructor( - private val type: Type?, - private val path: List?, - private val value: JsonValue?, - private val additionalProperties: Map, - + class Filter + private constructor( + private val type: Type?, + private val path: List?, + private val value: JsonValue?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - fun type(): Type? = type + @JsonProperty("type") fun type(): Type? = type /** - * List of fields describing the path to the value to be checked against. For - * instance, if you wish to filter on the value of `c` in - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For instance, if + * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` */ - @JsonProperty("path") - fun path(): List? = path + @JsonProperty("path") fun path(): List? = path /** - * The value to compare equality-wise against the event value at the specified - * `path`. The value must be a "primitive", that is, any JSON-serializable object - * except for objects and arrays. For instance, if you wish to filter on the value - * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `value="hello"` + * The value to compare equality-wise against the event value at the specified `path`. The + * value must be a "primitive", that is, any JSON-serializable object except for objects and + * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` */ - @JsonProperty("value") - fun value(): JsonValue? = value + @JsonProperty("value") fun value(): JsonValue? = value @JsonAnyGetter @ExcludeMissing @@ -651,35 +586,36 @@ class ExperimentFetchPostParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Filter && + this.type == other.type && + this.path == other.path && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + path, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -698,32 +634,22 @@ class ExperimentFetchPostParams constructor( } /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - fun type(type: Type) = apply { - this.type = type - } + @JsonProperty("type") fun type(type: Type) = apply { this.type = type } /** - * List of fields describing the path to the value to be checked against. For - * instance, if you wish to filter on the value of `c` in - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For instance, + * if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": + * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` */ - @JsonProperty("path") - fun path(path: List) = apply { - this.path = path - } + @JsonProperty("path") fun path(path: List) = apply { this.path = path } /** - * The value to compare equality-wise against the event value at the specified - * `path`. The value must be a "primitive", that is, any JSON-serializable object - * except for objects and arrays. For instance, if you wish to filter on the value - * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `value="hello"` + * The value to compare equality-wise against the event value at the specified `path`. + * The value must be a "primitive", that is, any JSON-serializable object except for + * objects and arrays. For instance, if you wish to filter on the value of "input.a.b.c" + * in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` */ - @JsonProperty("value") - fun value(value: JsonValue) = apply { - this.value = value - } + @JsonProperty("value") fun value(value: JsonValue) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -739,30 +665,29 @@ class ExperimentFetchPostParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Filter = Filter( - checkNotNull(type) { - "`type` is required but was not set" - }, - checkNotNull(path) { - "`path` is required but was not set" - }.toUnmodifiable(), - value, - additionalProperties.toUnmodifiable(), - ) + fun build(): Filter = + Filter( + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(path) { "`path` is required but was not set" }.toUnmodifiable(), + value, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -785,15 +710,17 @@ class ExperimentFetchPostParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + PATH_LOOKUP -> Value.PATH_LOOKUP + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PATH_LOOKUP -> Known.PATH_LOOKUP + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt index 9b5804d..6d08fbf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt @@ -2,40 +2,31 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ExperimentFetchPostResponse.Builder::class) @NoAutoDetect -class ExperimentFetchPostResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { +class ExperimentFetchPostResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { private var validated: Boolean = false @@ -47,25 +38,21 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events() = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -73,42 +60,43 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun validate(): ExperimentFetchPostResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchPostResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentFetchPostResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ExperimentFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -130,29 +118,25 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { - this.events = events - } + fun events(events: JsonField>) = apply { this.events = events } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String) = cursor(JsonField.of(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -168,36 +152,37 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentFetchPostResponse = ExperimentFetchPostResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentFetchPostResponse = + ExperimentFetchPostResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Event.Builder::class) @NoAutoDetect - class Event private constructor( - private val id: JsonField, - private val datasetRecordId: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val experimentId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - + class Event + private constructor( + private val id: JsonField, + private val datasetRecordId: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val experimentId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -205,22 +190,22 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi private var hashCode: Int = 0 /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): String = id.getRequired("id") /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -234,52 +219,49 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun experimentId(): String = experimentId.getRequired("experiment_id") /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical */ fun input(): JsonValue = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -287,194 +269,150 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** The `span_id` of the root of the trace this experiment event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun _datasetRecordId() = datasetRecordId + @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") - @ExcludeMissing - fun _experimentId() = experimentId + @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId() = experimentId /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId() = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ - @JsonProperty("span_parents") - @ExcludeMissing - fun _spanParents() = spanParents + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents /** The `span_id` of the root of the trace this experiment event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes @JsonAnyGetter @ExcludeMissing @@ -482,90 +420,91 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun validate(): Event = apply { if (!validated) { - id() - datasetRecordId() - _xactId() - created() - projectId() - experimentId() - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanId() - spanParents() - rootSpanId() - spanAttributes().map { it.validate() } - validated = true + id() + datasetRecordId() + _xactId() + created() + projectId() + experimentId() + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanId() + spanParents() + rootSpanId() + spanAttributes().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.experimentId == other.experimentId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Event && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this._xactId == other._xactId && + this.created == other.created && + this.projectId == other.projectId && + this.experimentId == other.experimentId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Event{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + override fun toString() = + "Event{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -614,30 +553,29 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi } /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String) = datasetRecordId(JsonField.of(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String) = + datasetRecordId(JsonField.of(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing @@ -646,24 +584,20 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -671,9 +605,7 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -681,9 +613,7 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) @@ -697,94 +627,83 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases are + * the same between experiments, so they should not contain experiment-specific state. A + * simple rule of thumb is that if you run the same experiment twice, the `input` should + * be identical */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * your experiments while digging into analyses. However, we may later use these values + * to re-score outputs or fine-tune your models */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -792,79 +711,67 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ @JsonProperty("span_parents") @ExcludeMissing @@ -878,12 +785,11 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** The `span_id` of the root of the trace this experiment event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -906,43 +812,43 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.putAll(additionalProperties) } - fun build(): Event = Event( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) + fun build(): Event = + Event( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -950,13 +856,16 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi private var hashCode: Int = 0 /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -964,14 +873,10 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -979,45 +884,46 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1036,7 +942,8 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -1046,7 +953,8 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -1075,29 +983,34 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1109,34 +1022,32 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1158,29 +1069,30 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1188,68 +1100,62 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi private var hashCode: Int = 0 /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1257,51 +1163,52 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1324,36 +1231,32 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi } /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Double) = start(JsonField.of(start)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Double) = end(JsonField.of(end)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the experiment event (only @@ -1375,7 +1278,8 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** * The number of tokens in the completion generated by the model (only set if this @@ -1393,9 +1297,7 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1407,34 +1309,38 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1446,34 +1352,32 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1495,9 +1399,10 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -1506,7 +1411,12 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1519,14 +1429,10 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1534,42 +1440,43 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1591,9 +1498,7 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -1601,9 +1506,7 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1615,29 +1518,33 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1680,25 +1587,27 @@ class ExperimentFetchPostResponse private constructor(private val events: JsonFi _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt index 89c5ce3..254cc0f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt @@ -2,40 +2,31 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ExperimentFetchResponse.Builder::class) @NoAutoDetect -class ExperimentFetchResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { +class ExperimentFetchResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { private var validated: Boolean = false @@ -47,25 +38,21 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events() = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -73,42 +60,43 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun validate(): ExperimentFetchResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentFetchResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ExperimentFetchResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentFetchResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -130,29 +118,25 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { - this.events = events - } + fun events(events: JsonField>) = apply { this.events = events } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String) = cursor(JsonField.of(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -168,36 +152,37 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentFetchResponse = ExperimentFetchResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentFetchResponse = + ExperimentFetchResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Event.Builder::class) @NoAutoDetect - class Event private constructor( - private val id: JsonField, - private val datasetRecordId: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val experimentId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - + class Event + private constructor( + private val id: JsonField, + private val datasetRecordId: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val experimentId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -205,22 +190,22 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< private var hashCode: Int = 0 /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): String = id.getRequired("id") /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -234,52 +219,49 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun experimentId(): String = experimentId.getRequired("experiment_id") /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical */ fun input(): JsonValue = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -287,194 +269,150 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** The `span_id` of the root of the trace this experiment event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun _datasetRecordId() = datasetRecordId + @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") - @ExcludeMissing - fun _experimentId() = experimentId + @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId() = experimentId /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId() = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ - @JsonProperty("span_parents") - @ExcludeMissing - fun _spanParents() = spanParents + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents /** The `span_id` of the root of the trace this experiment event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes @JsonAnyGetter @ExcludeMissing @@ -482,90 +420,91 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun validate(): Event = apply { if (!validated) { - id() - datasetRecordId() - _xactId() - created() - projectId() - experimentId() - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanId() - spanParents() - rootSpanId() - spanAttributes().map { it.validate() } - validated = true + id() + datasetRecordId() + _xactId() + created() + projectId() + experimentId() + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanId() + spanParents() + rootSpanId() + spanAttributes().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.experimentId == other.experimentId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Event && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this._xactId == other._xactId && + this.created == other.created && + this.projectId == other.projectId && + this.experimentId == other.experimentId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Event{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + override fun toString() = + "Event{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -614,30 +553,29 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< } /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String) = datasetRecordId(JsonField.of(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String) = + datasetRecordId(JsonField.of(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing @@ -646,24 +584,20 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -671,9 +605,7 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -681,9 +613,7 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) @@ -697,94 +627,83 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases are + * the same between experiments, so they should not contain experiment-specific state. A + * simple rule of thumb is that if you run the same experiment twice, the `input` should + * be identical */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * your experiments while digging into analyses. However, we may later use these values + * to re-score outputs or fine-tune your models */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -792,79 +711,67 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ @JsonProperty("span_parents") @ExcludeMissing @@ -878,12 +785,11 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** The `span_id` of the root of the trace this experiment event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -906,43 +812,43 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< this.additionalProperties.putAll(additionalProperties) } - fun build(): Event = Event( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) + fun build(): Event = + Event( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -950,13 +856,16 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< private var hashCode: Int = 0 /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -964,14 +873,10 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -979,45 +884,46 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1036,7 +942,8 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -1046,7 +953,8 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -1075,29 +983,34 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1109,34 +1022,32 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1158,29 +1069,30 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1188,68 +1100,62 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< private var hashCode: Int = 0 /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1257,51 +1163,52 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1324,36 +1231,32 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< } /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Double) = start(JsonField.of(start)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Double) = end(JsonField.of(end)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the experiment event (only @@ -1375,7 +1278,8 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** * The number of tokens in the completion generated by the model (only set if this @@ -1393,9 +1297,7 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1407,34 +1309,38 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1446,34 +1352,32 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1495,9 +1399,10 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -1506,7 +1411,12 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1519,14 +1429,10 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1534,42 +1440,43 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1591,9 +1498,7 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -1601,9 +1506,7 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1615,29 +1518,33 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1680,25 +1587,27 @@ class ExperimentFetchResponse private constructor(private val events: JsonField< _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 76aa2e5..36e22df 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -2,47 +2,40 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ExperimentInsertParams constructor( - private val experimentId: String, - private val events: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ExperimentInsertParams +constructor( + private val experimentId: String, + private val events: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -51,31 +44,32 @@ class ExperimentInsertParams constructor( @JvmSynthetic internal fun getBody(): ExperimentInsertBody { - return ExperimentInsertBody(events, additionalBodyProperties) + return ExperimentInsertBody(events, additionalBodyProperties) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentInsertBody.Builder::class) @NoAutoDetect - class ExperimentInsertBody internal constructor(private val events: List?, private val additionalProperties: Map, ) { + class ExperimentInsertBody + internal constructor( + private val events: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** A list of experiment events to insert */ - @JsonProperty("events") - fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -84,28 +78,28 @@ class ExperimentInsertParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ExperimentInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties + return other is ExperimentInsertBody && + this.events == other.events && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode } - override fun toString() = "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -120,10 +114,7 @@ class ExperimentInsertParams constructor( } /** A list of experiment events to insert */ - @JsonProperty("events") - fun events(events: List) = apply { - this.events = events - } + @JsonProperty("events") fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -139,9 +130,12 @@ class ExperimentInsertParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentInsertBody = ExperimentInsertBody(checkNotNull(events) { - "`events` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) + fun build(): ExperimentInsertBody = + ExperimentInsertBody( + checkNotNull(events) { "`events` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) } } @@ -152,36 +146,36 @@ class ExperimentInsertParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentInsertParams && - this.experimentId == other.experimentId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentInsertParams && + this.experimentId == other.experimentId && + this.events == other.events && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + events, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -203,9 +197,7 @@ class ExperimentInsertParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment events to insert */ fun events(events: List) = apply { @@ -214,9 +206,7 @@ class ExperimentInsertParams constructor( } /** A list of experiment events to insert */ - fun addEvent(event: Event) = apply { - this.events.add(event) - } + fun addEvent(event: Event) = apply { this.events.add(event) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,9 +246,7 @@ class ExperimentInsertParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -269,149 +257,181 @@ class ExperimentInsertParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentInsertParams = ExperimentInsertParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - checkNotNull(events) { - "`events` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentInsertParams = + ExperimentInsertParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Event.Deserializer::class) @JsonSerialize(using = Event.Serializer::class) - class Event private constructor(private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, private val _json: JsonValue? = null, ) { + class Event + private constructor( + private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, + private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun insertExperimentEventReplace(): Optional = Optional.ofNullable(insertExperimentEventReplace) - fun insertExperimentEventMerge(): Optional = Optional.ofNullable(insertExperimentEventMerge) + fun insertExperimentEventReplace(): Optional = + Optional.ofNullable(insertExperimentEventReplace) + + fun insertExperimentEventMerge(): Optional = + Optional.ofNullable(insertExperimentEventMerge) fun isInsertExperimentEventReplace(): Boolean = insertExperimentEventReplace != null + fun isInsertExperimentEventMerge(): Boolean = insertExperimentEventMerge != null - fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") - fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") + fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = + insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") + + fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = + insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - insertExperimentEventReplace != null -> visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) - insertExperimentEventMerge != null -> visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) - else -> visitor.unknown(_json) - } + return when { + insertExperimentEventReplace != null -> + visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) + insertExperimentEventMerge != null -> + visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) + else -> visitor.unknown(_json) + } } fun validate(): Event = apply { if (!validated) { - if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertExperimentEventReplace?.validate() - insertExperimentEventMerge?.validate() - validated = true + if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { + throw BraintrustInvalidDataException("Unknown Event: $_json") + } + insertExperimentEventReplace?.validate() + insertExperimentEventMerge?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Event && - this.insertExperimentEventReplace == other.insertExperimentEventReplace && - this.insertExperimentEventMerge == other.insertExperimentEventMerge + return other is Event && + this.insertExperimentEventReplace == other.insertExperimentEventReplace && + this.insertExperimentEventMerge == other.insertExperimentEventMerge } override fun hashCode(): Int { - return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) + return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) } override fun toString(): String { - return when { - insertExperimentEventReplace != null -> "Event{insertExperimentEventReplace=$insertExperimentEventReplace}" - insertExperimentEventMerge != null -> "Event{insertExperimentEventMerge=$insertExperimentEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } + return when { + insertExperimentEventReplace != null -> + "Event{insertExperimentEventReplace=$insertExperimentEventReplace}" + insertExperimentEventMerge != null -> + "Event{insertExperimentEventMerge=$insertExperimentEventMerge}" + _json != null -> "Event{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Event") + } } companion object { @JvmStatic - fun ofInsertExperimentEventReplace(insertExperimentEventReplace: InsertExperimentEventReplace) = Event(insertExperimentEventReplace = insertExperimentEventReplace) + fun ofInsertExperimentEventReplace( + insertExperimentEventReplace: InsertExperimentEventReplace + ) = Event(insertExperimentEventReplace = insertExperimentEventReplace) @JvmStatic - fun ofInsertExperimentEventMerge(insertExperimentEventMerge: InsertExperimentEventMerge) = Event(insertExperimentEventMerge = insertExperimentEventMerge) + fun ofInsertExperimentEventMerge( + insertExperimentEventMerge: InsertExperimentEventMerge + ) = Event(insertExperimentEventMerge = insertExperimentEventMerge) } interface Visitor { - fun visitInsertExperimentEventReplace(insertExperimentEventReplace: InsertExperimentEventReplace): T + fun visitInsertExperimentEventReplace( + insertExperimentEventReplace: InsertExperimentEventReplace + ): T - fun visitInsertExperimentEventMerge(insertExperimentEventMerge: InsertExperimentEventMerge): T + fun visitInsertExperimentEventMerge( + insertExperimentEventMerge: InsertExperimentEventMerge + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") + throw BraintrustInvalidDataException("Unknown Event: $json") } } class Deserializer : BaseDeserializer(Event::class) { override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Event(insertExperimentEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Event(insertExperimentEventMerge = it, _json = json) - } - - return Event(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Event(insertExperimentEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Event(insertExperimentEventMerge = it, _json = json) + } + + return Event(_json = json) } } class Serializer : BaseSerializer(Event::class) { - override fun serialize(value: Event, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.insertExperimentEventReplace != null -> generator.writeObject(value.insertExperimentEventReplace) - value.insertExperimentEventMerge != null -> generator.writeObject(value.insertExperimentEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } + override fun serialize( + value: Event, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.insertExperimentEventReplace != null -> + generator.writeObject(value.insertExperimentEventReplace) + value.insertExperimentEventMerge != null -> + generator.writeObject(value.insertExperimentEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Event") + } } } @JsonDeserialize(builder = InsertExperimentEventReplace.Builder::class) @NoAutoDetect - class InsertExperimentEventReplace private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, - + class InsertExperimentEventReplace + private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val datasetRecordId: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -420,279 +440,252 @@ class ExperimentInsertParams constructor( /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases are + * the same between experiments, so they should not contain experiment-specific state. A + * simple rule of thumb is that if you run the same experiment twice, the `input` should + * be identical */ fun input(): JsonValue = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * your experiments while digging into analyses. However, we may later use these values + * to re-score outputs or fine-tune your models */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The timestamp the experiment event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun created(): Optional = + Optional.ofNullable(created.getNullable("created")) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will + * not show up in subsequent fetches for this experiment */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + fun _isMerge(): Optional = + Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships + * are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": + * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, + * only the root span row `"abc"` will show up in the summary view. You can view the + * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" + * row. */ - fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + fun _parentId(): Optional = + Optional.ofNullable(_parentId.getNullable("_parent_id")) /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases are + * the same between experiments, so they should not contain experiment-specific state. A + * simple rule of thumb is that if you run the same experiment twice, the `input` should + * be identical */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * your experiments while digging into analyses. However, we may later use these values + * to re-score outputs or fine-tune your models */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will + * not show up in subsequent fetches for this experiment */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships + * are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": + * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, + * only the root span row `"abc"` will show up in the summary view. You can view the + * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" + * row. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun __parentId() = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId @JsonAnyGetter @ExcludeMissing @@ -700,81 +693,82 @@ class ExperimentInsertParams constructor( fun validate(): InsertExperimentEventReplace = apply { if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + datasetRecordId() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertExperimentEventReplace && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -797,75 +791,69 @@ class ExperimentInsertParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertExperimentEventReplace: InsertExperimentEventReplace) = apply { - this.input = insertExperimentEventReplace.input - this.output = insertExperimentEventReplace.output - this.expected = insertExperimentEventReplace.expected - this.scores = insertExperimentEventReplace.scores - this.metadata = insertExperimentEventReplace.metadata - this.tags = insertExperimentEventReplace.tags - this.metrics = insertExperimentEventReplace.metrics - this.context = insertExperimentEventReplace.context - this.spanAttributes = insertExperimentEventReplace.spanAttributes - this.id = insertExperimentEventReplace.id - this.datasetRecordId = insertExperimentEventReplace.datasetRecordId - this.created = insertExperimentEventReplace.created - this._objectDelete = insertExperimentEventReplace._objectDelete - this._isMerge = insertExperimentEventReplace._isMerge - this._parentId = insertExperimentEventReplace._parentId - additionalProperties(insertExperimentEventReplace.additionalProperties) - } + internal fun from(insertExperimentEventReplace: InsertExperimentEventReplace) = + apply { + this.input = insertExperimentEventReplace.input + this.output = insertExperimentEventReplace.output + this.expected = insertExperimentEventReplace.expected + this.scores = insertExperimentEventReplace.scores + this.metadata = insertExperimentEventReplace.metadata + this.tags = insertExperimentEventReplace.tags + this.metrics = insertExperimentEventReplace.metrics + this.context = insertExperimentEventReplace.context + this.spanAttributes = insertExperimentEventReplace.spanAttributes + this.id = insertExperimentEventReplace.id + this.datasetRecordId = insertExperimentEventReplace.datasetRecordId + this.created = insertExperimentEventReplace.created + this._objectDelete = insertExperimentEventReplace._objectDelete + this._isMerge = insertExperimentEventReplace._isMerge + this._parentId = insertExperimentEventReplace._parentId + additionalProperties(insertExperimentEventReplace.additionalProperties) + } /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases + * are the same between experiments, so they should not contain experiment-specific + * state. A simple rule of thumb is that if you run the same experiment twice, the + * `input` should be identical */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, + * or not. For example, in an app that generates SQL queries, the `output` should be + * the _result_ of the SQL query generated by the model, not the query itself, * because there may be multiple valid queries that answer a single question */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * Braintrust currently does not compare `output` to `expected` for you, since there + * are so many different ways to do that correctly. Instead, these values are just + * used to help you navigate your experiments while digging into analyses. However, + * we may later use these values to re-score outputs or fine-tune your models */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare experiments */ fun scores(scores: Scores) = scores(JsonField.of(scores)) @@ -874,16 +862,14 @@ class ExperimentInsertParams constructor( * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare experiments */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just @@ -903,9 +889,7 @@ class ExperimentInsertParams constructor( */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -913,9 +897,7 @@ class ExperimentInsertParams constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** * Metrics are numerical measurements tracking the execution of the code that @@ -931,32 +913,27 @@ class ExperimentInsertParams constructor( */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the experiment event */ fun context(context: Context) = context(JsonField.of(context)) /** * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the experiment event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -977,15 +954,14 @@ class ExperimentInsertParams constructor( */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** * If the experiment is associated to a dataset, this is the event-level dataset id * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String) = datasetRecordId(JsonField.of(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String) = + datasetRecordId(JsonField.of(datasetRecordId)) /** * If the experiment is associated to a dataset, this is the event-level dataset id @@ -1003,15 +979,14 @@ class ExperimentInsertParams constructor( /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean) = + _objectDelete(JsonField.of(_objectDelete)) /** * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events @@ -1029,12 +1004,12 @@ class ExperimentInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) @@ -1044,54 +1019,50 @@ class ExperimentInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical * relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": + * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a + * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": + * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in + * the summary view. You can view the full trace hierarchy (in this case, the + * `"llm_call"` row) by clicking on the "abc" row. */ fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical * relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": + * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a + * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": + * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in + * the summary view. You can view the full trace hierarchy (in this case, the + * `"llm_call"` row) by clicking on the "abc" row. */ @JsonProperty("_parent_id") @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { - this._parentId = _parentId - } + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1103,44 +1074,45 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): InsertExperimentEventReplace = InsertExperimentEventReplace( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertExperimentEventReplace = + InsertExperimentEventReplace( + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1148,13 +1120,16 @@ class ExperimentInsertParams constructor( private var hashCode: Int = 0 /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -1167,9 +1142,7 @@ class ExperimentInsertParams constructor( fun _callerFilename() = callerFilename /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -1177,45 +1150,46 @@ class ExperimentInsertParams constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1234,7 +1208,8 @@ class ExperimentInsertParams constructor( } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -1244,7 +1219,8 @@ class ExperimentInsertParams constructor( } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -1273,29 +1249,34 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1307,34 +1288,33 @@ class ExperimentInsertParams constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1356,29 +1336,30 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1386,14 +1367,14 @@ class ExperimentInsertParams constructor( private var hashCode: Int = 0 /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) @@ -1401,40 +1382,36 @@ class ExperimentInsertParams constructor( * The number of tokens in the prompt used to generate the experiment event (only * set if this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** * The number of tokens in the prompt used to generate the experiment event (only * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** * The number of tokens in the completion generated by the model (only set if this @@ -1445,9 +1422,7 @@ class ExperimentInsertParams constructor( fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1455,51 +1430,52 @@ class ExperimentInsertParams constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1533,9 +1509,7 @@ class ExperimentInsertParams constructor( */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** * A unix timestamp recording when the section of code which produced the @@ -1549,19 +1523,17 @@ class ExperimentInsertParams constructor( */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event + * (only set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event + * (only set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1570,14 +1542,15 @@ class ExperimentInsertParams constructor( } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1585,15 +1558,17 @@ class ExperimentInsertParams constructor( this.completionTokens = completionTokens } - /** The total number of tokens in the input and output of the experiment event. */ + /** + * The total number of tokens in the input and output of the experiment event. + */ fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * The total number of tokens in the input and output of the experiment event. + */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1605,34 +1580,39 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1644,34 +1624,33 @@ class ExperimentInsertParams constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1693,9 +1672,10 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -1704,7 +1684,12 @@ class ExperimentInsertParams constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1717,14 +1702,10 @@ class ExperimentInsertParams constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1732,42 +1713,43 @@ class ExperimentInsertParams constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1789,9 +1771,7 @@ class ExperimentInsertParams constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -1799,9 +1779,7 @@ class ExperimentInsertParams constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1813,29 +1791,34 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1878,25 +1861,27 @@ class ExperimentInsertParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1905,24 +1890,24 @@ class ExperimentInsertParams constructor( @JsonDeserialize(builder = InsertExperimentEventMerge.Builder::class) @NoAutoDetect - class InsertExperimentEventMerge private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, - + class InsertExperimentEventMerge + private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val datasetRecordId: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1931,281 +1916,251 @@ class ExperimentInsertParams constructor( /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases are + * the same between experiments, so they should not contain experiment-specific state. A + * simple rule of thumb is that if you run the same experiment twice, the `input` should + * be identical */ fun input(): JsonValue = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * your experiments while digging into analyses. However, we may later use these values + * to re-score outputs or fine-tune your models */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The timestamp the experiment event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun created(): Optional = + Optional.ofNullable(created.getNullable("created")) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will + * not show up in subsequent fetches for this experiment */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each + * path is a list of field names. The deep merge will not descend below any of the + * specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, + * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced + * `input.a` and `output`, but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases are + * the same between experiments, so they should not contain experiment-specific state. A + * simple rule of thumb is that if you run the same experiment twice, the `input` should + * be identical */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * your experiments while digging into analyses. However, we may later use these values + * to re-score outputs or fine-tune your models */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will + * not show up in subsequent fetches for this experiment */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each + * path is a list of field names. The deep merge will not descend below any of the + * specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, + * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced + * `input.a` and `output`, but have still deep-merged `input` and `input.c`. */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths @JsonAnyGetter @ExcludeMissing @@ -2213,81 +2168,82 @@ class ExperimentInsertParams constructor( fun validate(): InsertExperimentEventMerge = apply { if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + datasetRecordId() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertExperimentEventMerge && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2331,54 +2287,47 @@ class ExperimentInsertParams constructor( /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * object). Later on, Braintrust will use the `input` to know whether two test cases + * are the same between experiments, so they should not contain experiment-specific + * state. A simple rule of thumb is that if you run the same experiment twice, the + * `input` should be identical */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, + * or not. For example, in an app that generates SQL queries, the `output` should be + * the _result_ of the SQL query generated by the model, not the query itself, * because there may be multiple valid queries that answer a single question */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * Braintrust currently does not compare `output` to `expected` for you, since there + * are so many different ways to do that correctly. Instead, these values are just + * used to help you navigate your experiments while digging into analyses. However, + * we may later use these values to re-score outputs or fine-tune your models */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare experiments */ fun scores(scores: Scores) = scores(JsonField.of(scores)) @@ -2387,16 +2336,14 @@ class ExperimentInsertParams constructor( * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare experiments */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just @@ -2416,9 +2363,7 @@ class ExperimentInsertParams constructor( */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -2426,9 +2371,7 @@ class ExperimentInsertParams constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** * Metrics are numerical measurements tracking the execution of the code that @@ -2444,32 +2387,27 @@ class ExperimentInsertParams constructor( */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the experiment event */ fun context(context: Context) = context(JsonField.of(context)) /** * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the experiment event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -2490,15 +2428,14 @@ class ExperimentInsertParams constructor( */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** * If the experiment is associated to a dataset, this is the event-level dataset id * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String) = datasetRecordId(JsonField.of(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String) = + datasetRecordId(JsonField.of(datasetRecordId)) /** * If the experiment is associated to a dataset, this is the event-level dataset id @@ -2516,15 +2453,14 @@ class ExperimentInsertParams constructor( /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean) = + _objectDelete(JsonField.of(_objectDelete)) /** * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events @@ -2542,12 +2478,12 @@ class ExperimentInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) @@ -2557,50 +2493,49 @@ class ExperimentInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where + * each path is a list of field names. The deep merge will not descend below any of + * the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will + * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": + * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have + * replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ - fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + fun _mergePaths(_mergePaths: List>) = + _mergePaths(JsonField.of(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where + * each path is a list of field names. The deep merge will not descend below any of + * the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will + * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": + * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have + * replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing @@ -2618,44 +2553,45 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): InsertExperimentEventMerge = InsertExperimentEventMerge( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertExperimentEventMerge = + InsertExperimentEventMerge( + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. + * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes + * to track the location in code which produced the experiment event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2663,13 +2599,16 @@ class ExperimentInsertParams constructor( private var hashCode: Int = 0 /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -2682,9 +2621,7 @@ class ExperimentInsertParams constructor( fun _callerFilename() = callerFilename /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -2692,45 +2629,46 @@ class ExperimentInsertParams constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2749,7 +2687,8 @@ class ExperimentInsertParams constructor( } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -2759,7 +2698,8 @@ class ExperimentInsertParams constructor( } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -2788,29 +2728,34 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2822,34 +2767,33 @@ class ExperimentInsertParams constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2871,29 +2815,30 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the experiment event. Use "start" and "end" to track the time span over which the + * experiment event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2901,14 +2846,14 @@ class ExperimentInsertParams constructor( private var hashCode: Int = 0 /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) @@ -2916,40 +2861,36 @@ class ExperimentInsertParams constructor( * The number of tokens in the prompt used to generate the experiment event (only * set if this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** * The number of tokens in the prompt used to generate the experiment event (only * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** * The number of tokens in the completion generated by the model (only set if this @@ -2960,9 +2901,7 @@ class ExperimentInsertParams constructor( fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -2970,51 +2909,52 @@ class ExperimentInsertParams constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3048,9 +2988,7 @@ class ExperimentInsertParams constructor( */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** * A unix timestamp recording when the section of code which produced the @@ -3064,19 +3002,17 @@ class ExperimentInsertParams constructor( */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event + * (only set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event + * (only set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -3085,14 +3021,15 @@ class ExperimentInsertParams constructor( } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -3100,15 +3037,17 @@ class ExperimentInsertParams constructor( this.completionTokens = completionTokens } - /** The total number of tokens in the input and output of the experiment event. */ + /** + * The total number of tokens in the input and output of the experiment event. + */ fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * The total number of tokens in the input and output of the experiment event. + */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3120,34 +3059,39 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare + * experiments */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3159,34 +3103,33 @@ class ExperimentInsertParams constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3208,9 +3151,10 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -3219,7 +3163,12 @@ class ExperimentInsertParams constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3232,14 +3181,10 @@ class ExperimentInsertParams constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -3247,42 +3192,43 @@ class ExperimentInsertParams constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3304,9 +3250,7 @@ class ExperimentInsertParams constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -3314,9 +3258,7 @@ class ExperimentInsertParams constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3328,29 +3270,34 @@ class ExperimentInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3393,25 +3340,27 @@ class ExperimentInsertParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt index 4898a9e..671b2e2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt @@ -2,58 +2,39 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ExperimentInsertResponse.Builder::class) @NoAutoDetect -class ExperimentInsertResponse private constructor(private val rowIds: JsonField>, private val additionalProperties: Map, ) { +class ExperimentInsertResponse +private constructor( + private val rowIds: JsonField>, + private val additionalProperties: Map, +) { private var validated: Boolean = false private var hashCode: Int = 0 /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ fun rowIds(): List = rowIds.getRequired("row_ids") /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ - @JsonProperty("row_ids") - @ExcludeMissing - fun _rowIds() = rowIds + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds @JsonAnyGetter @ExcludeMissing @@ -61,36 +42,36 @@ class ExperimentInsertResponse private constructor(private val rowIds: JsonField fun validate(): ExperimentInsertResponse = apply { if (!validated) { - rowIds() - validated = true + rowIds() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ExperimentInsertResponse && - this.rowIds == other.rowIds && - this.additionalProperties == other.additionalProperties + return other is ExperimentInsertResponse && + this.rowIds == other.rowIds && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(rowIds, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(rowIds, additionalProperties) + } + return hashCode } - override fun toString() = "ExperimentInsertResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentInsertResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -105,20 +86,18 @@ class ExperimentInsertResponse private constructor(private val rowIds: JsonField } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ @JsonProperty("row_ids") @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { - this.rowIds = rowIds - } + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -134,6 +113,10 @@ class ExperimentInsertResponse private constructor(private val rowIds: JsonField this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentInsertResponse = ExperimentInsertResponse(rowIds.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable()) + fun build(): ExperimentInsertResponse = + ExperimentInsertResponse( + rowIds.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 1af799b..18eb99a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -2,79 +2,83 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.ExperimentService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Experiment -import com.braintrustdata.api.services.blocking.ExperimentService -class ExperimentListPage private constructor(private val experimentsService: ExperimentService, private val params: ExperimentListParams, private val response: Response, ) { +class ExperimentListPage +private constructor( + private val experimentsService: ExperimentService, + private val params: ExperimentListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentListPage && - this.experimentsService == other.experimentsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ExperimentListPage && + this.experimentsService == other.experimentsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - experimentsService, - params, - response, - ) + return Objects.hash( + experimentsService, + params, + response, + ) } - override fun toString() = "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = + "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ExperimentListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ExperimentListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { experimentsService.list(it) } + return getNextPageParams().map { experimentsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +86,25 @@ class ExperimentListPage private constructor(private val experimentsService: Exp companion object { @JvmStatic - fun of(experimentsService: ExperimentService, params: ExperimentListParams, response: Response) = ExperimentListPage( - experimentsService, - params, - response, - ) + fun of( + experimentsService: ExperimentService, + params: ExperimentListParams, + response: Response + ) = + ExperimentListPage( + experimentsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +119,33 @@ class ExperimentListPage private constructor(private val experimentsService: Exp fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ExperimentListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +173,25 @@ class ExperimentListPage private constructor(private val experimentsService: Exp } } - class AutoPager constructor(private val firstPage: ExperimentListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: ExperimentListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index 933f249..2b5d3b7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -2,83 +2,86 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.ExperimentServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Experiment -import com.braintrustdata.api.services.async.ExperimentServiceAsync -class ExperimentListPageAsync private constructor(private val experimentsService: ExperimentServiceAsync, private val params: ExperimentListParams, private val response: Response, ) { +class ExperimentListPageAsync +private constructor( + private val experimentsService: ExperimentServiceAsync, + private val params: ExperimentListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentListPageAsync && - this.experimentsService == other.experimentsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ExperimentListPageAsync && + this.experimentsService == other.experimentsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - experimentsService, - params, - response, - ) + return Objects.hash( + experimentsService, + params, + response, + ) } - override fun toString() = "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = + "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ExperimentListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ExperimentListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - experimentsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { experimentsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +89,25 @@ class ExperimentListPageAsync private constructor(private val experimentsService companion object { @JvmStatic - fun of(experimentsService: ExperimentServiceAsync, params: ExperimentListParams, response: Response) = ExperimentListPageAsync( - experimentsService, - params, - response, - ) + fun of( + experimentsService: ExperimentServiceAsync, + params: ExperimentListParams, + response: Response + ) = + ExperimentListPageAsync( + experimentsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +122,33 @@ class ExperimentListPageAsync private constructor(private val experimentsService fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ExperimentListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +176,32 @@ class ExperimentListPageAsync private constructor(private val experimentsService } } - class AutoPager constructor(private val firstPage: ExperimentListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: ExperimentListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Experiment) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Experiment) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 6a04358..5a310e4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -2,52 +2,36 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ExperimentListParams constructor( - private val endingBefore: String?, - private val experimentName: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ExperimentListParams +constructor( + private val endingBefore: String?, + private val experimentName: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -66,34 +50,19 @@ class ExperimentListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.experimentName?.let { - params.put("experiment_name", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.experimentName?.let { params.put("experiment_name", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -102,46 +71,46 @@ class ExperimentListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentListParams && - this.endingBefore == other.endingBefore && - this.experimentName == other.experimentName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentListParams && + this.endingBefore == other.endingBefore && + this.experimentName == other.experimentName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + experimentName, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -175,68 +144,50 @@ class ExperimentListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** Name of the experiment to search for */ - fun experimentName(experimentName: String) = apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: String) = apply { this.experimentName = experimentName } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -276,9 +227,7 @@ class ExperimentListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -289,88 +238,94 @@ class ExperimentListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentListParams = ExperimentListParams( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentListParams = + ExperimentListParams( + endingBefore, + experimentName, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -380,34 +335,38 @@ class ExperimentListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentReplaceParams.kt deleted file mode 100644 index 2c816f9..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentReplaceParams.kt +++ /dev/null @@ -1,761 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional - -class ExperimentReplaceParams -constructor( - private val projectId: String, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun projectId(): String = projectId - - fun baseExpId(): Optional = Optional.ofNullable(baseExpId) - - fun datasetId(): Optional = Optional.ofNullable(datasetId) - - fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion) - - fun description(): Optional = Optional.ofNullable(description) - - fun ensureNew(): Optional = Optional.ofNullable(ensureNew) - - fun metadata(): Optional = Optional.ofNullable(metadata) - - fun name(): Optional = Optional.ofNullable(name) - - fun public_(): Optional = Optional.ofNullable(public_) - - fun repoInfo(): Optional = Optional.ofNullable(repoInfo) - - @JvmSynthetic - internal fun getBody(): ExperimentReplaceBody { - return ExperimentReplaceBody( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JsonDeserialize(builder = ExperimentReplaceBody.Builder::class) - @NoAutoDetect - class ExperimentReplaceBody - internal constructor( - private val projectId: String?, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId - - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId - - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ - @JsonProperty("dataset_id") fun datasetId(): String? = datasetId - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - @JsonProperty("dataset_version") fun datasetVersion(): String? = datasetVersion - - /** Textual description of the experiment */ - @JsonProperty("description") fun description(): String? = description - - /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. - */ - @JsonProperty("ensure_new") fun ensureNew(): Boolean? = ensureNew - - /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata - - /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(): String? = name - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - @JsonProperty("public") fun public_(): Boolean? = public_ - - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentReplaceBody && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentReplaceBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var projectId: String? = null - private var baseExpId: String? = null - private var datasetId: String? = null - private var datasetVersion: String? = null - private var description: String? = null - private var ensureNew: Boolean? = null - private var metadata: Metadata? = null - private var name: String? = null - private var public_: Boolean? = null - private var repoInfo: RepoInfo? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(experimentReplaceBody: ExperimentReplaceBody) = apply { - this.projectId = experimentReplaceBody.projectId - this.baseExpId = experimentReplaceBody.baseExpId - this.datasetId = experimentReplaceBody.datasetId - this.datasetVersion = experimentReplaceBody.datasetVersion - this.description = experimentReplaceBody.description - this.ensureNew = experimentReplaceBody.ensureNew - this.metadata = experimentReplaceBody.metadata - this.name = experimentReplaceBody.name - this.public_ = experimentReplaceBody.public_ - this.repoInfo = experimentReplaceBody.repoInfo - additionalProperties(experimentReplaceBody.additionalProperties) - } - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } - - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } - - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ - @JsonProperty("dataset_id") - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } - - /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. - */ - @JsonProperty("dataset_version") - fun datasetVersion(datasetVersion: String) = apply { - this.datasetVersion = datasetVersion - } - - /** Textual description of the experiment */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } - - /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. - */ - @JsonProperty("ensure_new") - fun ensureNew(ensureNew: Boolean) = apply { this.ensureNew = ensureNew } - - /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } - - /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - @JsonProperty("public") fun public_(public_: Boolean) = apply { this.public_ = public_ } - - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ExperimentReplaceBody = - ExperimentReplaceBody( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties.toUnmodifiable(), - ) - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentReplaceParams && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "ExperimentReplaceParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var projectId: String? = null - private var baseExpId: String? = null - private var datasetId: String? = null - private var datasetVersion: String? = null - private var description: String? = null - private var ensureNew: Boolean? = null - private var metadata: Metadata? = null - private var name: String? = null - private var public_: Boolean? = null - private var repoInfo: RepoInfo? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(experimentReplaceParams: ExperimentReplaceParams) = apply { - this.projectId = experimentReplaceParams.projectId - this.baseExpId = experimentReplaceParams.baseExpId - this.datasetId = experimentReplaceParams.datasetId - this.datasetVersion = experimentReplaceParams.datasetVersion - this.description = experimentReplaceParams.description - this.ensureNew = experimentReplaceParams.ensureNew - this.metadata = experimentReplaceParams.metadata - this.name = experimentReplaceParams.name - this.public_ = experimentReplaceParams.public_ - this.repoInfo = experimentReplaceParams.repoInfo - additionalQueryParams(experimentReplaceParams.additionalQueryParams) - additionalHeaders(experimentReplaceParams.additionalHeaders) - additionalBodyProperties(experimentReplaceParams.additionalBodyProperties) - } - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } - - /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } - - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - fun datasetVersion(datasetVersion: String) = apply { this.datasetVersion = datasetVersion } - - /** Textual description of the experiment */ - fun description(description: String) = apply { this.description = description } - - /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. - */ - fun ensureNew(ensureNew: Boolean) = apply { this.ensureNew = ensureNew } - - /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } - - /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = apply { this.name = name } - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - fun public_(public_: Boolean) = apply { this.public_ = public_ } - - /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ExperimentReplaceParams = - ExperimentReplaceParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } - - /** User-controlled metadata about the experiment */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** Metadata about the state of the repo when the experiment was created */ - @JsonDeserialize(builder = RepoInfo.Builder::class) - @NoAutoDetect - class RepoInfo - private constructor( - private val commit: String?, - private val branch: String?, - private val tag: String?, - private val dirty: Boolean?, - private val authorName: String?, - private val authorEmail: String?, - private val commitMessage: String?, - private val commitTime: String?, - private val gitDiff: String?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** SHA of most recent commit */ - @JsonProperty("commit") fun commit(): String? = commit - - /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") fun branch(): String? = branch - - /** Name of the tag on the most recent commit */ - @JsonProperty("tag") fun tag(): String? = tag - - /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") fun dirty(): Boolean? = dirty - - /** Name of the author of the most recent commit */ - @JsonProperty("author_name") fun authorName(): String? = authorName - - /** Email of the author of the most recent commit */ - @JsonProperty("author_email") fun authorEmail(): String? = authorEmail - - /** Most recent commit message */ - @JsonProperty("commit_message") fun commitMessage(): String? = commitMessage - - /** Time of the most recent commit */ - @JsonProperty("commit_time") fun commitTime(): String? = commitTime - - /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. - */ - @JsonProperty("git_diff") fun gitDiff(): String? = gitDiff - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RepoInfo && - this.commit == other.commit && - this.branch == other.branch && - this.tag == other.tag && - this.dirty == other.dirty && - this.authorName == other.authorName && - this.authorEmail == other.authorEmail && - this.commitMessage == other.commitMessage && - this.commitTime == other.commitTime && - this.gitDiff == other.gitDiff && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var commit: String? = null - private var branch: String? = null - private var tag: String? = null - private var dirty: Boolean? = null - private var authorName: String? = null - private var authorEmail: String? = null - private var commitMessage: String? = null - private var commitTime: String? = null - private var gitDiff: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(repoInfo: RepoInfo) = apply { - this.commit = repoInfo.commit - this.branch = repoInfo.branch - this.tag = repoInfo.tag - this.dirty = repoInfo.dirty - this.authorName = repoInfo.authorName - this.authorEmail = repoInfo.authorEmail - this.commitMessage = repoInfo.commitMessage - this.commitTime = repoInfo.commitTime - this.gitDiff = repoInfo.gitDiff - additionalProperties(repoInfo.additionalProperties) - } - - /** SHA of most recent commit */ - @JsonProperty("commit") fun commit(commit: String) = apply { this.commit = commit } - - /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") fun branch(branch: String) = apply { this.branch = branch } - - /** Name of the tag on the most recent commit */ - @JsonProperty("tag") fun tag(tag: String) = apply { this.tag = tag } - - /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") fun dirty(dirty: Boolean) = apply { this.dirty = dirty } - - /** Name of the author of the most recent commit */ - @JsonProperty("author_name") - fun authorName(authorName: String) = apply { this.authorName = authorName } - - /** Email of the author of the most recent commit */ - @JsonProperty("author_email") - fun authorEmail(authorEmail: String) = apply { this.authorEmail = authorEmail } - - /** Most recent commit message */ - @JsonProperty("commit_message") - fun commitMessage(commitMessage: String) = apply { this.commitMessage = commitMessage } - - /** Time of the most recent commit */ - @JsonProperty("commit_time") - fun commitTime(commitTime: String) = apply { this.commitTime = commitTime } - - /** - * If the repo was dirty when run, this includes the diff between the current state of - * the repo and the most recent commit. - */ - @JsonProperty("git_diff") - fun gitDiff(gitDiff: String) = apply { this.gitDiff = gitDiff } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RepoInfo = - RepoInfo( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties.toUnmodifiable(), - ) - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index e730f93..c5002c9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class ExperimentRetrieveParams constructor( - private val experimentId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ExperimentRetrieveParams +constructor( + private val experimentId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class ExperimentRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentRetrieveParams && - this.experimentId == other.experimentId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentRetrieveParams && + this.experimentId == other.experimentId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentRetrieveParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentRetrieveParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class ExperimentRetrieveParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class ExperimentRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class ExperimentRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExperimentRetrieveParams = + ExperimentRetrieveParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 96155ea..8f32628 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -2,48 +2,21 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ExperimentSummarizeParams constructor( - private val experimentId: String, - private val comparisonExperimentId: String?, - private val summarizeScores: Boolean?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ExperimentSummarizeParams +constructor( + private val experimentId: String, + private val comparisonExperimentId: String?, + private val summarizeScores: Boolean?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -54,25 +27,22 @@ class ExperimentSummarizeParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.comparisonExperimentId?.let { - params.put("comparison_experiment_id", listOf(it.toString())) - } - this.summarizeScores?.let { - params.put("summarize_scores", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.comparisonExperimentId?.let { + params.put("comparison_experiment_id", listOf(it.toString())) + } + this.summarizeScores?.let { params.put("summarize_scores", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -82,38 +52,38 @@ class ExperimentSummarizeParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentSummarizeParams && - this.experimentId == other.experimentId && - this.comparisonExperimentId == other.comparisonExperimentId && - this.summarizeScores == other.summarizeScores && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentSummarizeParams && + this.experimentId == other.experimentId && + this.comparisonExperimentId == other.comparisonExperimentId && + this.summarizeScores == other.summarizeScores && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - comparisonExperimentId, - summarizeScores, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + comparisonExperimentId, + summarizeScores, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -137,23 +107,21 @@ class ExperimentSummarizeParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** - * The experiment to compare against, if summarizing scores and metrics. If - * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, - * and then to the most recent experiment run in the same project. Must pass - * `summarize_scores=true` for this id to be used + * The experiment to compare against, if summarizing scores and metrics. If omitted, will + * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most + * recent experiment run in the same project. Must pass `summarize_scores=true` for this id + * to be used */ fun comparisonExperimentId(comparisonExperimentId: String) = apply { this.comparisonExperimentId = comparisonExperimentId } /** - * Whether to summarize the scores and metrics. If false (or omitted), only the - * metadata will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata + * will be returned. */ fun summarizeScores(summarizeScores: Boolean) = apply { this.summarizeScores = summarizeScores @@ -197,9 +165,7 @@ class ExperimentSummarizeParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -210,19 +176,19 @@ class ExperimentSummarizeParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - comparisonExperimentId, - summarizeScores, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExperimentSummarizeParams = + ExperimentSummarizeParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + comparisonExperimentId, + summarizeScores, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt index 5d47978..d017eae 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt @@ -2,50 +2,32 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Summary of an experiment */ @JsonDeserialize(builder = ExperimentSummarizeResponse.Builder::class) @NoAutoDetect -class ExperimentSummarizeResponse private constructor( - private val projectName: JsonField, - private val experimentName: JsonField, - private val projectUrl: JsonField, - private val experimentUrl: JsonField, - private val comparisonExperimentName: JsonField, - private val scores: JsonField, - private val metrics: JsonField, - private val additionalProperties: Map, - +class ExperimentSummarizeResponse +private constructor( + private val projectName: JsonField, + private val experimentName: JsonField, + private val projectUrl: JsonField, + private val experimentUrl: JsonField, + private val comparisonExperimentName: JsonField, + private val scores: JsonField, + private val metrics: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -65,7 +47,8 @@ class ExperimentSummarizeResponse private constructor( fun experimentUrl(): String = experimentUrl.getRequired("experiment_url") /** The experiment which scores are baselined against */ - fun comparisonExperimentName(): Optional = Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) + fun comparisonExperimentName(): Optional = + Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) /** Summary of the experiment's scores */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) @@ -74,24 +57,16 @@ class ExperimentSummarizeResponse private constructor( fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** Name of the project that the experiment belongs to */ - @JsonProperty("project_name") - @ExcludeMissing - fun _projectName() = projectName + @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName /** Name of the experiment */ - @JsonProperty("experiment_name") - @ExcludeMissing - fun _experimentName() = experimentName + @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName() = experimentName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing - fun _projectUrl() = projectUrl + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl /** URL to the experiment's page in the Braintrust app */ - @JsonProperty("experiment_url") - @ExcludeMissing - fun _experimentUrl() = experimentUrl + @JsonProperty("experiment_url") @ExcludeMissing fun _experimentUrl() = experimentUrl /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @@ -99,14 +74,10 @@ class ExperimentSummarizeResponse private constructor( fun _comparisonExperimentName() = comparisonExperimentName /** Summary of the experiment's scores */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** Summary of the experiment's metrics */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics @JsonAnyGetter @ExcludeMissing @@ -114,57 +85,58 @@ class ExperimentSummarizeResponse private constructor( fun validate(): ExperimentSummarizeResponse = apply { if (!validated) { - projectName() - experimentName() - projectUrl() - experimentUrl() - comparisonExperimentName() - scores().map { it.validate() } - metrics().map { it.validate() } - validated = true + projectName() + experimentName() + projectUrl() + experimentUrl() + comparisonExperimentName() + scores().map { it.validate() } + metrics().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentSummarizeResponse && - this.projectName == other.projectName && - this.experimentName == other.experimentName && - this.projectUrl == other.projectUrl && - this.experimentUrl == other.experimentUrl && - this.comparisonExperimentName == other.comparisonExperimentName && - this.scores == other.scores && - this.metrics == other.metrics && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentSummarizeResponse && + this.projectName == other.projectName && + this.experimentName == other.experimentName && + this.projectUrl == other.projectUrl && + this.experimentUrl == other.experimentUrl && + this.comparisonExperimentName == other.comparisonExperimentName && + this.scores == other.scores && + this.metrics == other.metrics && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - projectName, - experimentName, - projectUrl, - experimentUrl, - comparisonExperimentName, - scores, - metrics, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + projectName, + experimentName, + projectUrl, + experimentUrl, + comparisonExperimentName, + scores, + metrics, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ExperimentSummarizeResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentSummarizeResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -196,9 +168,7 @@ class ExperimentSummarizeResponse private constructor( /** Name of the project that the experiment belongs to */ @JsonProperty("project_name") @ExcludeMissing - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } /** Name of the experiment */ fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) @@ -216,9 +186,7 @@ class ExperimentSummarizeResponse private constructor( /** URL to the project's page in the Braintrust app */ @JsonProperty("project_url") @ExcludeMissing - fun projectUrl(projectUrl: JsonField) = apply { - this.projectUrl = projectUrl - } + fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } /** URL to the experiment's page in the Braintrust app */ fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) @@ -231,7 +199,8 @@ class ExperimentSummarizeResponse private constructor( } /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: String) = comparisonExperimentName(JsonField.of(comparisonExperimentName)) + fun comparisonExperimentName(comparisonExperimentName: String) = + comparisonExperimentName(JsonField.of(comparisonExperimentName)) /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @@ -246,9 +215,7 @@ class ExperimentSummarizeResponse private constructor( /** Summary of the experiment's scores */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** Summary of the experiment's metrics */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) @@ -256,9 +223,7 @@ class ExperimentSummarizeResponse private constructor( /** Summary of the experiment's metrics */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -274,22 +239,26 @@ class ExperimentSummarizeResponse private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentSummarizeResponse = ExperimentSummarizeResponse( - projectName, - experimentName, - projectUrl, - experimentUrl, - comparisonExperimentName, - scores, - metrics, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentSummarizeResponse = + ExperimentSummarizeResponse( + projectName, + experimentName, + projectUrl, + experimentUrl, + comparisonExperimentName, + scores, + metrics, + additionalProperties.toUnmodifiable(), + ) } /** Summary of the experiment's metrics */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor(private val additionalProperties: Map, ) { + class Metrics + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -301,34 +270,32 @@ class ExperimentSummarizeResponse private constructor( fun validate(): Metrics = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metrics && - this.additionalProperties == other.additionalProperties + return other is Metrics && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metrics{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -361,7 +328,10 @@ class ExperimentSummarizeResponse private constructor( /** Summary of the experiment's scores */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -373,34 +343,32 @@ class ExperimentSummarizeResponse private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index c7093b0..d193ff5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -2,54 +2,32 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ExperimentUpdateParams constructor( - private val experimentId: String, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ExperimentUpdateParams +constructor( + private val experimentId: String, + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -72,89 +50,78 @@ class ExperimentUpdateParams constructor( @JvmSynthetic internal fun getBody(): ExperimentUpdateBody { - return ExperimentUpdateBody( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalBodyProperties, - ) + return ExperimentUpdateBody( + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentUpdateBody.Builder::class) @NoAutoDetect - class ExperimentUpdateBody internal constructor( - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalProperties: Map, - + class ExperimentUpdateBody + internal constructor( + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - fun baseExpId(): String? = baseExpId + @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") - fun datasetId(): String? = datasetId + @JsonProperty("dataset_id") fun datasetId(): String? = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") - fun datasetVersion(): String? = datasetVersion + @JsonProperty("dataset_version") fun datasetVersion(): String? = datasetVersion /** Textual description of the experiment */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata + @JsonProperty("metadata") fun metadata(): Metadata? = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - @JsonProperty("public") - fun public_(): Boolean? = public_ + @JsonProperty("public") fun public_(): Boolean? = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - fun repoInfo(): RepoInfo? = repoInfo + @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo @JsonAnyGetter @ExcludeMissing @@ -163,45 +130,46 @@ class ExperimentUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentUpdateBody && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentUpdateBody && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -231,22 +199,18 @@ class ExperimentUpdateParams constructor( /** Id of default base experiment to compare against when viewing this experiment */ @JsonProperty("base_exp_id") - fun baseExpId(baseExpId: String) = apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } /** * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ @JsonProperty("dataset_id") - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") fun datasetVersion(datasetVersion: String) = apply { @@ -255,36 +219,24 @@ class ExperimentUpdateParams constructor( /** Textual description of the experiment */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** User-controlled metadata about the experiment */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - @JsonProperty("public") - fun public_(public_: Boolean) = apply { - this.public_ = public_ - } + @JsonProperty("public") fun public_(public_: Boolean) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { - this.repoInfo = repoInfo - } + fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -300,17 +252,18 @@ class ExperimentUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentUpdateBody = ExperimentUpdateBody( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentUpdateBody = + ExperimentUpdateBody( + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalProperties.toUnmodifiable(), + ) } } @@ -321,50 +274,50 @@ class ExperimentUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentUpdateParams && - this.experimentId == other.experimentId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentUpdateParams && + this.experimentId == other.experimentId && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -400,58 +353,39 @@ class ExperimentUpdateParams constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: String) = apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: String) = apply { this.datasetVersion = datasetVersion } /** Textual description of the experiment */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: Boolean) = apply { - this.public_ = public_ - } + fun public_(public_: Boolean) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { - this.repoInfo = repoInfo - } + fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -491,9 +425,7 @@ class ExperimentUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -504,32 +436,35 @@ class ExperimentUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentUpdateParams = ExperimentUpdateParams( - checkNotNull(experimentId) { - "`experimentId` is required but was not set" - }, - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentUpdateParams = + ExperimentUpdateParams( + checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the experiment */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -540,27 +475,25 @@ class ExperimentUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -593,60 +526,51 @@ class ExperimentUpdateParams constructor( /** Metadata about the state of the repo when the experiment was created */ @JsonDeserialize(builder = RepoInfo.Builder::class) @NoAutoDetect - class RepoInfo private constructor( - private val commit: String?, - private val branch: String?, - private val tag: String?, - private val dirty: Boolean?, - private val authorName: String?, - private val authorEmail: String?, - private val commitMessage: String?, - private val commitTime: String?, - private val gitDiff: String?, - private val additionalProperties: Map, - + class RepoInfo + private constructor( + private val commit: String?, + private val branch: String?, + private val tag: String?, + private val dirty: Boolean?, + private val authorName: String?, + private val authorEmail: String?, + private val commitMessage: String?, + private val commitTime: String?, + private val gitDiff: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** SHA of most recent commit */ - @JsonProperty("commit") - fun commit(): String? = commit + @JsonProperty("commit") fun commit(): String? = commit /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") - fun branch(): String? = branch + @JsonProperty("branch") fun branch(): String? = branch /** Name of the tag on the most recent commit */ - @JsonProperty("tag") - fun tag(): String? = tag + @JsonProperty("tag") fun tag(): String? = tag /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") - fun dirty(): Boolean? = dirty + @JsonProperty("dirty") fun dirty(): Boolean? = dirty /** Name of the author of the most recent commit */ - @JsonProperty("author_name") - fun authorName(): String? = authorName + @JsonProperty("author_name") fun authorName(): String? = authorName /** Email of the author of the most recent commit */ - @JsonProperty("author_email") - fun authorEmail(): String? = authorEmail + @JsonProperty("author_email") fun authorEmail(): String? = authorEmail /** Most recent commit message */ - @JsonProperty("commit_message") - fun commitMessage(): String? = commitMessage + @JsonProperty("commit_message") fun commitMessage(): String? = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") - fun commitTime(): String? = commitTime + @JsonProperty("commit_time") fun commitTime(): String? = commitTime /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. */ - @JsonProperty("git_diff") - fun gitDiff(): String? = gitDiff + @JsonProperty("git_diff") fun gitDiff(): String? = gitDiff @JsonAnyGetter @ExcludeMissing @@ -655,47 +579,48 @@ class ExperimentUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RepoInfo && - this.commit == other.commit && - this.branch == other.branch && - this.tag == other.tag && - this.dirty == other.dirty && - this.authorName == other.authorName && - this.authorEmail == other.authorEmail && - this.commitMessage == other.commitMessage && - this.commitTime == other.commitTime && - this.gitDiff == other.gitDiff && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RepoInfo && + this.commit == other.commit && + this.branch == other.branch && + this.tag == other.tag && + this.dirty == other.dirty && + this.authorName == other.authorName && + this.authorEmail == other.authorEmail && + this.commitMessage == other.commitMessage && + this.commitTime == other.commitTime && + this.gitDiff == other.gitDiff && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" + override fun toString() = + "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -726,61 +651,39 @@ class ExperimentUpdateParams constructor( } /** SHA of most recent commit */ - @JsonProperty("commit") - fun commit(commit: String) = apply { - this.commit = commit - } + @JsonProperty("commit") fun commit(commit: String) = apply { this.commit = commit } /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") - fun branch(branch: String) = apply { - this.branch = branch - } + @JsonProperty("branch") fun branch(branch: String) = apply { this.branch = branch } /** Name of the tag on the most recent commit */ - @JsonProperty("tag") - fun tag(tag: String) = apply { - this.tag = tag - } + @JsonProperty("tag") fun tag(tag: String) = apply { this.tag = tag } /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") - fun dirty(dirty: Boolean) = apply { - this.dirty = dirty - } + @JsonProperty("dirty") fun dirty(dirty: Boolean) = apply { this.dirty = dirty } /** Name of the author of the most recent commit */ @JsonProperty("author_name") - fun authorName(authorName: String) = apply { - this.authorName = authorName - } + fun authorName(authorName: String) = apply { this.authorName = authorName } /** Email of the author of the most recent commit */ @JsonProperty("author_email") - fun authorEmail(authorEmail: String) = apply { - this.authorEmail = authorEmail - } + fun authorEmail(authorEmail: String) = apply { this.authorEmail = authorEmail } /** Most recent commit message */ @JsonProperty("commit_message") - fun commitMessage(commitMessage: String) = apply { - this.commitMessage = commitMessage - } + fun commitMessage(commitMessage: String) = apply { this.commitMessage = commitMessage } /** Time of the most recent commit */ @JsonProperty("commit_time") - fun commitTime(commitTime: String) = apply { - this.commitTime = commitTime - } + fun commitTime(commitTime: String) = apply { this.commitTime = commitTime } /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of + * the repo and the most recent commit. */ @JsonProperty("git_diff") - fun gitDiff(gitDiff: String) = apply { - this.gitDiff = gitDiff - } + fun gitDiff(gitDiff: String) = apply { this.gitDiff = gitDiff } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -796,18 +699,19 @@ class ExperimentUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RepoInfo = RepoInfo( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties.toUnmodifiable(), - ) + fun build(): RepoInfo = + RepoInfo( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties.toUnmodifiable(), + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt index df90f80..eddca26 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt @@ -2,55 +2,50 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect -class Function private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val functionData: JsonField, - private val additionalProperties: Map, - +class Function +private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val orgId: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val description: JsonField, + private val created: JsonField, + private val promptData: JsonField, + private val tags: JsonField>, + private val metadata: JsonField, + private val functionData: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -61,10 +56,9 @@ class Function private constructor( fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -84,13 +78,15 @@ class Function private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Date of prompt creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -101,73 +97,46 @@ class Function private constructor( fun functionData(): FunctionData = functionData.getRequired("function_data") /** Unique identifier for the prompt */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun _logId() = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug() = slug + @JsonProperty("slug") @ExcludeMissing fun _slug() = slug /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun _promptData() = promptData + @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - @JsonProperty("function_data") - @ExcludeMissing - fun _functionData() = functionData + @JsonProperty("function_data") @ExcludeMissing fun _functionData() = functionData @JsonAnyGetter @ExcludeMissing @@ -175,75 +144,76 @@ class Function private constructor( fun validate(): Function = apply { if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - functionData() - validated = true + id() + _xactId() + projectId() + logId() + orgId() + name() + slug() + description() + created() + promptData().map { it.validate() } + tags() + metadata().map { it.validate() } + functionData() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.functionData == other.functionData && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.id == other.id && + this._xactId == other._xactId && + this.projectId == other.projectId && + this.logId == other.logId && + this.orgId == other.orgId && + this.name == other.name && + this.slug == other.slug && + this.description == other.description && + this.created == other.created && + this.promptData == other.promptData && + this.tags == other.tags && + this.metadata == other.metadata && + this.functionData == other.functionData && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - functionData, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags, + metadata, + functionData, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionData=$functionData, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionData=$functionData, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -285,31 +255,23 @@ class Function private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -317,9 +279,7 @@ class Function private constructor( /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) @@ -327,9 +287,7 @@ class Function private constructor( /** A literal 'p' which identifies the object as a project prompt */ @JsonProperty("log_id") @ExcludeMissing - fun logId(logId: JsonField) = apply { - this.logId = logId - } + fun logId(logId: JsonField) = apply { this.logId = logId } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -337,9 +295,7 @@ class Function private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) @@ -347,9 +303,7 @@ class Function private constructor( /** Name of the prompt */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) @@ -357,9 +311,7 @@ class Function private constructor( /** Unique identifier for the prompt */ @JsonProperty("slug") @ExcludeMissing - fun slug(slug: JsonField) = apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String) = description(JsonField.of(description)) @@ -367,9 +319,7 @@ class Function private constructor( /** Textual description of the prompt */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** Date of prompt creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -377,9 +327,7 @@ class Function private constructor( /** Date of prompt creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) @@ -387,9 +335,7 @@ class Function private constructor( /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @ExcludeMissing - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -397,9 +343,7 @@ class Function private constructor( /** A list of tags for the prompt */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -407,9 +351,7 @@ class Function private constructor( /** User-controlled metadata about the prompt */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) @@ -433,159 +375,174 @@ class Function private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - functionData, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags.map { it.toUnmodifiable() }, + metadata, + functionData, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( - private val type: Type? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class FunctionData + private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun prompt(): Optional = Optional.ofNullable(prompt) + + fun code(): Optional = Optional.ofNullable(code) - fun isType(): Boolean = type != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun global(): Optional = Optional.ofNullable(global) - fun asType(): Type = type.getOrThrow("type") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isPrompt(): Boolean = prompt != null + + fun isCode(): Boolean = code != null + + fun isGlobal(): Boolean = global != null + + fun asPrompt(): Prompt = prompt.getOrThrow("prompt") + + fun asCode(): Code = code.getOrThrow("code") + + fun asGlobal(): Global = global.getOrThrow("global") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } fun validate(): FunctionData = apply { if (!validated) { - if (type == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - type?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (prompt == null && code == null && global == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.type == other.type && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global } override fun hashCode(): Int { - return Objects.hash( - type, - unionMember1, - unionMember2, - ) + return Objects.hash( + prompt, + code, + global, + ) } override fun toString(): String { - return when { - type != null -> "FunctionData{type=$type}" - unionMember1 != null -> "FunctionData{unionMember1=$unionMember1}" - unionMember2 != null -> "FunctionData{unionMember2=$unionMember2}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { - @JvmStatic - fun ofType(type: Type) = FunctionData(type = type) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionData(unionMember1 = unionMember1) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = FunctionData(unionMember2 = unionMember2) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } interface Visitor { - fun visitType(type: Type): T + fun visitPrompt(prompt: Prompt): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitCode(code: Code): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGlobal(global: Global): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember2 = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.type != null -> generator.writeObject(value.type) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } - @JsonDeserialize(builder = Type.Builder::class) + @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class Prompt + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -593,46 +550,44 @@ class Function private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Type = apply { + fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -641,18 +596,16 @@ class Function private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) + internal fun from(prompt: Prompt) = apply { + this.type = prompt.type + additionalProperties(prompt.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -664,25 +617,28 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -705,23 +661,30 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { + class Code + private constructor( + private val type: JsonField, + private val data: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -731,56 +694,53 @@ class Function private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("data") - @ExcludeMissing - fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data() = data @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Code = apply { if (!validated) { - type() - data().validate() - validated = true + type() + data().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -790,27 +750,23 @@ class Function private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.data = unionMember1.data - additionalProperties(unionMember1.additionalProperties) + internal fun from(code: Code) = apply { + this.type = code.type + this.data = code.data + additionalProperties(code.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -822,25 +778,27 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = + Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect - class Data private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val additionalProperties: Map, - + class Data + private constructor( + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -857,13 +815,9 @@ class Function private constructor( @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") - @ExcludeMissing - fun _location() = location + @JsonProperty("location") @ExcludeMissing fun _location() = location - @JsonProperty("bundle_id") - @ExcludeMissing - fun _bundleId() = bundleId + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId @JsonAnyGetter @ExcludeMissing @@ -871,45 +825,46 @@ class Function private constructor( fun validate(): Data = apply { if (!validated) { - runtimeContext().validate() - location().validate() - bundleId() - validated = true + runtimeContext().validate() + location().validate() + bundleId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Data && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtimeContext, - location, - bundleId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtimeContext, + location, + bundleId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" + override fun toString() = + "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -927,7 +882,8 @@ class Function private constructor( additionalProperties(data.additionalProperties) } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -939,17 +895,13 @@ class Function private constructor( @JsonProperty("location") @ExcludeMissing - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = apply { this.location = location } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) @JsonProperty("bundle_id") @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -961,26 +913,28 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Data = Data( - runtimeContext, - location, - bundleId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Data = + Data( + runtimeContext, + location, + bundleId, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - + class Location + private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -993,17 +947,11 @@ class Function private constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("eval_name") - @ExcludeMissing - fun _evalName() = evalName + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - @JsonProperty("position") - @ExcludeMissing - fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1011,45 +959,46 @@ class Function private constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1057,7 +1006,8 @@ class Function private constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(location: Location) = apply { @@ -1071,9 +1021,7 @@ class Function private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1091,145 +1039,161 @@ class Function private constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Location = Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Location = + Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position private constructor(private val unionMember0: UnionMember0? = null, private val score: Score? = null, private val _json: JsonValue? = null, ) { + class Position + private constructor( + private val task: Task? = null, + private val score: Score? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun task(): Optional = Optional.ofNullable(task) + fun score(): Optional = Optional.ofNullable(score) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTask(): Boolean = task != null + fun isScore(): Boolean = score != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTask(): Task = task.getOrThrow("task") + fun asScore(): Score = score.getOrThrow("score") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - score != null -> visitor.visitScore(score) - else -> visitor.unknown(_json) - } + return when { + task != null -> visitor.visitTask(task) + score != null -> visitor.visitScore(score) + else -> visitor.unknown(_json) + } } fun validate(): Position = apply { if (!validated) { - if (unionMember0 == null && score == null) { - throw BraintrustInvalidDataException("Unknown Position: $_json") - } - score?.validate() - validated = true + if (task == null && score == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + score?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.unionMember0 == other.unionMember0 && - this.score == other.score + return other is Position && + this.task == other.task && + this.score == other.score } override fun hashCode(): Int { - return Objects.hash(unionMember0, score) + return Objects.hash(task, score) } override fun toString(): String { - return when { - unionMember0 != null -> "Position{unionMember0=$unionMember0}" - score != null -> "Position{score=$score}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + task != null -> "Position{task=$task}" + score != null -> "Position{score=$score}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Position(unionMember0 = unionMember0) + @JvmStatic fun ofTask(task: Task) = Position(task = task) - @JvmStatic - fun ofScore(score: Score) = Position(score = score) + @JvmStatic fun ofScore(score: Score) = Position(score = score) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTask(task: Task): T fun visitScore(score: Score): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Position(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Position(score = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Position(task = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(score = it, _json = json) + } - return Position(_json = json) + return Position(_json = json) } } class Serializer : BaseSerializer(Position::class) { - override fun serialize(value: Position, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.score != null -> generator.writeObject(value.score) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.task != null -> generator.writeObject(value.task) + value.score != null -> generator.writeObject(value.score) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Task + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Task && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1238,9 +1202,9 @@ class Function private constructor( companion object { - @JvmField val TASK = UnionMember0(JsonField.of("task")) + @JvmField val TASK = Task(JsonField.of("task")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Task(JsonField.of(value)) } enum class Known { @@ -1252,22 +1216,29 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException("Unknown Task: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Score.Builder::class) @NoAutoDetect - class Score private constructor(private val score: JsonField, private val additionalProperties: Map, ) { + class Score + private constructor( + private val score: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1275,52 +1246,52 @@ class Function private constructor( fun score(): Double = score.getRequired("score") - @JsonProperty("score") - @ExcludeMissing - fun _score() = score + @JsonProperty("score") @ExcludeMissing fun _score() = score @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Score = apply { if (!validated) { - score() - validated = true + score() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Score && - this.score == other.score && - this.additionalProperties == other.additionalProperties + return other is Score && + this.score == other.score && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(score, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(score, additionalProperties) + } + return hashCode } - override fun toString() = "Score{score=$score, additionalProperties=$additionalProperties}" + override fun toString() = + "Score{score=$score, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var score: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(score: Score) = apply { @@ -1332,11 +1303,11 @@ class Function private constructor( @JsonProperty("score") @ExcludeMissing - fun score(score: JsonField) = apply { - this.score = score - } + fun score(score: JsonField) = apply { this.score = score } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1346,27 +1317,31 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Score = Score(score, additionalProperties.toUnmodifiable()) + fun build(): Score = + Score(score, additionalProperties.toUnmodifiable()) } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1389,15 +1364,17 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1405,7 +1382,12 @@ class Function private constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { + class RuntimeContext + private constructor( + private val runtime: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1415,13 +1397,9 @@ class Function private constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") - @ExcludeMissing - fun _runtime() = runtime + @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime - @JsonProperty("version") - @ExcludeMissing - fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1429,49 +1407,51 @@ class Function private constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { @@ -1484,51 +1464,52 @@ class Function private constructor( @JsonProperty("runtime") @ExcludeMissing - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) @JsonProperty("version") @ExcludeMissing - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): RuntimeContext = RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = + RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Runtime + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && - this.value == other.value + return other is Runtime && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1551,33 +1532,38 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NODE -> Value.NODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NODE -> Value.NODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NODE -> Known.NODE - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") - } + fun known(): Known = + when (this) { + NODE -> Known.NODE + else -> + throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1600,23 +1586,30 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Global + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1626,56 +1619,53 @@ class Function private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1685,27 +1675,23 @@ class Function private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.name = unionMember2.name - additionalProperties(unionMember2.additionalProperties) + internal fun from(global: Global) = apply { + this.type = global.type + this.name = global.name + additionalProperties(global.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1717,29 +1703,33 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = + Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1762,33 +1752,37 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class LogId @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class LogId + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is LogId && - this.value == other.value + return other is LogId && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1811,15 +1805,17 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - P -> Value.P - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + P -> Value.P + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } + fun known(): Known = + when (this) { + P -> Known.P + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1827,7 +1823,10 @@ class Function private constructor( /** User-controlled metadata about the prompt */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1839,34 +1838,32 @@ class Function private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1899,12 +1896,12 @@ class Function private constructor( /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: JsonField, + private val options: JsonField, + private val origin: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1917,17 +1914,11 @@ class Function private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - @JsonProperty("prompt") - @ExcludeMissing - fun _prompt() = prompt + @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - @JsonProperty("options") - @ExcludeMissing - fun _options() = options + @JsonProperty("options") @ExcludeMissing fun _options() = options - @JsonProperty("origin") - @ExcludeMissing - fun _origin() = origin + @JsonProperty("origin") @ExcludeMissing fun _origin() = origin @JsonAnyGetter @ExcludeMissing @@ -1935,45 +1926,46 @@ class Function private constructor( fun validate(): PromptData = apply { if (!validated) { - prompt() - options().map { it.validate() } - origin().map { it.validate() } - validated = true + prompt() + options().map { it.validate() } + origin().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1995,25 +1987,19 @@ class Function private constructor( @JsonProperty("prompt") @ExcludeMissing - fun prompt(prompt: JsonField) = apply { - this.prompt = prompt - } + fun prompt(prompt: JsonField) = apply { this.prompt = prompt } fun options(options: Options) = options(JsonField.of(options)) @JsonProperty("options") @ExcludeMissing - fun options(options: JsonField) = apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } fun origin(origin: Origin) = origin(JsonField.of(origin)) @JsonProperty("origin") @ExcludeMissing - fun origin(origin: JsonField) = apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2029,22 +2015,23 @@ class Function private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: JsonField, + private val params: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2057,17 +2044,11 @@ class Function private constructor( fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - @JsonProperty("model") - @ExcludeMissing - fun _model() = model + @JsonProperty("model") @ExcludeMissing fun _model() = model - @JsonProperty("params") - @ExcludeMissing - fun _params() = params + @JsonProperty("params") @ExcludeMissing fun _params() = params - @JsonProperty("position") - @ExcludeMissing - fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -2075,45 +2056,46 @@ class Function private constructor( fun validate(): Options = apply { if (!validated) { - model() - params() - position() - validated = true + model() + params() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2135,25 +2117,19 @@ class Function private constructor( @JsonProperty("model") @ExcludeMissing - fun model(model: JsonField) = apply { - this.model = model - } + fun model(model: JsonField) = apply { this.model = model } fun params(params: Params) = params(JsonField.of(params)) @JsonProperty("params") @ExcludeMissing - fun params(params: JsonField) = apply { - this.params = params - } + fun params(params: JsonField) = apply { this.params = params } fun position(position: String) = position(JsonField.of(position)) @JsonProperty("position") @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } + fun position(position: JsonField) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2165,245 +2141,307 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun isOpenAIModelParams(): Boolean = openaiModelParams != null + + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null + + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") + + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2417,91 +2455,86 @@ class Function private constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2517,22 +2550,23 @@ class Function private constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2543,7 +2577,8 @@ class Function private constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2555,9 +2590,7 @@ class Function private constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -2567,7 +2600,8 @@ class Function private constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2575,7 +2609,8 @@ class Function private constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -2583,7 +2618,8 @@ class Function private constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -2591,7 +2627,8 @@ class Function private constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -2599,7 +2636,8 @@ class Function private constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -2611,190 +2649,202 @@ class Function private constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun none(): Optional = Optional.ofNullable(none) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2803,9 +2853,9 @@ class Function private constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -2817,31 +2867,37 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2850,9 +2906,9 @@ class Function private constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -2864,22 +2920,29 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2887,68 +2950,68 @@ class Function private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -2958,18 +3021,23 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2977,9 +3045,7 @@ class Function private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -2987,42 +3053,43 @@ class Function private constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -3034,39 +3101,42 @@ class Function private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3089,15 +3159,18 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -3105,146 +3178,160 @@ class Function private constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun asNone(): None = none.getOrThrow("none") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3253,9 +3340,9 @@ class Function private constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -3267,31 +3354,37 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3300,9 +3393,9 @@ class Function private constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -3314,22 +3407,30 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3339,78 +3440,75 @@ class Function private constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -3420,7 +3518,9 @@ class Function private constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -3430,20 +3530,25 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3451,52 +3556,53 @@ class Function private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -3508,40 +3614,47 @@ class Function private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3564,15 +3677,20 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -3580,25 +3698,26 @@ class Function private constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -3608,30 +3727,22 @@ class Function private constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -3646,59 +3757,60 @@ class Function private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3710,18 +3822,19 @@ class Function private constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3740,7 +3853,8 @@ class Function private constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3752,19 +3866,16 @@ class Function private constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -3773,7 +3884,8 @@ class Function private constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -3782,130 +3894,128 @@ class Function private constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3915,16 +4025,17 @@ class Function private constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3935,7 +4046,8 @@ class Function private constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3943,7 +4055,8 @@ class Function private constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -3955,120 +4068,115 @@ class Function private constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4076,14 +4184,15 @@ class Function private constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -4094,7 +4203,8 @@ class Function private constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -4106,94 +4216,98 @@ class Function private constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -4204,21 +4318,23 @@ class Function private constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -4226,35 +4342,32 @@ class Function private constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: JsonField, + private val projectId: JsonField, + private val promptVersion: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) + fun promptId(): Optional = + Optional.ofNullable(promptId.getNullable("prompt_id")) - fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) + fun projectId(): Optional = + Optional.ofNullable(projectId.getNullable("project_id")) - fun promptVersion(): Optional = Optional.ofNullable(promptVersion.getNullable("prompt_version")) + fun promptVersion(): Optional = + Optional.ofNullable(promptVersion.getNullable("prompt_version")) - @JsonProperty("prompt_id") - @ExcludeMissing - fun _promptId() = promptId + @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - @JsonProperty("prompt_version") - @ExcludeMissing - fun _promptVersion() = promptVersion + @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion @JsonAnyGetter @ExcludeMissing @@ -4262,45 +4375,46 @@ class Function private constructor( fun validate(): Origin = apply { if (!validated) { - promptId() - projectId() - promptVersion() - validated = true + promptId() + projectId() + promptVersion() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4322,19 +4436,16 @@ class Function private constructor( @JsonProperty("prompt_id") @ExcludeMissing - fun promptId(promptId: JsonField) = apply { - this.promptId = promptId - } + fun promptId(promptId: JsonField) = apply { this.promptId = promptId } fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) + fun promptVersion(promptVersion: String) = + promptVersion(JsonField.of(promptVersion)) @JsonProperty("prompt_version") @ExcludeMissing @@ -4352,154 +4463,175 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isCompletion(): Boolean = completion != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isChat(): Boolean = chat != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asCompletion(): Completion = completion.getOrThrow("completion") + + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4509,56 +4641,53 @@ class Function private constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4568,27 +4697,23 @@ class Function private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4600,29 +4725,34 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4645,28 +4775,30 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4679,63 +4811,58 @@ class Function private constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4746,20 +4873,18 @@ class Function private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -4773,9 +4898,7 @@ class Function private constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4787,281 +4910,306 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5069,14 +5217,15 @@ class Function private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5091,52 +5240,53 @@ class Function private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5159,97 +5309,96 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5257,14 +5406,15 @@ class Function private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -5279,52 +5429,53 @@ class Function private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5347,304 +5498,410 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent7s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent7s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent7s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent7s) + + fun unnamedSchemaWithArrayParent7s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent7s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent7s(): Boolean = unnamedSchemaWithArrayParent7s != null + + fun isUnnamedSchemaWithArrayParent7s(): Boolean = + unnamedSchemaWithArrayParent7s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent7s(): List = unnamedSchemaWithArrayParent7s.getOrThrow("unnamedSchemaWithArrayParent7s") + + fun asUnnamedSchemaWithArrayParent7s(): + List = + unnamedSchemaWithArrayParent7s.getOrThrow( + "unnamedSchemaWithArrayParent7s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent7s != null -> visitor.visitUnnamedSchemaWithArrayParent7s(unnamedSchemaWithArrayParent7s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent7s != null -> + visitor.visitUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent7s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent7s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent7s == other.unnamedSchemaWithArrayParent7s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent7s == + other.unnamedSchemaWithArrayParent7s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent7s) + return Objects.hash(string, unnamedSchemaWithArrayParent7s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent7s != null -> "Content{unnamedSchemaWithArrayParent7s=$unnamedSchemaWithArrayParent7s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent7s != null -> + "Content{unnamedSchemaWithArrayParent7s=$unnamedSchemaWithArrayParent7s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent7s(unnamedSchemaWithArrayParent7s: List) = Content(unnamedSchemaWithArrayParent7s = unnamedSchemaWithArrayParent7s) + fun ofUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s: + List + ) = + Content( + unnamedSchemaWithArrayParent7s = + unnamedSchemaWithArrayParent7s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent7s(unnamedSchemaWithArrayParent7s: List): T + fun visitUnnamedSchemaWithArrayParent7s( + unnamedSchemaWithArrayParent7s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent7s = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent7s = it, + _json = json + ) + } - return Content(_json = json) + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent7s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent7s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent7s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent7s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent7.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent7.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent7.Serializer::class) - class UnnamedSchemaWithArrayParent7 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent7 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) + + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) + + fun isText(): Boolean = text != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isImageUrl(): Boolean = imageUrl != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asText(): Text = text.getOrThrow("text") + + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent7 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent7: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent7: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent7 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent7 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent7{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent7{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent7{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent7") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent7{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent7{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent7{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent7(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent7(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent7(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent7(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent7: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent7: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent7::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent7 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent7(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent7(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent7 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent7( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent7( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent7(_json = json) + return UnnamedSchemaWithArrayParent7(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent7::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent7, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent7") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent7, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -5659,43 +5916,50 @@ class Function private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5706,7 +5970,8 @@ class Function private constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -5718,23 +5983,33 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5748,68 +6023,71 @@ class Function private constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -5821,34 +6099,43 @@ class Function private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5856,11 +6143,10 @@ class Function private constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -5868,53 +6154,58 @@ class Function private constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -5931,7 +6222,8 @@ class Function private constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -5939,39 +6231,52 @@ class Function private constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5986,7 +6291,8 @@ class Function private constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -6002,36 +6308,44 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6040,9 +6354,11 @@ class Function private constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -6054,15 +6370,20 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -6071,16 +6392,16 @@ class Function private constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -6089,85 +6410,81 @@ class Function private constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6177,25 +6494,24 @@ class Function private constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -6205,7 +6521,8 @@ class Function private constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -6217,11 +6534,10 @@ class Function private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -6229,42 +6545,47 @@ class Function private constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6287,22 +6608,30 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6312,63 +6641,62 @@ class Function private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -6377,7 +6705,8 @@ class Function private constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6389,11 +6718,11 @@ class Function private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6403,26 +6732,27 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -6435,63 +6765,59 @@ class Function private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6499,7 +6825,8 @@ class Function private constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -6513,9 +6840,7 @@ class Function private constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -6529,11 +6854,11 @@ class Function private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6543,21 +6868,27 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6571,59 +6902,61 @@ class Function private constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -6632,7 +6965,8 @@ class Function private constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6644,44 +6978,51 @@ class Function private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6704,98 +7045,100 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6803,14 +7146,15 @@ class Function private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -6825,11 +7169,10 @@ class Function private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -6837,40 +7180,45 @@ class Function private constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6893,97 +7241,96 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6991,14 +7338,15 @@ class Function private constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -7013,52 +7361,53 @@ class Function private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7081,23 +7430,31 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -7105,80 +7462,77 @@ class Function private constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -7188,39 +7542,44 @@ class Function private constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7243,33 +7602,39 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7292,23 +7657,28 @@ class Function private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -7318,36 +7688,36 @@ class Function private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -7355,8 +7725,8 @@ class Function private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -7369,11 +7739,13 @@ class Function private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt index 3663251..6282696 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt @@ -2,52 +2,44 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class FunctionCreateParams constructor( - private val functionData: FunctionData, - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class FunctionCreateParams +constructor( + private val functionData: FunctionData, + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun functionData(): FunctionData = functionData @@ -66,66 +58,57 @@ class FunctionCreateParams constructor( @JvmSynthetic internal fun getBody(): FunctionCreateBody { - return FunctionCreateBody( - functionData, - name, - projectId, - slug, - description, - promptData, - tags, - additionalBodyProperties, - ) + return FunctionCreateBody( + functionData, + name, + projectId, + slug, + description, + promptData, + tags, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = FunctionCreateBody.Builder::class) @NoAutoDetect - class FunctionCreateBody internal constructor( - private val functionData: FunctionData?, - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, - + class FunctionCreateBody + internal constructor( + private val functionData: FunctionData?, + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("function_data") - fun functionData(): FunctionData? = functionData + @JsonProperty("function_data") fun functionData(): FunctionData? = functionData /** Name of the prompt */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(): String? = slug + @JsonProperty("slug") fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(): List? = tags + @JsonProperty("tags") fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -134,43 +117,44 @@ class FunctionCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCreateBody && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FunctionCreateBody && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - functionData, - name, - projectId, - slug, - description, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + functionData, + name, + projectId, + slug, + description, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -202,40 +186,25 @@ class FunctionCreateParams constructor( } /** Name of the prompt */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(slug: String) = apply { - this.slug = slug - } + @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(tags: List) = apply { - this.tags = tags - } + @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -251,24 +220,17 @@ class FunctionCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCreateBody = FunctionCreateBody( - checkNotNull(functionData) { - "`functionData` is required but was not set" - }, - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCreateBody = + FunctionCreateBody( + checkNotNull(functionData) { "`functionData` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -279,46 +241,46 @@ class FunctionCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCreateParams && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionCreateParams && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionData, - name, - projectId, - slug, - description, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionData, + name, + projectId, + slug, + description, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -349,46 +311,34 @@ class FunctionCreateParams constructor( additionalBodyProperties(functionCreateParams.additionalBodyProperties) } - fun functionData(functionData: FunctionData) = apply { - this.functionData = functionData - } + fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } - fun functionData(type: FunctionData.Type) = apply { - this.functionData = FunctionData.ofType(type) + fun functionData(prompt: FunctionData.Prompt) = apply { + this.functionData = FunctionData.ofPrompt(prompt) } - fun functionData(unionMember1: FunctionData.UnionMember1) = apply { - this.functionData = FunctionData.ofUnionMember1(unionMember1) + fun functionData(code: FunctionData.Code) = apply { + this.functionData = FunctionData.ofCode(code) } - fun functionData(unionMember2: FunctionData.UnionMember2) = apply { - this.functionData = FunctionData.ofUnionMember2(unionMember2) + fun functionData(global: FunctionData.Global) = apply { + this.functionData = FunctionData.ofGlobal(global) } /** Name of the prompt */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { - this.slug = slug - } + fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -397,9 +347,7 @@ class FunctionCreateParams constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - this.tags.add(tag) - } + fun addTag(tag: String) = apply { this.tags.add(tag) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -439,9 +387,7 @@ class FunctionCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -452,167 +398,175 @@ class FunctionCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): FunctionCreateParams = FunctionCreateParams( - checkNotNull(functionData) { - "`functionData` is required but was not set" - }, - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - if(tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): FunctionCreateParams = + FunctionCreateParams( + checkNotNull(functionData) { "`functionData` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + if (tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( - private val type: Type? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class FunctionData + private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun prompt(): Optional = Optional.ofNullable(prompt) + + fun code(): Optional = Optional.ofNullable(code) + + fun global(): Optional = Optional.ofNullable(global) + + fun isPrompt(): Boolean = prompt != null - fun isType(): Boolean = type != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isCode(): Boolean = code != null - fun asType(): Type = type.getOrThrow("type") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isGlobal(): Boolean = global != null + + fun asPrompt(): Prompt = prompt.getOrThrow("prompt") + + fun asCode(): Code = code.getOrThrow("code") + + fun asGlobal(): Global = global.getOrThrow("global") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } fun validate(): FunctionData = apply { if (!validated) { - if (type == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - type?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (prompt == null && code == null && global == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.type == other.type && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global } override fun hashCode(): Int { - return Objects.hash( - type, - unionMember1, - unionMember2, - ) + return Objects.hash( + prompt, + code, + global, + ) } override fun toString(): String { - return when { - type != null -> "FunctionData{type=$type}" - unionMember1 != null -> "FunctionData{unionMember1=$unionMember1}" - unionMember2 != null -> "FunctionData{unionMember2=$unionMember2}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { - @JvmStatic - fun ofType(type: Type) = FunctionData(type = type) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionData(unionMember1 = unionMember1) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = FunctionData(unionMember2 = unionMember2) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } interface Visitor { - fun visitType(type: Type): T + fun visitPrompt(prompt: Prompt): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitCode(code: Code): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGlobal(global: Global): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember2 = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.type != null -> generator.writeObject(value.type) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } - @JsonDeserialize(builder = Type.Builder::class) + @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class Prompt + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -620,46 +574,44 @@ class FunctionCreateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Type = apply { + fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -668,18 +620,16 @@ class FunctionCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) + internal fun from(prompt: Prompt) = apply { + this.type = prompt.type + additionalProperties(prompt.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -691,25 +641,28 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -732,23 +685,30 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { + class Code + private constructor( + private val type: JsonField, + private val data: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -758,56 +718,53 @@ class FunctionCreateParams constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("data") - @ExcludeMissing - fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data() = data @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Code = apply { if (!validated) { - type() - data().validate() - validated = true + type() + data().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -817,27 +774,23 @@ class FunctionCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.data = unionMember1.data - additionalProperties(unionMember1.additionalProperties) + internal fun from(code: Code) = apply { + this.type = code.type + this.data = code.data + additionalProperties(code.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -849,25 +802,27 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = + Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect - class Data private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val additionalProperties: Map, - + class Data + private constructor( + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -884,13 +839,9 @@ class FunctionCreateParams constructor( @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") - @ExcludeMissing - fun _location() = location + @JsonProperty("location") @ExcludeMissing fun _location() = location - @JsonProperty("bundle_id") - @ExcludeMissing - fun _bundleId() = bundleId + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId @JsonAnyGetter @ExcludeMissing @@ -898,45 +849,46 @@ class FunctionCreateParams constructor( fun validate(): Data = apply { if (!validated) { - runtimeContext().validate() - location().validate() - bundleId() - validated = true + runtimeContext().validate() + location().validate() + bundleId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Data && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtimeContext, - location, - bundleId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtimeContext, + location, + bundleId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" + override fun toString() = + "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -954,7 +906,8 @@ class FunctionCreateParams constructor( additionalProperties(data.additionalProperties) } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -966,17 +919,13 @@ class FunctionCreateParams constructor( @JsonProperty("location") @ExcludeMissing - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = apply { this.location = location } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) @JsonProperty("bundle_id") @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -988,26 +937,28 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Data = Data( - runtimeContext, - location, - bundleId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Data = + Data( + runtimeContext, + location, + bundleId, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - + class Location + private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1020,17 +971,11 @@ class FunctionCreateParams constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("eval_name") - @ExcludeMissing - fun _evalName() = evalName + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - @JsonProperty("position") - @ExcludeMissing - fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1038,45 +983,46 @@ class FunctionCreateParams constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1084,7 +1030,8 @@ class FunctionCreateParams constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(location: Location) = apply { @@ -1098,9 +1045,7 @@ class FunctionCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1118,145 +1063,161 @@ class FunctionCreateParams constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Location = Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Location = + Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position private constructor(private val unionMember0: UnionMember0? = null, private val score: Score? = null, private val _json: JsonValue? = null, ) { + class Position + private constructor( + private val task: Task? = null, + private val score: Score? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun task(): Optional = Optional.ofNullable(task) + fun score(): Optional = Optional.ofNullable(score) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTask(): Boolean = task != null + fun isScore(): Boolean = score != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTask(): Task = task.getOrThrow("task") + fun asScore(): Score = score.getOrThrow("score") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - score != null -> visitor.visitScore(score) - else -> visitor.unknown(_json) - } + return when { + task != null -> visitor.visitTask(task) + score != null -> visitor.visitScore(score) + else -> visitor.unknown(_json) + } } fun validate(): Position = apply { if (!validated) { - if (unionMember0 == null && score == null) { - throw BraintrustInvalidDataException("Unknown Position: $_json") - } - score?.validate() - validated = true + if (task == null && score == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + score?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.unionMember0 == other.unionMember0 && - this.score == other.score + return other is Position && + this.task == other.task && + this.score == other.score } override fun hashCode(): Int { - return Objects.hash(unionMember0, score) + return Objects.hash(task, score) } override fun toString(): String { - return when { - unionMember0 != null -> "Position{unionMember0=$unionMember0}" - score != null -> "Position{score=$score}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + task != null -> "Position{task=$task}" + score != null -> "Position{score=$score}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Position(unionMember0 = unionMember0) + @JvmStatic fun ofTask(task: Task) = Position(task = task) - @JvmStatic - fun ofScore(score: Score) = Position(score = score) + @JvmStatic fun ofScore(score: Score) = Position(score = score) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTask(task: Task): T fun visitScore(score: Score): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Position(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Position(score = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Position(task = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(score = it, _json = json) + } - return Position(_json = json) + return Position(_json = json) } } class Serializer : BaseSerializer(Position::class) { - override fun serialize(value: Position, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.score != null -> generator.writeObject(value.score) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.task != null -> generator.writeObject(value.task) + value.score != null -> generator.writeObject(value.score) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Task + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Task && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1265,9 +1226,9 @@ class FunctionCreateParams constructor( companion object { - @JvmField val TASK = UnionMember0(JsonField.of("task")) + @JvmField val TASK = Task(JsonField.of("task")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Task(JsonField.of(value)) } enum class Known { @@ -1279,22 +1240,29 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException("Unknown Task: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Score.Builder::class) @NoAutoDetect - class Score private constructor(private val score: JsonField, private val additionalProperties: Map, ) { + class Score + private constructor( + private val score: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1302,52 +1270,52 @@ class FunctionCreateParams constructor( fun score(): Double = score.getRequired("score") - @JsonProperty("score") - @ExcludeMissing - fun _score() = score + @JsonProperty("score") @ExcludeMissing fun _score() = score @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Score = apply { if (!validated) { - score() - validated = true + score() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Score && - this.score == other.score && - this.additionalProperties == other.additionalProperties + return other is Score && + this.score == other.score && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(score, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(score, additionalProperties) + } + return hashCode } - override fun toString() = "Score{score=$score, additionalProperties=$additionalProperties}" + override fun toString() = + "Score{score=$score, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var score: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(score: Score) = apply { @@ -1359,11 +1327,11 @@ class FunctionCreateParams constructor( @JsonProperty("score") @ExcludeMissing - fun score(score: JsonField) = apply { - this.score = score - } + fun score(score: JsonField) = apply { this.score = score } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1373,27 +1341,31 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Score = Score(score, additionalProperties.toUnmodifiable()) + fun build(): Score = + Score(score, additionalProperties.toUnmodifiable()) } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1416,15 +1388,17 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1432,7 +1406,12 @@ class FunctionCreateParams constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { + class RuntimeContext + private constructor( + private val runtime: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1442,13 +1421,9 @@ class FunctionCreateParams constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") - @ExcludeMissing - fun _runtime() = runtime + @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime - @JsonProperty("version") - @ExcludeMissing - fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1456,49 +1431,51 @@ class FunctionCreateParams constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { @@ -1511,51 +1488,52 @@ class FunctionCreateParams constructor( @JsonProperty("runtime") @ExcludeMissing - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) @JsonProperty("version") @ExcludeMissing - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): RuntimeContext = RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = + RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Runtime + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && - this.value == other.value + return other is Runtime && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1578,33 +1556,38 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NODE -> Value.NODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NODE -> Value.NODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NODE -> Known.NODE - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") - } + fun known(): Known = + when (this) { + NODE -> Known.NODE + else -> + throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1627,23 +1610,30 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Global + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1653,56 +1643,53 @@ class FunctionCreateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1712,27 +1699,23 @@ class FunctionCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.name = unionMember2.name - additionalProperties(unionMember2.additionalProperties) + internal fun from(global: Global) = apply { + this.type = global.type + this.name = global.name + additionalProperties(global.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1744,29 +1727,33 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = + Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1789,15 +1776,17 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1807,24 +1796,21 @@ class FunctionCreateParams constructor( /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: Prompt?, - private val options: Options?, - private val origin: Origin?, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: Prompt?, + private val options: Options?, + private val origin: Origin?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt") - fun prompt(): Prompt? = prompt + @JsonProperty("prompt") fun prompt(): Prompt? = prompt - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options - @JsonProperty("origin") - fun origin(): Origin? = origin + @JsonProperty("origin") fun origin(): Origin? = origin @JsonAnyGetter @ExcludeMissing @@ -1833,35 +1819,36 @@ class FunctionCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1879,20 +1866,12 @@ class FunctionCreateParams constructor( additionalProperties(promptData.additionalProperties) } - @JsonProperty("prompt") - fun prompt(prompt: Prompt) = apply { - this.prompt = prompt - } + @JsonProperty("prompt") fun prompt(prompt: Prompt) = apply { this.prompt = prompt } @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } - @JsonProperty("origin") - fun origin(origin: Origin) = apply { - this.origin = origin - } + @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1908,34 +1887,32 @@ class FunctionCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: String?, - private val params: Params?, - private val position: String?, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: String?, + private val params: Params?, + private val position: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("model") - fun model(): String? = model + @JsonProperty("model") fun model(): String? = model - @JsonProperty("params") - fun params(): Params? = params + @JsonProperty("params") fun params(): Params? = params - @JsonProperty("position") - fun position(): String? = position + @JsonProperty("position") fun position(): String? = position @JsonAnyGetter @ExcludeMissing @@ -1944,35 +1921,36 @@ class FunctionCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1990,20 +1968,12 @@ class FunctionCreateParams constructor( additionalProperties(options.additionalProperties) } - @JsonProperty("model") - fun model(model: String) = apply { - this.model = model - } + @JsonProperty("model") fun model(model: String) = apply { this.model = model } - @JsonProperty("params") - fun params(params: Params) = apply { - this.params = params - } + @JsonProperty("params") fun params(params: Params) = apply { this.params = params } @JsonProperty("position") - fun position(position: String) = apply { - this.position = position - } + fun position(position: String) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2015,245 +1985,307 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) + + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) + + fun isOpenAIModelParams(): Boolean = openaiModelParams != null + + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2267,91 +2299,86 @@ class FunctionCreateParams constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2367,22 +2394,23 @@ class FunctionCreateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2393,7 +2421,8 @@ class FunctionCreateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2405,9 +2434,7 @@ class FunctionCreateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -2417,7 +2444,8 @@ class FunctionCreateParams constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2425,7 +2453,8 @@ class FunctionCreateParams constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -2433,7 +2462,8 @@ class FunctionCreateParams constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -2441,7 +2471,8 @@ class FunctionCreateParams constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -2449,7 +2480,8 @@ class FunctionCreateParams constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -2461,190 +2493,202 @@ class FunctionCreateParams constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun asNone(): None = none.getOrThrow("none") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2653,9 +2697,9 @@ class FunctionCreateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -2667,31 +2711,37 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2700,9 +2750,9 @@ class FunctionCreateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -2714,22 +2764,29 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2737,68 +2794,68 @@ class FunctionCreateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -2808,18 +2865,23 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2827,9 +2889,7 @@ class FunctionCreateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -2837,42 +2897,43 @@ class FunctionCreateParams constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -2884,39 +2945,42 @@ class FunctionCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2939,15 +3003,18 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2955,146 +3022,160 @@ class FunctionCreateParams constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isFunction(): Boolean = function != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3103,9 +3184,9 @@ class FunctionCreateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -3117,31 +3198,37 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3150,9 +3237,9 @@ class FunctionCreateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -3164,22 +3251,30 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3189,78 +3284,75 @@ class FunctionCreateParams constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -3270,7 +3362,9 @@ class FunctionCreateParams constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -3280,20 +3374,25 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3301,52 +3400,53 @@ class FunctionCreateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -3358,40 +3458,47 @@ class FunctionCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3414,15 +3521,20 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -3430,25 +3542,26 @@ class FunctionCreateParams constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -3458,30 +3571,22 @@ class FunctionCreateParams constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -3496,59 +3601,60 @@ class FunctionCreateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3560,18 +3666,19 @@ class FunctionCreateParams constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3590,7 +3697,8 @@ class FunctionCreateParams constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3602,19 +3710,16 @@ class FunctionCreateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -3623,7 +3728,8 @@ class FunctionCreateParams constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -3632,130 +3738,128 @@ class FunctionCreateParams constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3765,16 +3869,17 @@ class FunctionCreateParams constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3785,7 +3890,8 @@ class FunctionCreateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3793,7 +3899,8 @@ class FunctionCreateParams constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -3805,120 +3912,115 @@ class FunctionCreateParams constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3926,14 +4028,15 @@ class FunctionCreateParams constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3944,7 +4047,8 @@ class FunctionCreateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3956,94 +4060,98 @@ class FunctionCreateParams constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -4054,21 +4162,23 @@ class FunctionCreateParams constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -4076,24 +4186,21 @@ class FunctionCreateParams constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: String?, - private val projectId: String?, - private val promptVersion: String?, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: String?, + private val projectId: String?, + private val promptVersion: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt_id") - fun promptId(): String? = promptId + @JsonProperty("prompt_id") fun promptId(): String? = promptId - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId - @JsonProperty("prompt_version") - fun promptVersion(): String? = promptVersion + @JsonProperty("prompt_version") fun promptVersion(): String? = promptVersion @JsonAnyGetter @ExcludeMissing @@ -4102,35 +4209,36 @@ class FunctionCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4149,14 +4257,10 @@ class FunctionCreateParams constructor( } @JsonProperty("prompt_id") - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } @JsonProperty("prompt_version") fun promptVersion(promptVersion: String) = apply { @@ -4173,154 +4277,175 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isCompletion(): Boolean = completion != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isChat(): Boolean = chat != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asCompletion(): Completion = completion.getOrThrow("completion") + + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4330,56 +4455,53 @@ class FunctionCreateParams constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4389,27 +4511,23 @@ class FunctionCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4421,29 +4539,34 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4466,28 +4589,30 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4500,63 +4625,58 @@ class FunctionCreateParams constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4567,20 +4687,18 @@ class FunctionCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -4594,9 +4712,7 @@ class FunctionCreateParams constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4608,281 +4724,306 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4890,14 +5031,15 @@ class FunctionCreateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -4912,52 +5054,53 @@ class FunctionCreateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4980,97 +5123,96 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5078,14 +5220,15 @@ class FunctionCreateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -5100,52 +5243,53 @@ class FunctionCreateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5168,304 +5312,410 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent3s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent3s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent3s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent3s) + + fun unnamedSchemaWithArrayParent3s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent3s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent3s(): Boolean = unnamedSchemaWithArrayParent3s != null + + fun isUnnamedSchemaWithArrayParent3s(): Boolean = + unnamedSchemaWithArrayParent3s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent3s(): List = unnamedSchemaWithArrayParent3s.getOrThrow("unnamedSchemaWithArrayParent3s") + + fun asUnnamedSchemaWithArrayParent3s(): + List = + unnamedSchemaWithArrayParent3s.getOrThrow( + "unnamedSchemaWithArrayParent3s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent3s != null -> visitor.visitUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent3s != null -> + visitor.visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent3s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent3s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent3s == other.unnamedSchemaWithArrayParent3s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent3s == + other.unnamedSchemaWithArrayParent3s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent3s) + return Objects.hash(string, unnamedSchemaWithArrayParent3s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent3s != null -> "Content{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent3s != null -> + "Content{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s: List) = Content(unnamedSchemaWithArrayParent3s = unnamedSchemaWithArrayParent3s) + fun ofUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: + List + ) = + Content( + unnamedSchemaWithArrayParent3s = + unnamedSchemaWithArrayParent3s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s: List): T + fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent3s = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent3s = it, + _json = json + ) + } - return Content(_json = json) + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent3s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent3s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent3s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent3s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent3.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) - class UnnamedSchemaWithArrayParent3 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent3 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun isText(): Boolean = text != null + + fun isImageUrl(): Boolean = imageUrl != null + + fun asText(): Text = text.getOrThrow("text") + + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent3 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent3: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent3: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent3 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent3 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent3{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent3{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent3{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent3{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent3" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent3(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent3(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent3(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent3(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent3: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent3: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent3::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent3 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent3(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent3(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent3 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent3( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent3( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent3(_json = json) + return UnnamedSchemaWithArrayParent3(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent3::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent3, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent3, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent3" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -5480,43 +5730,50 @@ class FunctionCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5527,7 +5784,8 @@ class FunctionCreateParams constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -5539,23 +5797,33 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5569,68 +5837,71 @@ class FunctionCreateParams constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -5642,34 +5913,43 @@ class FunctionCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5677,11 +5957,10 @@ class FunctionCreateParams constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -5689,53 +5968,58 @@ class FunctionCreateParams constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -5752,7 +6036,8 @@ class FunctionCreateParams constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -5760,39 +6045,52 @@ class FunctionCreateParams constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5807,7 +6105,8 @@ class FunctionCreateParams constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -5823,36 +6122,44 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5861,9 +6168,11 @@ class FunctionCreateParams constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -5875,15 +6184,20 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -5892,16 +6206,16 @@ class FunctionCreateParams constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -5910,85 +6224,81 @@ class FunctionCreateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5998,25 +6308,24 @@ class FunctionCreateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -6026,7 +6335,8 @@ class FunctionCreateParams constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -6038,11 +6348,10 @@ class FunctionCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -6050,42 +6359,47 @@ class FunctionCreateParams constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6108,22 +6422,30 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6133,63 +6455,62 @@ class FunctionCreateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -6198,7 +6519,8 @@ class FunctionCreateParams constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6210,11 +6532,11 @@ class FunctionCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6224,26 +6546,27 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -6256,63 +6579,59 @@ class FunctionCreateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6320,7 +6639,8 @@ class FunctionCreateParams constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -6334,9 +6654,7 @@ class FunctionCreateParams constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -6350,11 +6668,11 @@ class FunctionCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6364,21 +6682,27 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6392,59 +6716,61 @@ class FunctionCreateParams constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -6453,7 +6779,8 @@ class FunctionCreateParams constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6465,44 +6792,51 @@ class FunctionCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6525,98 +6859,100 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6624,14 +6960,15 @@ class FunctionCreateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -6646,11 +6983,10 @@ class FunctionCreateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -6658,40 +6994,45 @@ class FunctionCreateParams constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6714,97 +7055,96 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6812,14 +7152,15 @@ class FunctionCreateParams constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -6834,52 +7175,53 @@ class FunctionCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6902,23 +7244,31 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6926,80 +7276,77 @@ class FunctionCreateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -7009,39 +7356,44 @@ class FunctionCreateParams constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7064,33 +7416,39 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7113,23 +7471,28 @@ class FunctionCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -7139,36 +7502,36 @@ class FunctionCreateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -7176,8 +7539,8 @@ class FunctionCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -7190,11 +7553,13 @@ class FunctionCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index b8c23a9..3c43364 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class FunctionDeleteParams constructor( - private val functionId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class FunctionDeleteParams +constructor( + private val functionId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun functionId(): String = functionId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class FunctionDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionDeleteParams && - this.functionId == other.functionId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionDeleteParams && + this.functionId == other.functionId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "FunctionDeleteParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "FunctionDeleteParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class FunctionDeleteParams constructor( } /** Function id */ - fun functionId(functionId: String) = apply { - this.functionId = functionId - } + fun functionId(functionId: String) = apply { this.functionId = functionId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class FunctionDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class FunctionDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): FunctionDeleteParams = FunctionDeleteParams( - checkNotNull(functionId) { - "`functionId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): FunctionDeleteParams = + FunctionDeleteParams( + checkNotNull(functionId) { "`functionId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionFeedbackParams.kt deleted file mode 100644 index fcd873e..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionFeedbackParams.kt +++ /dev/null @@ -1,562 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class FunctionFeedbackParams constructor( - private val functionId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - -) { - - fun functionId(): String = functionId - - fun feedback(): List = feedback - - @JvmSynthetic - internal fun getBody(): FunctionFeedbackBody { - return FunctionFeedbackBody(feedback, additionalBodyProperties) - } - - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams - - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } - } - - @JsonDeserialize(builder = FunctionFeedbackBody.Builder::class) - @NoAutoDetect - class FunctionFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { - - private var hashCode: Int = 0 - - /** A list of function feedback items */ - @JsonProperty("feedback") - fun feedback(): List? = feedback - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = "FunctionFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - class Builder { - - private var feedback: List? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(functionFeedbackBody: FunctionFeedbackBody) = apply { - this.feedback = functionFeedbackBody.feedback - additionalProperties(functionFeedbackBody.additionalProperties) - } - - /** A list of function feedback items */ - @JsonProperty("feedback") - fun feedback(feedback: List) = apply { - this.feedback = feedback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FunctionFeedbackBody = FunctionFeedbackBody(checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionFeedbackParams && - this.functionId == other.functionId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - functionId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = "FunctionFeedbackParams{functionId=$functionId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var functionId: String? = null - private var feedback: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(functionFeedbackParams: FunctionFeedbackParams) = apply { - this.functionId = functionFeedbackParams.functionId - this.feedback(functionFeedbackParams.feedback) - additionalQueryParams(functionFeedbackParams.additionalQueryParams) - additionalHeaders(functionFeedbackParams.additionalHeaders) - additionalBodyProperties(functionFeedbackParams.additionalBodyProperties) - } - - /** Function id */ - fun functionId(functionId: String) = apply { - this.functionId = functionId - } - - /** A list of function feedback items */ - fun feedback(feedback: List) = apply { - this.feedback.clear() - this.feedback.addAll(feedback) - } - - /** A list of function feedback items */ - fun addFeedback(feedback: Feedback) = apply { - this.feedback.add(feedback) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): FunctionFeedbackParams = FunctionFeedbackParams( - checkNotNull(functionId) { - "`functionId` is required but was not set" - }, - checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Feedback.Builder::class) - @NoAutoDetect - class Feedback private constructor( - private val id: String?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - - ) { - - private var hashCode: Int = 0 - - /** - * The id of the function event to log feedback for. This is the row `id` returned - * by `POST /v1/function/{function_id}/insert` - */ - @JsonProperty("id") - fun id(): String? = id - - /** An optional comment string to log about the function event */ - @JsonProperty("comment") - fun comment(): String? = comment - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(): Source? = source - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = "Feedback{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var comment: String? = null - private var metadata: Metadata? = null - private var source: Source? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedback: Feedback) = apply { - this.id = feedback.id - this.comment = feedback.comment - this.metadata = feedback.metadata - this.source = feedback.source - additionalProperties(feedback.additionalProperties) - } - - /** - * The id of the function event to log feedback for. This is the row `id` returned - * by `POST /v1/function/{function_id}/insert` - */ - @JsonProperty("id") - fun id(id: String) = apply { - this.id = id - } - - /** An optional comment string to log about the function event */ - @JsonProperty("comment") - fun comment(comment: String) = apply { - this.comment = comment - } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(source: Source) = apply { - this.source = source - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Feedback = Feedback( - checkNotNull(id) { - "`id` is required but was not set" - }, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Source && - this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val APP = Source(JsonField.of("app")) - - @JvmField val API = Source(JsonField.of("api")) - - @JvmField val EXTERNAL = Source(JsonField.of("external")) - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - APP, - API, - EXTERNAL, - } - - enum class Value { - APP, - API, - EXTERNAL, - _UNKNOWN, - } - - fun value(): Value = when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 94db663..9b9e1ca 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -2,79 +2,83 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.FunctionService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Function -import com.braintrustdata.api.services.blocking.FunctionService -class FunctionListPage private constructor(private val functionsService: FunctionService, private val params: FunctionListParams, private val response: Response, ) { +class FunctionListPage +private constructor( + private val functionsService: FunctionService, + private val params: FunctionListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionListPage && - this.functionsService == other.functionsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is FunctionListPage && + this.functionsService == other.functionsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - functionsService, - params, - response, - ) + return Objects.hash( + functionsService, + params, + response, + ) } - override fun toString() = "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = + "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + FunctionListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + FunctionListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { functionsService.list(it) } + return getNextPageParams().map { functionsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +86,21 @@ class FunctionListPage private constructor(private val functionsService: Functio companion object { @JvmStatic - fun of(functionsService: FunctionService, params: FunctionListParams, response: Response) = FunctionListPage( - functionsService, - params, - response, - ) + fun of(functionsService: FunctionService, params: FunctionListParams, response: Response) = + FunctionListPage( + functionsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +115,33 @@ class FunctionListPage private constructor(private val functionsService: Functio fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "FunctionListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +169,25 @@ class FunctionListPage private constructor(private val functionsService: Functio } } - class AutoPager constructor(private val firstPage: FunctionListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: FunctionListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 3399f89..9daf7ae 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -2,83 +2,86 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.FunctionServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Function -import com.braintrustdata.api.services.async.FunctionServiceAsync -class FunctionListPageAsync private constructor(private val functionsService: FunctionServiceAsync, private val params: FunctionListParams, private val response: Response, ) { +class FunctionListPageAsync +private constructor( + private val functionsService: FunctionServiceAsync, + private val params: FunctionListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionListPageAsync && - this.functionsService == other.functionsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is FunctionListPageAsync && + this.functionsService == other.functionsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - functionsService, - params, - response, - ) + return Objects.hash( + functionsService, + params, + response, + ) } - override fun toString() = "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = + "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + FunctionListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + FunctionListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - functionsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { functionsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +89,25 @@ class FunctionListPageAsync private constructor(private val functionsService: Fu companion object { @JvmStatic - fun of(functionsService: FunctionServiceAsync, params: FunctionListParams, response: Response) = FunctionListPageAsync( - functionsService, - params, - response, - ) + fun of( + functionsService: FunctionServiceAsync, + params: FunctionListParams, + response: Response + ) = + FunctionListPageAsync( + functionsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +122,33 @@ class FunctionListPageAsync private constructor(private val functionsService: Fu fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "FunctionListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +176,32 @@ class FunctionListPageAsync private constructor(private val functionsService: Fu } } - class AutoPager constructor(private val firstPage: FunctionListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: FunctionListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Function) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Function) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 76d5d3c..d78221b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -2,54 +2,38 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class FunctionListParams constructor( - private val endingBefore: String?, - private val functionName: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val slug: String?, - private val startingAfter: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class FunctionListParams +constructor( + private val endingBefore: String?, + private val functionName: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val slug: String?, + private val startingAfter: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -72,40 +56,21 @@ class FunctionListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.functionName?.let { - params.put("function_name", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.slug?.let { - params.put("slug", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - this.version?.let { - params.put("version", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.functionName?.let { params.put("function_name", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.slug?.let { params.put("slug", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + this.version?.let { params.put("version", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -114,50 +79,50 @@ class FunctionListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionListParams && - this.endingBefore == other.endingBefore && - this.functionName == other.functionName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.slug == other.slug && - this.startingAfter == other.startingAfter && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionListParams && + this.endingBefore == other.endingBefore && + this.functionName == other.functionName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.slug == other.slug && + this.startingAfter == other.startingAfter && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - functionName, - ids, - limit, - orgName, - projectName, - slug, - startingAfter, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + functionName, + ids, + limit, + orgName, + projectName, + slug, + startingAfter, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -195,83 +160,61 @@ class FunctionListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** Name of the function to search for */ - fun functionName(functionName: String) = apply { - this.functionName = functionName - } + fun functionName(functionName: String) = apply { this.functionName = functionName } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** Retrieve prompt with a specific slug */ - fun slug(slug: String) = apply { - this.slug = slug - } + fun slug(slug: String) = apply { this.slug = slug } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -311,9 +254,7 @@ class FunctionListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -324,90 +265,96 @@ class FunctionListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): FunctionListParams = FunctionListParams( - endingBefore, - functionName, - ids, - limit, - orgName, - projectName, - slug, - startingAfter, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): FunctionListParams = + FunctionListParams( + endingBefore, + functionName, + ids, + limit, + orgName, + projectName, + slug, + startingAfter, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -417,34 +364,38 @@ class FunctionListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt index 1183fa3..993c3d9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt @@ -2,52 +2,44 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class FunctionReplaceParams constructor( - private val functionData: FunctionData, - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class FunctionReplaceParams +constructor( + private val functionData: FunctionData, + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun functionData(): FunctionData = functionData @@ -66,66 +58,57 @@ class FunctionReplaceParams constructor( @JvmSynthetic internal fun getBody(): FunctionReplaceBody { - return FunctionReplaceBody( - functionData, - name, - projectId, - slug, - description, - promptData, - tags, - additionalBodyProperties, - ) + return FunctionReplaceBody( + functionData, + name, + projectId, + slug, + description, + promptData, + tags, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = FunctionReplaceBody.Builder::class) @NoAutoDetect - class FunctionReplaceBody internal constructor( - private val functionData: FunctionData?, - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, - + class FunctionReplaceBody + internal constructor( + private val functionData: FunctionData?, + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("function_data") - fun functionData(): FunctionData? = functionData + @JsonProperty("function_data") fun functionData(): FunctionData? = functionData /** Name of the prompt */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(): String? = slug + @JsonProperty("slug") fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(): List? = tags + @JsonProperty("tags") fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -134,43 +117,44 @@ class FunctionReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionReplaceBody && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FunctionReplaceBody && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - functionData, - name, - projectId, - slug, - description, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + functionData, + name, + projectId, + slug, + description, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -202,40 +186,25 @@ class FunctionReplaceParams constructor( } /** Name of the prompt */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(slug: String) = apply { - this.slug = slug - } + @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(tags: List) = apply { - this.tags = tags - } + @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -251,24 +220,17 @@ class FunctionReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionReplaceBody = FunctionReplaceBody( - checkNotNull(functionData) { - "`functionData` is required but was not set" - }, - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionReplaceBody = + FunctionReplaceBody( + checkNotNull(functionData) { "`functionData` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -279,46 +241,46 @@ class FunctionReplaceParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionReplaceParams && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionReplaceParams && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionData, - name, - projectId, - slug, - description, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionData, + name, + projectId, + slug, + description, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -349,46 +311,34 @@ class FunctionReplaceParams constructor( additionalBodyProperties(functionReplaceParams.additionalBodyProperties) } - fun functionData(functionData: FunctionData) = apply { - this.functionData = functionData - } + fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } - fun functionData(type: FunctionData.Type) = apply { - this.functionData = FunctionData.ofType(type) + fun functionData(prompt: FunctionData.Prompt) = apply { + this.functionData = FunctionData.ofPrompt(prompt) } - fun functionData(unionMember1: FunctionData.UnionMember1) = apply { - this.functionData = FunctionData.ofUnionMember1(unionMember1) + fun functionData(code: FunctionData.Code) = apply { + this.functionData = FunctionData.ofCode(code) } - fun functionData(unionMember2: FunctionData.UnionMember2) = apply { - this.functionData = FunctionData.ofUnionMember2(unionMember2) + fun functionData(global: FunctionData.Global) = apply { + this.functionData = FunctionData.ofGlobal(global) } /** Name of the prompt */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { - this.slug = slug - } + fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -397,9 +347,7 @@ class FunctionReplaceParams constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - this.tags.add(tag) - } + fun addTag(tag: String) = apply { this.tags.add(tag) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -439,9 +387,7 @@ class FunctionReplaceParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -452,167 +398,175 @@ class FunctionReplaceParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): FunctionReplaceParams = FunctionReplaceParams( - checkNotNull(functionData) { - "`functionData` is required but was not set" - }, - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - if(tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): FunctionReplaceParams = + FunctionReplaceParams( + checkNotNull(functionData) { "`functionData` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + if (tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( - private val type: Type? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class FunctionData + private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun prompt(): Optional = Optional.ofNullable(prompt) + + fun code(): Optional = Optional.ofNullable(code) + + fun global(): Optional = Optional.ofNullable(global) + + fun isPrompt(): Boolean = prompt != null - fun isType(): Boolean = type != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isCode(): Boolean = code != null - fun asType(): Type = type.getOrThrow("type") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isGlobal(): Boolean = global != null + + fun asPrompt(): Prompt = prompt.getOrThrow("prompt") + + fun asCode(): Code = code.getOrThrow("code") + + fun asGlobal(): Global = global.getOrThrow("global") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } fun validate(): FunctionData = apply { if (!validated) { - if (type == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - type?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (prompt == null && code == null && global == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.type == other.type && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global } override fun hashCode(): Int { - return Objects.hash( - type, - unionMember1, - unionMember2, - ) + return Objects.hash( + prompt, + code, + global, + ) } override fun toString(): String { - return when { - type != null -> "FunctionData{type=$type}" - unionMember1 != null -> "FunctionData{unionMember1=$unionMember1}" - unionMember2 != null -> "FunctionData{unionMember2=$unionMember2}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { - @JvmStatic - fun ofType(type: Type) = FunctionData(type = type) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionData(unionMember1 = unionMember1) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = FunctionData(unionMember2 = unionMember2) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } interface Visitor { - fun visitType(type: Type): T + fun visitPrompt(prompt: Prompt): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitCode(code: Code): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGlobal(global: Global): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember2 = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.type != null -> generator.writeObject(value.type) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } - @JsonDeserialize(builder = Type.Builder::class) + @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class Prompt + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -620,46 +574,44 @@ class FunctionReplaceParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Type = apply { + fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -668,18 +620,16 @@ class FunctionReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) + internal fun from(prompt: Prompt) = apply { + this.type = prompt.type + additionalProperties(prompt.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -691,25 +641,28 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -732,23 +685,30 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { + class Code + private constructor( + private val type: JsonField, + private val data: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -758,56 +718,53 @@ class FunctionReplaceParams constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("data") - @ExcludeMissing - fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data() = data @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Code = apply { if (!validated) { - type() - data().validate() - validated = true + type() + data().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -817,27 +774,23 @@ class FunctionReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.data = unionMember1.data - additionalProperties(unionMember1.additionalProperties) + internal fun from(code: Code) = apply { + this.type = code.type + this.data = code.data + additionalProperties(code.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -849,25 +802,27 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = + Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect - class Data private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val additionalProperties: Map, - + class Data + private constructor( + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -884,13 +839,9 @@ class FunctionReplaceParams constructor( @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") - @ExcludeMissing - fun _location() = location + @JsonProperty("location") @ExcludeMissing fun _location() = location - @JsonProperty("bundle_id") - @ExcludeMissing - fun _bundleId() = bundleId + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId @JsonAnyGetter @ExcludeMissing @@ -898,45 +849,46 @@ class FunctionReplaceParams constructor( fun validate(): Data = apply { if (!validated) { - runtimeContext().validate() - location().validate() - bundleId() - validated = true + runtimeContext().validate() + location().validate() + bundleId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Data && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtimeContext, - location, - bundleId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtimeContext, + location, + bundleId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" + override fun toString() = + "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -954,7 +906,8 @@ class FunctionReplaceParams constructor( additionalProperties(data.additionalProperties) } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -966,17 +919,13 @@ class FunctionReplaceParams constructor( @JsonProperty("location") @ExcludeMissing - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = apply { this.location = location } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) @JsonProperty("bundle_id") @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -988,26 +937,28 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Data = Data( - runtimeContext, - location, - bundleId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Data = + Data( + runtimeContext, + location, + bundleId, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - + class Location + private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1020,17 +971,11 @@ class FunctionReplaceParams constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("eval_name") - @ExcludeMissing - fun _evalName() = evalName + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - @JsonProperty("position") - @ExcludeMissing - fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1038,45 +983,46 @@ class FunctionReplaceParams constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1084,7 +1030,8 @@ class FunctionReplaceParams constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(location: Location) = apply { @@ -1098,9 +1045,7 @@ class FunctionReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1118,145 +1063,161 @@ class FunctionReplaceParams constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Location = Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Location = + Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position private constructor(private val unionMember0: UnionMember0? = null, private val score: Score? = null, private val _json: JsonValue? = null, ) { + class Position + private constructor( + private val task: Task? = null, + private val score: Score? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun task(): Optional = Optional.ofNullable(task) + fun score(): Optional = Optional.ofNullable(score) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTask(): Boolean = task != null + fun isScore(): Boolean = score != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTask(): Task = task.getOrThrow("task") + fun asScore(): Score = score.getOrThrow("score") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - score != null -> visitor.visitScore(score) - else -> visitor.unknown(_json) - } + return when { + task != null -> visitor.visitTask(task) + score != null -> visitor.visitScore(score) + else -> visitor.unknown(_json) + } } fun validate(): Position = apply { if (!validated) { - if (unionMember0 == null && score == null) { - throw BraintrustInvalidDataException("Unknown Position: $_json") - } - score?.validate() - validated = true + if (task == null && score == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + score?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.unionMember0 == other.unionMember0 && - this.score == other.score + return other is Position && + this.task == other.task && + this.score == other.score } override fun hashCode(): Int { - return Objects.hash(unionMember0, score) + return Objects.hash(task, score) } override fun toString(): String { - return when { - unionMember0 != null -> "Position{unionMember0=$unionMember0}" - score != null -> "Position{score=$score}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + task != null -> "Position{task=$task}" + score != null -> "Position{score=$score}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Position(unionMember0 = unionMember0) + @JvmStatic fun ofTask(task: Task) = Position(task = task) - @JvmStatic - fun ofScore(score: Score) = Position(score = score) + @JvmStatic fun ofScore(score: Score) = Position(score = score) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTask(task: Task): T fun visitScore(score: Score): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Position(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Position(score = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Position(task = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(score = it, _json = json) + } - return Position(_json = json) + return Position(_json = json) } } class Serializer : BaseSerializer(Position::class) { - override fun serialize(value: Position, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.score != null -> generator.writeObject(value.score) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.task != null -> generator.writeObject(value.task) + value.score != null -> generator.writeObject(value.score) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Task + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Task && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1265,9 +1226,9 @@ class FunctionReplaceParams constructor( companion object { - @JvmField val TASK = UnionMember0(JsonField.of("task")) + @JvmField val TASK = Task(JsonField.of("task")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Task(JsonField.of(value)) } enum class Known { @@ -1279,22 +1240,29 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException("Unknown Task: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Score.Builder::class) @NoAutoDetect - class Score private constructor(private val score: JsonField, private val additionalProperties: Map, ) { + class Score + private constructor( + private val score: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1302,52 +1270,52 @@ class FunctionReplaceParams constructor( fun score(): Double = score.getRequired("score") - @JsonProperty("score") - @ExcludeMissing - fun _score() = score + @JsonProperty("score") @ExcludeMissing fun _score() = score @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Score = apply { if (!validated) { - score() - validated = true + score() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Score && - this.score == other.score && - this.additionalProperties == other.additionalProperties + return other is Score && + this.score == other.score && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(score, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(score, additionalProperties) + } + return hashCode } - override fun toString() = "Score{score=$score, additionalProperties=$additionalProperties}" + override fun toString() = + "Score{score=$score, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var score: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(score: Score) = apply { @@ -1359,11 +1327,11 @@ class FunctionReplaceParams constructor( @JsonProperty("score") @ExcludeMissing - fun score(score: JsonField) = apply { - this.score = score - } + fun score(score: JsonField) = apply { this.score = score } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1373,27 +1341,31 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Score = Score(score, additionalProperties.toUnmodifiable()) + fun build(): Score = + Score(score, additionalProperties.toUnmodifiable()) } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1416,15 +1388,17 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1432,7 +1406,12 @@ class FunctionReplaceParams constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { + class RuntimeContext + private constructor( + private val runtime: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1442,13 +1421,9 @@ class FunctionReplaceParams constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") - @ExcludeMissing - fun _runtime() = runtime + @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime - @JsonProperty("version") - @ExcludeMissing - fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1456,49 +1431,51 @@ class FunctionReplaceParams constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { @@ -1511,51 +1488,52 @@ class FunctionReplaceParams constructor( @JsonProperty("runtime") @ExcludeMissing - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) @JsonProperty("version") @ExcludeMissing - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): RuntimeContext = RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = + RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Runtime + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && - this.value == other.value + return other is Runtime && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1578,33 +1556,38 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NODE -> Value.NODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NODE -> Value.NODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NODE -> Known.NODE - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") - } + fun known(): Known = + when (this) { + NODE -> Known.NODE + else -> + throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1627,23 +1610,30 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Global + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1653,56 +1643,53 @@ class FunctionReplaceParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1712,27 +1699,23 @@ class FunctionReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.name = unionMember2.name - additionalProperties(unionMember2.additionalProperties) + internal fun from(global: Global) = apply { + this.type = global.type + this.name = global.name + additionalProperties(global.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1744,29 +1727,33 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = + Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1789,15 +1776,17 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1807,24 +1796,21 @@ class FunctionReplaceParams constructor( /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: Prompt?, - private val options: Options?, - private val origin: Origin?, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: Prompt?, + private val options: Options?, + private val origin: Origin?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt") - fun prompt(): Prompt? = prompt + @JsonProperty("prompt") fun prompt(): Prompt? = prompt - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options - @JsonProperty("origin") - fun origin(): Origin? = origin + @JsonProperty("origin") fun origin(): Origin? = origin @JsonAnyGetter @ExcludeMissing @@ -1833,35 +1819,36 @@ class FunctionReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1879,20 +1866,12 @@ class FunctionReplaceParams constructor( additionalProperties(promptData.additionalProperties) } - @JsonProperty("prompt") - fun prompt(prompt: Prompt) = apply { - this.prompt = prompt - } + @JsonProperty("prompt") fun prompt(prompt: Prompt) = apply { this.prompt = prompt } @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } - @JsonProperty("origin") - fun origin(origin: Origin) = apply { - this.origin = origin - } + @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1908,34 +1887,32 @@ class FunctionReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: String?, - private val params: Params?, - private val position: String?, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: String?, + private val params: Params?, + private val position: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("model") - fun model(): String? = model + @JsonProperty("model") fun model(): String? = model - @JsonProperty("params") - fun params(): Params? = params + @JsonProperty("params") fun params(): Params? = params - @JsonProperty("position") - fun position(): String? = position + @JsonProperty("position") fun position(): String? = position @JsonAnyGetter @ExcludeMissing @@ -1944,35 +1921,36 @@ class FunctionReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1990,20 +1968,12 @@ class FunctionReplaceParams constructor( additionalProperties(options.additionalProperties) } - @JsonProperty("model") - fun model(model: String) = apply { - this.model = model - } + @JsonProperty("model") fun model(model: String) = apply { this.model = model } - @JsonProperty("params") - fun params(params: Params) = apply { - this.params = params - } + @JsonProperty("params") fun params(params: Params) = apply { this.params = params } @JsonProperty("position") - fun position(position: String) = apply { - this.position = position - } + fun position(position: String) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2015,245 +1985,307 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) + + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) + + fun isOpenAIModelParams(): Boolean = openaiModelParams != null + + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2267,91 +2299,86 @@ class FunctionReplaceParams constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2367,22 +2394,23 @@ class FunctionReplaceParams constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2393,7 +2421,8 @@ class FunctionReplaceParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2405,9 +2434,7 @@ class FunctionReplaceParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -2417,7 +2444,8 @@ class FunctionReplaceParams constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2425,7 +2453,8 @@ class FunctionReplaceParams constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -2433,7 +2462,8 @@ class FunctionReplaceParams constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -2441,7 +2471,8 @@ class FunctionReplaceParams constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -2449,7 +2480,8 @@ class FunctionReplaceParams constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -2461,190 +2493,202 @@ class FunctionReplaceParams constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun asNone(): None = none.getOrThrow("none") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2653,9 +2697,9 @@ class FunctionReplaceParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -2667,31 +2711,37 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2700,9 +2750,9 @@ class FunctionReplaceParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -2714,22 +2764,29 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2737,68 +2794,68 @@ class FunctionReplaceParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -2808,18 +2865,23 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2827,9 +2889,7 @@ class FunctionReplaceParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -2837,42 +2897,43 @@ class FunctionReplaceParams constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -2884,39 +2945,42 @@ class FunctionReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2939,15 +3003,18 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2955,146 +3022,160 @@ class FunctionReplaceParams constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isFunction(): Boolean = function != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3103,9 +3184,9 @@ class FunctionReplaceParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -3117,31 +3198,37 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3150,9 +3237,9 @@ class FunctionReplaceParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -3164,22 +3251,30 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3189,78 +3284,75 @@ class FunctionReplaceParams constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -3270,7 +3362,9 @@ class FunctionReplaceParams constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -3280,20 +3374,25 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3301,52 +3400,53 @@ class FunctionReplaceParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -3358,40 +3458,47 @@ class FunctionReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3414,15 +3521,20 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -3430,25 +3542,26 @@ class FunctionReplaceParams constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -3458,30 +3571,22 @@ class FunctionReplaceParams constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -3496,59 +3601,60 @@ class FunctionReplaceParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3560,18 +3666,19 @@ class FunctionReplaceParams constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3590,7 +3697,8 @@ class FunctionReplaceParams constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3602,19 +3710,16 @@ class FunctionReplaceParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -3623,7 +3728,8 @@ class FunctionReplaceParams constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -3632,130 +3738,128 @@ class FunctionReplaceParams constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3765,16 +3869,17 @@ class FunctionReplaceParams constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3785,7 +3890,8 @@ class FunctionReplaceParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3793,7 +3899,8 @@ class FunctionReplaceParams constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -3805,120 +3912,115 @@ class FunctionReplaceParams constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3926,14 +4028,15 @@ class FunctionReplaceParams constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3944,7 +4047,8 @@ class FunctionReplaceParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3956,94 +4060,98 @@ class FunctionReplaceParams constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -4054,21 +4162,23 @@ class FunctionReplaceParams constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -4076,24 +4186,21 @@ class FunctionReplaceParams constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: String?, - private val projectId: String?, - private val promptVersion: String?, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: String?, + private val projectId: String?, + private val promptVersion: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt_id") - fun promptId(): String? = promptId + @JsonProperty("prompt_id") fun promptId(): String? = promptId - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId - @JsonProperty("prompt_version") - fun promptVersion(): String? = promptVersion + @JsonProperty("prompt_version") fun promptVersion(): String? = promptVersion @JsonAnyGetter @ExcludeMissing @@ -4102,35 +4209,36 @@ class FunctionReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4149,14 +4257,10 @@ class FunctionReplaceParams constructor( } @JsonProperty("prompt_id") - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } @JsonProperty("prompt_version") fun promptVersion(promptVersion: String) = apply { @@ -4173,154 +4277,175 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isCompletion(): Boolean = completion != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isChat(): Boolean = chat != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asCompletion(): Completion = completion.getOrThrow("completion") + + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4330,56 +4455,53 @@ class FunctionReplaceParams constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4389,27 +4511,23 @@ class FunctionReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4421,29 +4539,34 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4466,28 +4589,30 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4500,63 +4625,58 @@ class FunctionReplaceParams constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4567,20 +4687,18 @@ class FunctionReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -4594,9 +4712,7 @@ class FunctionReplaceParams constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4608,281 +4724,306 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4890,14 +5031,15 @@ class FunctionReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -4912,52 +5054,53 @@ class FunctionReplaceParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4980,97 +5123,96 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5078,14 +5220,15 @@ class FunctionReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -5100,52 +5243,53 @@ class FunctionReplaceParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5168,304 +5312,410 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent5s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent5s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent5s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent5s) + + fun unnamedSchemaWithArrayParent5s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent5s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent5s(): Boolean = unnamedSchemaWithArrayParent5s != null + + fun isUnnamedSchemaWithArrayParent5s(): Boolean = + unnamedSchemaWithArrayParent5s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent5s(): List = unnamedSchemaWithArrayParent5s.getOrThrow("unnamedSchemaWithArrayParent5s") + + fun asUnnamedSchemaWithArrayParent5s(): + List = + unnamedSchemaWithArrayParent5s.getOrThrow( + "unnamedSchemaWithArrayParent5s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent5s != null -> visitor.visitUnnamedSchemaWithArrayParent5s(unnamedSchemaWithArrayParent5s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent5s != null -> + visitor.visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent5s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent5s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent5s == other.unnamedSchemaWithArrayParent5s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent5s == + other.unnamedSchemaWithArrayParent5s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent5s) + return Objects.hash(string, unnamedSchemaWithArrayParent5s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent5s != null -> "Content{unnamedSchemaWithArrayParent5s=$unnamedSchemaWithArrayParent5s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent5s != null -> + "Content{unnamedSchemaWithArrayParent5s=$unnamedSchemaWithArrayParent5s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent5s(unnamedSchemaWithArrayParent5s: List) = Content(unnamedSchemaWithArrayParent5s = unnamedSchemaWithArrayParent5s) + fun ofUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: + List + ) = + Content( + unnamedSchemaWithArrayParent5s = + unnamedSchemaWithArrayParent5s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent5s(unnamedSchemaWithArrayParent5s: List): T + fun visitUnnamedSchemaWithArrayParent5s( + unnamedSchemaWithArrayParent5s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent5s = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent5s = it, + _json = json + ) + } - return Content(_json = json) + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent5s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent5s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent5s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent5s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent5.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent5.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent5.Serializer::class) - class UnnamedSchemaWithArrayParent5 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent5 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun isText(): Boolean = text != null + + fun isImageUrl(): Boolean = imageUrl != null + + fun asText(): Text = text.getOrThrow("text") + + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent5 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent5: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent5 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent5 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent5{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent5{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent5{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent5") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent5{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent5{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent5(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent5(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent5(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent5(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent5: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent5::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent5 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent5(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent5(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent5 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent5( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent5( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent5(_json = json) + return UnnamedSchemaWithArrayParent5(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent5::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent5, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent5") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent5, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -5480,43 +5730,50 @@ class FunctionReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5527,7 +5784,8 @@ class FunctionReplaceParams constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -5539,23 +5797,33 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5569,68 +5837,71 @@ class FunctionReplaceParams constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -5642,34 +5913,43 @@ class FunctionReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5677,11 +5957,10 @@ class FunctionReplaceParams constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -5689,53 +5968,58 @@ class FunctionReplaceParams constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -5752,7 +6036,8 @@ class FunctionReplaceParams constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -5760,39 +6045,52 @@ class FunctionReplaceParams constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5807,7 +6105,8 @@ class FunctionReplaceParams constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -5823,36 +6122,44 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5861,9 +6168,11 @@ class FunctionReplaceParams constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -5875,15 +6184,20 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -5892,16 +6206,16 @@ class FunctionReplaceParams constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -5910,85 +6224,81 @@ class FunctionReplaceParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5998,25 +6308,24 @@ class FunctionReplaceParams constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -6026,7 +6335,8 @@ class FunctionReplaceParams constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -6038,11 +6348,10 @@ class FunctionReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -6050,42 +6359,47 @@ class FunctionReplaceParams constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6108,22 +6422,30 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6133,63 +6455,62 @@ class FunctionReplaceParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -6198,7 +6519,8 @@ class FunctionReplaceParams constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6210,11 +6532,11 @@ class FunctionReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6224,26 +6546,27 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -6256,63 +6579,59 @@ class FunctionReplaceParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6320,7 +6639,8 @@ class FunctionReplaceParams constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -6334,9 +6654,7 @@ class FunctionReplaceParams constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -6350,11 +6668,11 @@ class FunctionReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6364,21 +6682,27 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6392,59 +6716,61 @@ class FunctionReplaceParams constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -6453,7 +6779,8 @@ class FunctionReplaceParams constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6465,44 +6792,51 @@ class FunctionReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6525,98 +6859,100 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6624,14 +6960,15 @@ class FunctionReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -6646,11 +6983,10 @@ class FunctionReplaceParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -6658,40 +6994,45 @@ class FunctionReplaceParams constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6714,97 +7055,96 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6812,14 +7152,15 @@ class FunctionReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -6834,52 +7175,53 @@ class FunctionReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6902,23 +7244,31 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6926,80 +7276,77 @@ class FunctionReplaceParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -7009,39 +7356,44 @@ class FunctionReplaceParams constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7064,33 +7416,39 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7113,23 +7471,28 @@ class FunctionReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -7139,36 +7502,36 @@ class FunctionReplaceParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -7176,8 +7539,8 @@ class FunctionReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -7190,11 +7553,13 @@ class FunctionReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index 9a5dc9c..b56c159 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class FunctionRetrieveParams constructor( - private val functionId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class FunctionRetrieveParams +constructor( + private val functionId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun functionId(): String = functionId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class FunctionRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionRetrieveParams && - this.functionId == other.functionId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionRetrieveParams && + this.functionId == other.functionId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "FunctionRetrieveParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "FunctionRetrieveParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class FunctionRetrieveParams constructor( } /** Function id */ - fun functionId(functionId: String) = apply { - this.functionId = functionId - } + fun functionId(functionId: String) = apply { this.functionId = functionId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class FunctionRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class FunctionRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): FunctionRetrieveParams = FunctionRetrieveParams( - checkNotNull(functionId) { - "`functionId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): FunctionRetrieveParams = + FunctionRetrieveParams( + checkNotNull(functionId) { "`functionId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index afa1c4d..338eeaa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -2,51 +2,43 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class FunctionUpdateParams constructor( - private val functionId: String, - private val description: String?, - private val functionData: FunctionData?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class FunctionUpdateParams +constructor( + private val functionId: String, + private val description: String?, + private val functionData: FunctionData?, + private val name: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun functionId(): String = functionId @@ -63,61 +55,54 @@ class FunctionUpdateParams constructor( @JvmSynthetic internal fun getBody(): FunctionUpdateBody { - return FunctionUpdateBody( - description, - functionData, - name, - promptData, - tags, - additionalBodyProperties, - ) + return FunctionUpdateBody( + description, + functionData, + name, + promptData, + tags, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } @JsonDeserialize(builder = FunctionUpdateBody.Builder::class) @NoAutoDetect - class FunctionUpdateBody internal constructor( - private val description: String?, - private val functionData: FunctionData?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, - + class FunctionUpdateBody + internal constructor( + private val description: String?, + private val functionData: FunctionData?, + private val name: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Textual description of the prompt */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description - @JsonProperty("function_data") - fun functionData(): FunctionData? = functionData + @JsonProperty("function_data") fun functionData(): FunctionData? = functionData /** Name of the prompt */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(): List? = tags + @JsonProperty("tags") fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -126,39 +111,40 @@ class FunctionUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionUpdateBody && - this.description == other.description && - this.functionData == other.functionData && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FunctionUpdateBody && + this.description == other.description && + this.functionData == other.functionData && + this.name == other.name && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - description, - functionData, - name, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + description, + functionData, + name, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -182,9 +168,7 @@ class FunctionUpdateParams constructor( /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } @JsonProperty("function_data") fun functionData(functionData: FunctionData) = apply { @@ -192,22 +176,14 @@ class FunctionUpdateParams constructor( } /** Name of the prompt */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(tags: List) = apply { - this.tags = tags - } + @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -223,14 +199,15 @@ class FunctionUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionUpdateBody = FunctionUpdateBody( - description, - functionData, - name, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionUpdateBody = + FunctionUpdateBody( + description, + functionData, + name, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -241,44 +218,44 @@ class FunctionUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionUpdateParams && - this.functionId == other.functionId && - this.description == other.description && - this.functionData == other.functionData && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionUpdateParams && + this.functionId == other.functionId && + this.description == other.description && + this.functionData == other.functionData && + this.name == other.name && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionId, - description, - functionData, - name, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionId, + description, + functionData, + name, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -308,44 +285,34 @@ class FunctionUpdateParams constructor( } /** Function id */ - fun functionId(functionId: String) = apply { - this.functionId = functionId - } + fun functionId(functionId: String) = apply { this.functionId = functionId } /** Textual description of the prompt */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } - fun functionData(functionData: FunctionData) = apply { - this.functionData = functionData - } + fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } - fun functionData(type: FunctionData.Type) = apply { - this.functionData = FunctionData.ofType(type) + fun functionData(prompt: FunctionData.Prompt) = apply { + this.functionData = FunctionData.ofPrompt(prompt) } - fun functionData(unionMember1: FunctionData.UnionMember1) = apply { - this.functionData = FunctionData.ofUnionMember1(unionMember1) + fun functionData(code: FunctionData.Code) = apply { + this.functionData = FunctionData.ofCode(code) } - fun functionData(unionMember2: FunctionData.UnionMember2) = apply { - this.functionData = FunctionData.ofUnionMember2(unionMember2) + fun functionData(global: FunctionData.Global) = apply { + this.functionData = FunctionData.ofGlobal(global) } - fun functionData(unionMember3: UnionMember3) = apply { - this.functionData = FunctionData.ofUnionMember3(unionMember3) + fun functionData(nullableVariant: FunctionData.NullableVariant) = apply { + this.functionData = FunctionData.ofNullableVariant(nullableVariant) } /** Name of the prompt */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -354,9 +321,7 @@ class FunctionUpdateParams constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - this.tags.add(tag) - } + fun addTag(tag: String) = apply { this.tags.add(tag) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -396,9 +361,7 @@ class FunctionUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -409,178 +372,197 @@ class FunctionUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): FunctionUpdateParams = FunctionUpdateParams( - checkNotNull(functionId) { - "`functionId` is required but was not set" - }, - description, - functionData, - name, - promptData, - if(tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): FunctionUpdateParams = + FunctionUpdateParams( + checkNotNull(functionId) { "`functionId` is required but was not set" }, + description, + functionData, + name, + promptData, + if (tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( - private val type: Type? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val _json: JsonValue? = null, - + class FunctionData + private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + fun prompt(): Optional = Optional.ofNullable(prompt) + + fun code(): Optional = Optional.ofNullable(code) + + fun global(): Optional = Optional.ofNullable(global) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isPrompt(): Boolean = prompt != null + + fun isCode(): Boolean = code != null + + fun isGlobal(): Boolean = global != null + + fun isNullableVariant(): Boolean = nullableVariant != null - fun isType(): Boolean = type != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null + fun asPrompt(): Prompt = prompt.getOrThrow("prompt") - fun asType(): Type = type.getOrThrow("type") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + fun asCode(): Code = code.getOrThrow("code") + + fun asGlobal(): Global = global.getOrThrow("global") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): FunctionData = apply { if (!validated) { - if (type == null && unionMember1 == null && unionMember2 == null && unionMember3 == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - type?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - validated = true + if (prompt == null && code == null && global == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.type == other.type && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - type, - unionMember1, - unionMember2, - unionMember3, - ) + return Objects.hash( + prompt, + code, + global, + nullableVariant, + ) } override fun toString(): String { - return when { - type != null -> "FunctionData{type=$type}" - unionMember1 != null -> "FunctionData{unionMember1=$unionMember1}" - unionMember2 != null -> "FunctionData{unionMember2=$unionMember2}" - unionMember3 != null -> "FunctionData{unionMember3=$unionMember3}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + nullableVariant != null -> "FunctionData{nullableVariant=$nullableVariant}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { - @JvmStatic - fun ofType(type: Type) = FunctionData(type = type) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionData(unionMember1 = unionMember1) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = FunctionData(unionMember2 = unionMember2) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = FunctionData(unionMember3 = unionMember3) + fun ofNullableVariant(nullableVariant: NullableVariant) = + FunctionData(nullableVariant = nullableVariant) } interface Visitor { - fun visitType(type: Type): T + fun visitPrompt(prompt: Prompt): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitCode(code: Code): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGlobal(global: Global): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(unionMember3 = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(nullableVariant = it, _json = json) + } + + return FunctionData(_json = json) } } class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.type != null -> generator.writeObject(value.type) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } - @JsonDeserialize(builder = Type.Builder::class) + @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class Prompt + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -588,46 +570,44 @@ class FunctionUpdateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Type = apply { + fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -636,18 +616,16 @@ class FunctionUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) + internal fun from(prompt: Prompt) = apply { + this.type = prompt.type + additionalProperties(prompt.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -659,25 +637,28 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -700,23 +681,30 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { + class Code + private constructor( + private val type: JsonField, + private val data: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -726,56 +714,53 @@ class FunctionUpdateParams constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("data") - @ExcludeMissing - fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data() = data @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Code = apply { if (!validated) { - type() - data().validate() - validated = true + type() + data().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -785,27 +770,23 @@ class FunctionUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.data = unionMember1.data - additionalProperties(unionMember1.additionalProperties) + internal fun from(code: Code) = apply { + this.type = code.type + this.data = code.data + additionalProperties(code.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -817,25 +798,27 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = + Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Data.Builder::class) @NoAutoDetect - class Data private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val additionalProperties: Map, - + class Data + private constructor( + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -852,13 +835,9 @@ class FunctionUpdateParams constructor( @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") - @ExcludeMissing - fun _location() = location + @JsonProperty("location") @ExcludeMissing fun _location() = location - @JsonProperty("bundle_id") - @ExcludeMissing - fun _bundleId() = bundleId + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId @JsonAnyGetter @ExcludeMissing @@ -866,45 +845,46 @@ class FunctionUpdateParams constructor( fun validate(): Data = apply { if (!validated) { - runtimeContext().validate() - location().validate() - bundleId() - validated = true + runtimeContext().validate() + location().validate() + bundleId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Data && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtimeContext, - location, - bundleId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtimeContext, + location, + bundleId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" + override fun toString() = + "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -922,7 +902,8 @@ class FunctionUpdateParams constructor( additionalProperties(data.additionalProperties) } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -934,17 +915,13 @@ class FunctionUpdateParams constructor( @JsonProperty("location") @ExcludeMissing - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = apply { this.location = location } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) @JsonProperty("bundle_id") @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -956,26 +933,28 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Data = Data( - runtimeContext, - location, - bundleId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Data = + Data( + runtimeContext, + location, + bundleId, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - + class Location + private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -988,17 +967,11 @@ class FunctionUpdateParams constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("eval_name") - @ExcludeMissing - fun _evalName() = evalName + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - @JsonProperty("position") - @ExcludeMissing - fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1006,45 +979,46 @@ class FunctionUpdateParams constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1052,7 +1026,8 @@ class FunctionUpdateParams constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(location: Location) = apply { @@ -1066,9 +1041,7 @@ class FunctionUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1086,145 +1059,161 @@ class FunctionUpdateParams constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Location = Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Location = + Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position private constructor(private val unionMember0: UnionMember0? = null, private val score: Score? = null, private val _json: JsonValue? = null, ) { + class Position + private constructor( + private val task: Task? = null, + private val score: Score? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun task(): Optional = Optional.ofNullable(task) + fun score(): Optional = Optional.ofNullable(score) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTask(): Boolean = task != null + fun isScore(): Boolean = score != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTask(): Task = task.getOrThrow("task") + fun asScore(): Score = score.getOrThrow("score") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - score != null -> visitor.visitScore(score) - else -> visitor.unknown(_json) - } + return when { + task != null -> visitor.visitTask(task) + score != null -> visitor.visitScore(score) + else -> visitor.unknown(_json) + } } fun validate(): Position = apply { if (!validated) { - if (unionMember0 == null && score == null) { - throw BraintrustInvalidDataException("Unknown Position: $_json") - } - score?.validate() - validated = true + if (task == null && score == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + score?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.unionMember0 == other.unionMember0 && - this.score == other.score + return other is Position && + this.task == other.task && + this.score == other.score } override fun hashCode(): Int { - return Objects.hash(unionMember0, score) + return Objects.hash(task, score) } override fun toString(): String { - return when { - unionMember0 != null -> "Position{unionMember0=$unionMember0}" - score != null -> "Position{score=$score}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + task != null -> "Position{task=$task}" + score != null -> "Position{score=$score}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Position(unionMember0 = unionMember0) + @JvmStatic fun ofTask(task: Task) = Position(task = task) - @JvmStatic - fun ofScore(score: Score) = Position(score = score) + @JvmStatic fun ofScore(score: Score) = Position(score = score) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTask(task: Task): T fun visitScore(score: Score): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Position(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Position(score = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Position(task = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(score = it, _json = json) + } - return Position(_json = json) + return Position(_json = json) } } class Serializer : BaseSerializer(Position::class) { - override fun serialize(value: Position, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.score != null -> generator.writeObject(value.score) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.task != null -> generator.writeObject(value.task) + value.score != null -> generator.writeObject(value.score) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Task + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Task && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1233,9 +1222,9 @@ class FunctionUpdateParams constructor( companion object { - @JvmField val TASK = UnionMember0(JsonField.of("task")) + @JvmField val TASK = Task(JsonField.of("task")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Task(JsonField.of(value)) } enum class Known { @@ -1247,22 +1236,29 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException("Unknown Task: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Score.Builder::class) @NoAutoDetect - class Score private constructor(private val score: JsonField, private val additionalProperties: Map, ) { + class Score + private constructor( + private val score: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1270,52 +1266,52 @@ class FunctionUpdateParams constructor( fun score(): Double = score.getRequired("score") - @JsonProperty("score") - @ExcludeMissing - fun _score() = score + @JsonProperty("score") @ExcludeMissing fun _score() = score @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Score = apply { if (!validated) { - score() - validated = true + score() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Score && - this.score == other.score && - this.additionalProperties == other.additionalProperties + return other is Score && + this.score == other.score && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(score, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(score, additionalProperties) + } + return hashCode } - override fun toString() = "Score{score=$score, additionalProperties=$additionalProperties}" + override fun toString() = + "Score{score=$score, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var score: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(score: Score) = apply { @@ -1327,11 +1323,11 @@ class FunctionUpdateParams constructor( @JsonProperty("score") @ExcludeMissing - fun score(score: JsonField) = apply { - this.score = score - } + fun score(score: JsonField) = apply { this.score = score } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1341,27 +1337,31 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Score = Score(score, additionalProperties.toUnmodifiable()) + fun build(): Score = + Score(score, additionalProperties.toUnmodifiable()) } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1384,15 +1384,17 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1400,7 +1402,12 @@ class FunctionUpdateParams constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { + class RuntimeContext + private constructor( + private val runtime: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1410,13 +1417,9 @@ class FunctionUpdateParams constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") - @ExcludeMissing - fun _runtime() = runtime + @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime - @JsonProperty("version") - @ExcludeMissing - fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1424,49 +1427,51 @@ class FunctionUpdateParams constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { @@ -1479,51 +1484,52 @@ class FunctionUpdateParams constructor( @JsonProperty("runtime") @ExcludeMissing - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) @JsonProperty("version") @ExcludeMissing - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): RuntimeContext = RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = + RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Runtime + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && - this.value == other.value + return other is Runtime && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1546,33 +1552,38 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NODE -> Value.NODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NODE -> Value.NODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NODE -> Known.NODE - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") - } + fun known(): Known = + when (this) { + NODE -> Known.NODE + else -> + throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1595,23 +1606,30 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Global + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1621,56 +1639,53 @@ class FunctionUpdateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1680,27 +1695,23 @@ class FunctionUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.name = unionMember2.name - additionalProperties(unionMember2.additionalProperties) + internal fun from(global: Global) = apply { + this.type = global.type + this.name = global.name + additionalProperties(global.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1712,29 +1723,33 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = + Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1757,23 +1772,28 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember3 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1783,36 +1803,35 @@ class FunctionUpdateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1820,8 +1839,8 @@ class FunctionUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - additionalProperties(unionMember3.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -1834,11 +1853,13 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember3 = UnionMember3(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } @@ -1846,24 +1867,21 @@ class FunctionUpdateParams constructor( /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: Prompt?, - private val options: Options?, - private val origin: Origin?, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: Prompt?, + private val options: Options?, + private val origin: Origin?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt") - fun prompt(): Prompt? = prompt + @JsonProperty("prompt") fun prompt(): Prompt? = prompt - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options - @JsonProperty("origin") - fun origin(): Origin? = origin + @JsonProperty("origin") fun origin(): Origin? = origin @JsonAnyGetter @ExcludeMissing @@ -1872,35 +1890,36 @@ class FunctionUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1918,20 +1937,12 @@ class FunctionUpdateParams constructor( additionalProperties(promptData.additionalProperties) } - @JsonProperty("prompt") - fun prompt(prompt: Prompt) = apply { - this.prompt = prompt - } + @JsonProperty("prompt") fun prompt(prompt: Prompt) = apply { this.prompt = prompt } @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } - @JsonProperty("origin") - fun origin(origin: Origin) = apply { - this.origin = origin - } + @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1947,34 +1958,32 @@ class FunctionUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: String?, - private val params: Params?, - private val position: String?, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: String?, + private val params: Params?, + private val position: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("model") - fun model(): String? = model + @JsonProperty("model") fun model(): String? = model - @JsonProperty("params") - fun params(): Params? = params + @JsonProperty("params") fun params(): Params? = params - @JsonProperty("position") - fun position(): String? = position + @JsonProperty("position") fun position(): String? = position @JsonAnyGetter @ExcludeMissing @@ -1983,35 +1992,36 @@ class FunctionUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2029,20 +2039,12 @@ class FunctionUpdateParams constructor( additionalProperties(options.additionalProperties) } - @JsonProperty("model") - fun model(model: String) = apply { - this.model = model - } + @JsonProperty("model") fun model(model: String) = apply { this.model = model } - @JsonProperty("params") - fun params(params: Params) = apply { - this.params = params - } + @JsonProperty("params") fun params(params: Params) = apply { this.params = params } @JsonProperty("position") - fun position(position: String) = apply { - this.position = position - } + fun position(position: String) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2054,245 +2056,307 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) + + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) + + fun isOpenAIModelParams(): Boolean = openaiModelParams != null + + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null + + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2306,91 +2370,86 @@ class FunctionUpdateParams constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2406,22 +2465,23 @@ class FunctionUpdateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2432,7 +2492,8 @@ class FunctionUpdateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2444,9 +2505,7 @@ class FunctionUpdateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -2456,7 +2515,8 @@ class FunctionUpdateParams constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -2464,7 +2524,8 @@ class FunctionUpdateParams constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -2472,7 +2533,8 @@ class FunctionUpdateParams constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -2480,7 +2542,8 @@ class FunctionUpdateParams constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -2488,7 +2551,8 @@ class FunctionUpdateParams constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -2500,190 +2564,202 @@ class FunctionUpdateParams constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun isNone(): Boolean = none != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2692,9 +2768,9 @@ class FunctionUpdateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -2706,31 +2782,37 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2739,9 +2821,9 @@ class FunctionUpdateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -2753,22 +2835,29 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2776,68 +2865,68 @@ class FunctionUpdateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -2847,18 +2936,23 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2866,9 +2960,7 @@ class FunctionUpdateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -2876,42 +2968,43 @@ class FunctionUpdateParams constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -2923,39 +3016,42 @@ class FunctionUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2978,15 +3074,18 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2994,146 +3093,160 @@ class FunctionUpdateParams constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun asAuto(): Auto = auto.getOrThrow("auto") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3142,9 +3255,9 @@ class FunctionUpdateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -3156,31 +3269,37 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3189,9 +3308,9 @@ class FunctionUpdateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -3203,22 +3322,30 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3228,78 +3355,75 @@ class FunctionUpdateParams constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -3309,7 +3433,9 @@ class FunctionUpdateParams constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -3319,20 +3445,25 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3340,52 +3471,53 @@ class FunctionUpdateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -3397,40 +3529,47 @@ class FunctionUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3453,15 +3592,20 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -3469,25 +3613,26 @@ class FunctionUpdateParams constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -3497,30 +3642,22 @@ class FunctionUpdateParams constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -3535,59 +3672,60 @@ class FunctionUpdateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3599,18 +3737,19 @@ class FunctionUpdateParams constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3629,7 +3768,8 @@ class FunctionUpdateParams constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3641,19 +3781,16 @@ class FunctionUpdateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -3662,7 +3799,8 @@ class FunctionUpdateParams constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -3671,130 +3809,128 @@ class FunctionUpdateParams constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3804,16 +3940,17 @@ class FunctionUpdateParams constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3824,7 +3961,8 @@ class FunctionUpdateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3832,7 +3970,8 @@ class FunctionUpdateParams constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -3844,120 +3983,115 @@ class FunctionUpdateParams constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3965,14 +4099,15 @@ class FunctionUpdateParams constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -3983,7 +4118,8 @@ class FunctionUpdateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -3995,94 +4131,98 @@ class FunctionUpdateParams constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -4093,21 +4233,23 @@ class FunctionUpdateParams constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -4115,24 +4257,21 @@ class FunctionUpdateParams constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: String?, - private val projectId: String?, - private val promptVersion: String?, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: String?, + private val projectId: String?, + private val promptVersion: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt_id") - fun promptId(): String? = promptId + @JsonProperty("prompt_id") fun promptId(): String? = promptId - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId - @JsonProperty("prompt_version") - fun promptVersion(): String? = promptVersion + @JsonProperty("prompt_version") fun promptVersion(): String? = promptVersion @JsonAnyGetter @ExcludeMissing @@ -4141,35 +4280,36 @@ class FunctionUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4188,14 +4328,10 @@ class FunctionUpdateParams constructor( } @JsonProperty("prompt_id") - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } @JsonProperty("prompt_version") fun promptVersion(promptVersion: String) = apply { @@ -4212,154 +4348,175 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isCompletion(): Boolean = completion != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isChat(): Boolean = chat != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asCompletion(): Completion = completion.getOrThrow("completion") + + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4369,56 +4526,53 @@ class FunctionUpdateParams constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4428,27 +4582,23 @@ class FunctionUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4460,29 +4610,34 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4505,28 +4660,30 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4539,63 +4696,58 @@ class FunctionUpdateParams constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4606,20 +4758,18 @@ class FunctionUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -4633,9 +4783,7 @@ class FunctionUpdateParams constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4647,281 +4795,306 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4929,14 +5102,15 @@ class FunctionUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -4951,52 +5125,53 @@ class FunctionUpdateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5019,97 +5194,96 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5117,14 +5291,15 @@ class FunctionUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -5139,52 +5314,53 @@ class FunctionUpdateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5207,304 +5383,410 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent4s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent4s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent4s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent4s) + + fun unnamedSchemaWithArrayParent4s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent4s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent4s(): Boolean = unnamedSchemaWithArrayParent4s != null + + fun isUnnamedSchemaWithArrayParent4s(): Boolean = + unnamedSchemaWithArrayParent4s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent4s(): List = unnamedSchemaWithArrayParent4s.getOrThrow("unnamedSchemaWithArrayParent4s") + + fun asUnnamedSchemaWithArrayParent4s(): + List = + unnamedSchemaWithArrayParent4s.getOrThrow( + "unnamedSchemaWithArrayParent4s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent4s != null -> visitor.visitUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent4s != null -> + visitor.visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent4s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent4s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent4s == other.unnamedSchemaWithArrayParent4s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent4s == + other.unnamedSchemaWithArrayParent4s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent4s) + return Objects.hash(string, unnamedSchemaWithArrayParent4s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent4s != null -> "Content{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent4s != null -> + "Content{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s: List) = Content(unnamedSchemaWithArrayParent4s = unnamedSchemaWithArrayParent4s) + fun ofUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: + List + ) = + Content( + unnamedSchemaWithArrayParent4s = + unnamedSchemaWithArrayParent4s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s: List): T + fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent4s = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent4s = it, + _json = json + ) + } - return Content(_json = json) + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent4s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent4s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent4s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent4s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent4.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) - class UnnamedSchemaWithArrayParent4 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent4 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) + + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) + + fun isText(): Boolean = text != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isImageUrl(): Boolean = imageUrl != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asText(): Text = text.getOrThrow("text") + + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent4 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent4: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent4: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent4 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent4 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent4{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent4{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent4{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent4{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent4" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent4(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent4(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent4(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent4(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent4: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent4: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent4::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent4 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent4(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent4(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent4 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent4( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent4( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent4(_json = json) + return UnnamedSchemaWithArrayParent4(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent4::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent4, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent4, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent4" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -5519,43 +5801,50 @@ class FunctionUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5566,7 +5855,8 @@ class FunctionUpdateParams constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -5578,23 +5868,33 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5608,68 +5908,71 @@ class FunctionUpdateParams constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -5681,34 +5984,43 @@ class FunctionUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5716,11 +6028,10 @@ class FunctionUpdateParams constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -5728,53 +6039,58 @@ class FunctionUpdateParams constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -5791,7 +6107,8 @@ class FunctionUpdateParams constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -5799,39 +6116,52 @@ class FunctionUpdateParams constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5846,7 +6176,8 @@ class FunctionUpdateParams constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -5862,36 +6193,44 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5900,9 +6239,11 @@ class FunctionUpdateParams constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -5914,15 +6255,20 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -5931,16 +6277,16 @@ class FunctionUpdateParams constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -5949,85 +6295,81 @@ class FunctionUpdateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6037,25 +6379,24 @@ class FunctionUpdateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -6065,7 +6406,8 @@ class FunctionUpdateParams constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -6077,11 +6419,10 @@ class FunctionUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -6089,42 +6430,47 @@ class FunctionUpdateParams constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6147,22 +6493,30 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6172,63 +6526,62 @@ class FunctionUpdateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -6237,7 +6590,8 @@ class FunctionUpdateParams constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6249,11 +6603,11 @@ class FunctionUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6263,26 +6617,27 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -6295,63 +6650,59 @@ class FunctionUpdateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6359,7 +6710,8 @@ class FunctionUpdateParams constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -6373,9 +6725,7 @@ class FunctionUpdateParams constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -6389,11 +6739,11 @@ class FunctionUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -6403,21 +6753,27 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6431,59 +6787,61 @@ class FunctionUpdateParams constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -6492,7 +6850,8 @@ class FunctionUpdateParams constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -6504,44 +6863,51 @@ class FunctionUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6564,98 +6930,100 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6663,14 +7031,15 @@ class FunctionUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -6685,11 +7054,10 @@ class FunctionUpdateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -6697,40 +7065,45 @@ class FunctionUpdateParams constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6753,97 +7126,96 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6851,14 +7223,15 @@ class FunctionUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -6873,52 +7246,53 @@ class FunctionUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -6941,23 +7315,31 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -6965,80 +7347,77 @@ class FunctionUpdateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -7048,39 +7427,44 @@ class FunctionUpdateParams constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7103,33 +7487,39 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -7152,23 +7542,28 @@ class FunctionUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -7178,36 +7573,36 @@ class FunctionUpdateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -7215,8 +7610,8 @@ class FunctionUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -7229,11 +7624,13 @@ class FunctionUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 3cd69e5..e642791 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -2,57 +2,39 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException /** * A group is a collection of users which can be assigned an ACL * - * Groups can consist of individual users, as well as a set of groups they inherit - * from + * Groups can consist of individual users, as well as a set of groups they inherit from */ @JsonDeserialize(builder = Group.Builder::class) @NoAutoDetect -class Group private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val deletedAt: JsonField, - private val memberUsers: JsonField>, - private val memberGroups: JsonField>, - private val additionalProperties: Map, - +class Group +private constructor( + private val id: JsonField, + private val orgId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val deletedAt: JsonField, + private val memberUsers: JsonField>, + private val memberGroups: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -79,75 +61,61 @@ class Group private constructor( fun name(): String = name.getRequired("name") /** Textual description of the group */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ - fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = + Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Unique identifier for the group */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** * Unique id for the organization that the group belongs under * * It is forbidden to change the org after creating a group */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** Identifies the user who created the group */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** Date of group creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Textual description of the group */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** Date of group deletion, or null if the group is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt /** Ids of users which belong to this group */ - @JsonProperty("member_users") - @ExcludeMissing - fun _memberUsers() = memberUsers + @JsonProperty("member_users") @ExcludeMissing fun _memberUsers() = memberUsers /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ - @JsonProperty("member_groups") - @ExcludeMissing - fun _memberGroups() = memberGroups + @JsonProperty("member_groups") @ExcludeMissing fun _memberGroups() = memberGroups @JsonAnyGetter @ExcludeMissing @@ -155,63 +123,64 @@ class Group private constructor( fun validate(): Group = apply { if (!validated) { - id() - orgId() - userId() - created() - name() - description() - deletedAt() - memberUsers() - memberGroups() - validated = true + id() + orgId() + userId() + created() + name() + description() + deletedAt() + memberUsers() + memberGroups() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Group && - this.id == other.id && - this.orgId == other.orgId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.deletedAt == other.deletedAt && - this.memberUsers == other.memberUsers && - this.memberGroups == other.memberGroups && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Group && + this.id == other.id && + this.orgId == other.orgId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.deletedAt == other.deletedAt && + this.memberUsers == other.memberUsers && + this.memberGroups == other.memberGroups && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberUsers, - memberGroups, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberUsers, + memberGroups, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" + override fun toString() = + "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -245,11 +214,7 @@ class Group private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the group */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** * Unique id for the organization that the group belongs under @@ -265,9 +230,7 @@ class Group private constructor( */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Identifies the user who created the group */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -275,9 +238,7 @@ class Group private constructor( /** Identifies the user who created the group */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Date of group creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -285,9 +246,7 @@ class Group private constructor( /** Date of group creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) @@ -295,9 +254,7 @@ class Group private constructor( /** Name of the group */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the group */ fun description(description: String) = description(JsonField.of(description)) @@ -305,9 +262,7 @@ class Group private constructor( /** Textual description of the group */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** Date of group deletion, or null if the group is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -315,9 +270,7 @@ class Group private constructor( /** Date of group deletion, or null if the group is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List) = memberUsers(JsonField.of(memberUsers)) @@ -332,16 +285,16 @@ class Group private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ fun memberGroups(memberGroups: List) = memberGroups(JsonField.of(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -363,17 +316,18 @@ class Group private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Group = Group( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberUsers.map { it.toUnmodifiable() }, - memberGroups.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Group = + Group( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberUsers.map { it.toUnmodifiable() }, + memberGroups.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 8b0ed1f..50bdabc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -2,50 +2,28 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class GroupCreateParams constructor( - private val name: String, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class GroupCreateParams +constructor( + private val name: String, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -60,64 +38,57 @@ class GroupCreateParams constructor( @JvmSynthetic internal fun getBody(): GroupCreateBody { - return GroupCreateBody( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalBodyProperties, - ) + return GroupCreateBody( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = GroupCreateBody.Builder::class) @NoAutoDetect - class GroupCreateBody internal constructor( - private val name: String?, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalProperties: Map, - + class GroupCreateBody + internal constructor( + private val name: String?, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the group */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Textual description of the group */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - @JsonProperty("member_groups") - fun memberGroups(): List? = memberGroups + @JsonProperty("member_groups") fun memberGroups(): List? = memberGroups /** Ids of users which belong to this group */ - @JsonProperty("member_users") - fun memberUsers(): List? = memberUsers + @JsonProperty("member_users") fun memberUsers(): List? = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - @JsonProperty("org_name") - fun orgName(): String? = orgName + @JsonProperty("org_name") fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -126,39 +97,40 @@ class GroupCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupCreateBody && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GroupCreateBody && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -181,22 +153,17 @@ class GroupCreateParams constructor( } /** Name of the group */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Textual description of the group */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ @JsonProperty("member_groups") fun memberGroups(memberGroups: List) = apply { @@ -205,19 +172,15 @@ class GroupCreateParams constructor( /** Ids of users which belong to this group */ @JsonProperty("member_users") - fun memberUsers(memberUsers: List) = apply { - this.memberUsers = memberUsers - } + fun memberUsers(memberUsers: List) = apply { this.memberUsers = memberUsers } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -233,16 +196,15 @@ class GroupCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupCreateBody = GroupCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - memberGroups?.toUnmodifiable(), - memberUsers?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): GroupCreateBody = + GroupCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + description, + memberGroups?.toUnmodifiable(), + memberUsers?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -253,42 +215,42 @@ class GroupCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupCreateParams && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupCreateParams && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -316,20 +278,16 @@ class GroupCreateParams constructor( } /** Name of the group */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Textual description of the group */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ fun memberGroups(memberGroups: List) = apply { this.memberGroups.clear() @@ -339,12 +297,10 @@ class GroupCreateParams constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - this.memberGroups.add(memberGroup) - } + fun addMemberGroup(memberGroup: String) = apply { this.memberGroups.add(memberGroup) } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List) = apply { @@ -353,18 +309,14 @@ class GroupCreateParams constructor( } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - this.memberUsers.add(memberUser) - } + fun addMemberUser(memberUser: String) = apply { this.memberUsers.add(memberUser) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -404,9 +356,7 @@ class GroupCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -417,21 +367,21 @@ class GroupCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): GroupCreateParams = GroupCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - if(memberGroups.size == 0) null else memberGroups.toUnmodifiable(), - if(memberUsers.size == 0) null else memberUsers.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): GroupCreateParams = + GroupCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + description, + if (memberGroups.size == 0) null else memberGroups.toUnmodifiable(), + if (memberUsers.size == 0) null else memberUsers.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 1ada260..275bba9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class GroupDeleteParams constructor( - private val groupId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class GroupDeleteParams +constructor( + private val groupId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun groupId(): String = groupId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class GroupDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupDeleteParams && - this.groupId == other.groupId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupDeleteParams && + this.groupId == other.groupId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - groupId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + groupId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "GroupDeleteParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "GroupDeleteParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class GroupDeleteParams constructor( } /** Group id */ - fun groupId(groupId: String) = apply { - this.groupId = groupId - } + fun groupId(groupId: String) = apply { this.groupId = groupId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class GroupDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class GroupDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): GroupDeleteParams = GroupDeleteParams( - checkNotNull(groupId) { - "`groupId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): GroupDeleteParams = + GroupDeleteParams( + checkNotNull(groupId) { "`groupId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 05a2616..9d3d9ce 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -2,79 +2,77 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.GroupService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Group -import com.braintrustdata.api.services.blocking.GroupService -class GroupListPage private constructor(private val groupsService: GroupService, private val params: GroupListParams, private val response: Response, ) { +class GroupListPage +private constructor( + private val groupsService: GroupService, + private val params: GroupListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupListPage && - this.groupsService == other.groupsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is GroupListPage && + this.groupsService == other.groupsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - groupsService, - params, - response, - ) + return Objects.hash( + groupsService, + params, + response, + ) } - override fun toString() = "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = + "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { groupsService.list(it) } + return getNextPageParams().map { groupsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +80,21 @@ class GroupListPage private constructor(private val groupsService: GroupService, companion object { @JvmStatic - fun of(groupsService: GroupService, params: GroupListParams, response: Response) = GroupListPage( - groupsService, - params, - response, - ) + fun of(groupsService: GroupService, params: GroupListParams, response: Response) = + GroupListPage( + groupsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +109,33 @@ class GroupListPage private constructor(private val groupsService: GroupService, fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "GroupListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "GroupListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +163,25 @@ class GroupListPage private constructor(private val groupsService: GroupService, } } - class AutoPager constructor(private val firstPage: GroupListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: GroupListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 28e0af8..cc058b5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -2,83 +2,80 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.GroupServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Group -import com.braintrustdata.api.services.async.GroupServiceAsync -class GroupListPageAsync private constructor(private val groupsService: GroupServiceAsync, private val params: GroupListParams, private val response: Response, ) { +class GroupListPageAsync +private constructor( + private val groupsService: GroupServiceAsync, + private val params: GroupListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupListPageAsync && - this.groupsService == other.groupsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is GroupListPageAsync && + this.groupsService == other.groupsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - groupsService, - params, - response, - ) + return Objects.hash( + groupsService, + params, + response, + ) } - override fun toString() = "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = + "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - groupsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { groupsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +83,21 @@ class GroupListPageAsync private constructor(private val groupsService: GroupSer companion object { @JvmStatic - fun of(groupsService: GroupServiceAsync, params: GroupListParams, response: Response) = GroupListPageAsync( - groupsService, - params, - response, - ) + fun of(groupsService: GroupServiceAsync, params: GroupListParams, response: Response) = + GroupListPageAsync( + groupsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +112,33 @@ class GroupListPageAsync private constructor(private val groupsService: GroupSer fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "GroupListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "GroupListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +166,32 @@ class GroupListPageAsync private constructor(private val groupsService: GroupSer } } - class AutoPager constructor(private val firstPage: GroupListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: GroupListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Group) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Group) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index cc0362b..29db15d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -2,51 +2,35 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class GroupListParams constructor( - private val endingBefore: String?, - private val groupName: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class GroupListParams +constructor( + private val endingBefore: String?, + private val groupName: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -63,31 +47,18 @@ class GroupListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.groupName?.let { - params.put("group_name", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.groupName?.let { params.put("group_name", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -96,44 +67,44 @@ class GroupListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupListParams && - this.endingBefore == other.endingBefore && - this.groupName == other.groupName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupListParams && + this.endingBefore == other.endingBefore && + this.groupName == other.groupName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + groupName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -165,63 +136,47 @@ class GroupListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** Name of the group to search for */ - fun groupName(groupName: String) = apply { - this.groupName = groupName - } + fun groupName(groupName: String) = apply { this.groupName = groupName } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,9 +216,7 @@ class GroupListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -274,87 +227,93 @@ class GroupListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): GroupListParams = GroupListParams( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): GroupListParams = + GroupListParams( + endingBefore, + groupName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -364,34 +323,38 @@ class GroupListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 378be14..c7f5ad5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -2,50 +2,28 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class GroupReplaceParams constructor( - private val name: String, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class GroupReplaceParams +constructor( + private val name: String, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -60,64 +38,57 @@ class GroupReplaceParams constructor( @JvmSynthetic internal fun getBody(): GroupReplaceBody { - return GroupReplaceBody( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalBodyProperties, - ) + return GroupReplaceBody( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = GroupReplaceBody.Builder::class) @NoAutoDetect - class GroupReplaceBody internal constructor( - private val name: String?, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalProperties: Map, - + class GroupReplaceBody + internal constructor( + private val name: String?, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the group */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Textual description of the group */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - @JsonProperty("member_groups") - fun memberGroups(): List? = memberGroups + @JsonProperty("member_groups") fun memberGroups(): List? = memberGroups /** Ids of users which belong to this group */ - @JsonProperty("member_users") - fun memberUsers(): List? = memberUsers + @JsonProperty("member_users") fun memberUsers(): List? = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - @JsonProperty("org_name") - fun orgName(): String? = orgName + @JsonProperty("org_name") fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -126,39 +97,40 @@ class GroupReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupReplaceBody && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GroupReplaceBody && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -181,22 +153,17 @@ class GroupReplaceParams constructor( } /** Name of the group */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Textual description of the group */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ @JsonProperty("member_groups") fun memberGroups(memberGroups: List) = apply { @@ -205,19 +172,15 @@ class GroupReplaceParams constructor( /** Ids of users which belong to this group */ @JsonProperty("member_users") - fun memberUsers(memberUsers: List) = apply { - this.memberUsers = memberUsers - } + fun memberUsers(memberUsers: List) = apply { this.memberUsers = memberUsers } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -233,16 +196,15 @@ class GroupReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupReplaceBody = GroupReplaceBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - memberGroups?.toUnmodifiable(), - memberUsers?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): GroupReplaceBody = + GroupReplaceBody( + checkNotNull(name) { "`name` is required but was not set" }, + description, + memberGroups?.toUnmodifiable(), + memberUsers?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -253,42 +215,42 @@ class GroupReplaceParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupReplaceParams && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupReplaceParams && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -316,20 +278,16 @@ class GroupReplaceParams constructor( } /** Name of the group */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Textual description of the group */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ fun memberGroups(memberGroups: List) = apply { this.memberGroups.clear() @@ -339,12 +297,10 @@ class GroupReplaceParams constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - this.memberGroups.add(memberGroup) - } + fun addMemberGroup(memberGroup: String) = apply { this.memberGroups.add(memberGroup) } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List) = apply { @@ -353,18 +309,14 @@ class GroupReplaceParams constructor( } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - this.memberUsers.add(memberUser) - } + fun addMemberUser(memberUser: String) = apply { this.memberUsers.add(memberUser) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -404,9 +356,7 @@ class GroupReplaceParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -417,21 +367,21 @@ class GroupReplaceParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): GroupReplaceParams = GroupReplaceParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - if(memberGroups.size == 0) null else memberGroups.toUnmodifiable(), - if(memberUsers.size == 0) null else memberUsers.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): GroupReplaceParams = + GroupReplaceParams( + checkNotNull(name) { "`name` is required but was not set" }, + description, + if (memberGroups.size == 0) null else memberGroups.toUnmodifiable(), + if (memberUsers.size == 0) null else memberUsers.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index c7d2462..619c786 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class GroupRetrieveParams constructor( - private val groupId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class GroupRetrieveParams +constructor( + private val groupId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun groupId(): String = groupId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class GroupRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupRetrieveParams && - this.groupId == other.groupId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupRetrieveParams && + this.groupId == other.groupId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - groupId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + groupId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "GroupRetrieveParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "GroupRetrieveParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class GroupRetrieveParams constructor( } /** Group id */ - fun groupId(groupId: String) = apply { - this.groupId = groupId - } + fun groupId(groupId: String) = apply { this.groupId = groupId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class GroupRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class GroupRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): GroupRetrieveParams = GroupRetrieveParams( - checkNotNull(groupId) { - "`groupId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): GroupRetrieveParams = + GroupRetrieveParams( + checkNotNull(groupId) { "`groupId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 1e16c0b..ad6adec 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -2,52 +2,30 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class GroupUpdateParams constructor( - private val groupId: String, - private val addMemberGroups: List?, - private val addMemberUsers: List?, - private val description: String?, - private val name: String?, - private val removeMemberGroups: List?, - private val removeMemberUsers: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class GroupUpdateParams +constructor( + private val groupId: String, + private val addMemberGroups: List?, + private val addMemberUsers: List?, + private val description: String?, + private val name: String?, + private val removeMemberGroups: List?, + private val removeMemberUsers: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun groupId(): String = groupId @@ -66,60 +44,54 @@ class GroupUpdateParams constructor( @JvmSynthetic internal fun getBody(): GroupUpdateBody { - return GroupUpdateBody( - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalBodyProperties, - ) + return GroupUpdateBody( + addMemberGroups, + addMemberUsers, + description, + name, + removeMemberGroups, + removeMemberUsers, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } @JsonDeserialize(builder = GroupUpdateBody.Builder::class) @NoAutoDetect - class GroupUpdateBody internal constructor( - private val addMemberGroups: List?, - private val addMemberUsers: List?, - private val description: String?, - private val name: String?, - private val removeMemberGroups: List?, - private val removeMemberUsers: List?, - private val additionalProperties: Map, - + class GroupUpdateBody + internal constructor( + private val addMemberGroups: List?, + private val addMemberUsers: List?, + private val description: String?, + private val name: String?, + private val removeMemberGroups: List?, + private val removeMemberUsers: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of group IDs to add to the group's inheriting-from set */ - @JsonProperty("add_member_groups") - fun addMemberGroups(): List? = addMemberGroups + @JsonProperty("add_member_groups") fun addMemberGroups(): List? = addMemberGroups /** A list of user IDs to add to the group */ - @JsonProperty("add_member_users") - fun addMemberUsers(): List? = addMemberUsers + @JsonProperty("add_member_users") fun addMemberUsers(): List? = addMemberUsers /** Textual description of the group */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** Name of the group */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") @@ -136,41 +108,42 @@ class GroupUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupUpdateBody && - this.addMemberGroups == other.addMemberGroups && - this.addMemberUsers == other.addMemberUsers && - this.description == other.description && - this.name == other.name && - this.removeMemberGroups == other.removeMemberGroups && - this.removeMemberUsers == other.removeMemberUsers && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GroupUpdateBody && + this.addMemberGroups == other.addMemberGroups && + this.addMemberUsers == other.addMemberUsers && + this.description == other.description && + this.name == other.name && + this.removeMemberGroups == other.removeMemberGroups && + this.removeMemberUsers == other.removeMemberUsers && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + addMemberGroups, + addMemberUsers, + description, + name, + removeMemberGroups, + removeMemberUsers, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" + override fun toString() = + "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -208,15 +181,10 @@ class GroupUpdateParams constructor( /** Textual description of the group */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the group */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") @@ -244,15 +212,16 @@ class GroupUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupUpdateBody = GroupUpdateBody( - addMemberGroups?.toUnmodifiable(), - addMemberUsers?.toUnmodifiable(), - description, - name, - removeMemberGroups?.toUnmodifiable(), - removeMemberUsers?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): GroupUpdateBody = + GroupUpdateBody( + addMemberGroups?.toUnmodifiable(), + addMemberUsers?.toUnmodifiable(), + description, + name, + removeMemberGroups?.toUnmodifiable(), + removeMemberUsers?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -263,46 +232,46 @@ class GroupUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupUpdateParams && - this.groupId == other.groupId && - this.addMemberGroups == other.addMemberGroups && - this.addMemberUsers == other.addMemberUsers && - this.description == other.description && - this.name == other.name && - this.removeMemberGroups == other.removeMemberGroups && - this.removeMemberUsers == other.removeMemberUsers && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupUpdateParams && + this.groupId == other.groupId && + this.addMemberGroups == other.addMemberGroups && + this.addMemberUsers == other.addMemberUsers && + this.description == other.description && + this.name == other.name && + this.removeMemberGroups == other.removeMemberGroups && + this.removeMemberUsers == other.removeMemberUsers && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - groupId, - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + groupId, + addMemberGroups, + addMemberUsers, + description, + name, + removeMemberGroups, + removeMemberUsers, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -334,9 +303,7 @@ class GroupUpdateParams constructor( } /** Group id */ - fun groupId(groupId: String) = apply { - this.groupId = groupId - } + fun groupId(groupId: String) = apply { this.groupId = groupId } /** A list of group IDs to add to the group's inheriting-from set */ fun addMemberGroups(addMemberGroups: List) = apply { @@ -361,14 +328,10 @@ class GroupUpdateParams constructor( } /** Textual description of the group */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the group */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** A list of group IDs to remove from the group's inheriting-from set */ fun removeMemberGroups(removeMemberGroups: List) = apply { @@ -430,9 +393,7 @@ class GroupUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -443,23 +404,23 @@ class GroupUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): GroupUpdateParams = GroupUpdateParams( - checkNotNull(groupId) { - "`groupId` is required but was not set" - }, - if(addMemberGroups.size == 0) null else addMemberGroups.toUnmodifiable(), - if(addMemberUsers.size == 0) null else addMemberUsers.toUnmodifiable(), - description, - name, - if(removeMemberGroups.size == 0) null else removeMemberGroups.toUnmodifiable(), - if(removeMemberUsers.size == 0) null else removeMemberUsers.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): GroupUpdateParams = + GroupUpdateParams( + checkNotNull(groupId) { "`groupId` is required but was not set" }, + if (addMemberGroups.size == 0) null else addMemberGroups.toUnmodifiable(), + if (addMemberUsers.size == 0) null else addMemberUsers.toUnmodifiable(), + description, + name, + if (removeMemberGroups.size == 0) null else removeMemberGroups.toUnmodifiable(), + if (removeMemberUsers.size == 0) null else removeMemberUsers.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index a96859d..44c9b60 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -2,48 +2,32 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Organization.Builder::class) @NoAutoDetect -class Organization private constructor( - private val id: JsonField, - private val name: JsonField, - private val apiUrl: JsonField, - private val proxyUrl: JsonField, - private val realtimeUrl: JsonField, - private val created: JsonField, - private val additionalProperties: Map, - +class Organization +private constructor( + private val id: JsonField, + private val name: JsonField, + private val apiUrl: JsonField, + private val isUniversalApi: JsonField, + private val proxyUrl: JsonField, + private val realtimeUrl: JsonField, + private val created: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -58,39 +42,33 @@ class Organization private constructor( fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) + fun isUniversalApi(): Optional = + Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) - fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + fun realtimeUrl(): Optional = + Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) /** Date of organization creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Unique identifier for the organization */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Name of the organization */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("api_url") - @ExcludeMissing - fun _apiUrl() = apiUrl + @JsonProperty("api_url") @ExcludeMissing fun _apiUrl() = apiUrl - @JsonProperty("proxy_url") - @ExcludeMissing - fun _proxyUrl() = proxyUrl + @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi() = isUniversalApi - @JsonProperty("realtime_url") - @ExcludeMissing - fun _realtimeUrl() = realtimeUrl + @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl() = proxyUrl + + @JsonProperty("realtime_url") @ExcludeMissing fun _realtimeUrl() = realtimeUrl /** Date of organization creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created @JsonAnyGetter @ExcludeMissing @@ -98,54 +76,58 @@ class Organization private constructor( fun validate(): Organization = apply { if (!validated) { - id() - name() - apiUrl() - proxyUrl() - realtimeUrl() - created() - validated = true + id() + name() + apiUrl() + isUniversalApi() + proxyUrl() + realtimeUrl() + created() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Organization && - this.id == other.id && - this.name == other.name && - this.apiUrl == other.apiUrl && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.created == other.created && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Organization && + this.id == other.id && + this.name == other.name && + this.apiUrl == other.apiUrl && + this.isUniversalApi == other.isUniversalApi && + this.proxyUrl == other.proxyUrl && + this.realtimeUrl == other.realtimeUrl && + this.created == other.created && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - name, - apiUrl, - proxyUrl, - realtimeUrl, - created, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + name, + apiUrl, + isUniversalApi, + proxyUrl, + realtimeUrl, + created, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Organization{id=$id, name=$name, apiUrl=$apiUrl, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" + override fun toString() = + "Organization{id=$id, name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -153,6 +135,7 @@ class Organization private constructor( private var id: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var apiUrl: JsonField = JsonMissing.of() + private var isUniversalApi: JsonField = JsonMissing.of() private var proxyUrl: JsonField = JsonMissing.of() private var realtimeUrl: JsonField = JsonMissing.of() private var created: JsonField = JsonMissing.of() @@ -163,6 +146,7 @@ class Organization private constructor( this.id = organization.id this.name = organization.name this.apiUrl = organization.apiUrl + this.isUniversalApi = organization.isUniversalApi this.proxyUrl = organization.proxyUrl this.realtimeUrl = organization.realtimeUrl this.created = organization.created @@ -173,11 +157,7 @@ class Organization private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the organization */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Name of the organization */ fun name(name: String) = name(JsonField.of(name)) @@ -185,33 +165,33 @@ class Organization private constructor( /** Name of the organization */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun apiUrl(apiUrl: String) = apiUrl(JsonField.of(apiUrl)) @JsonProperty("api_url") @ExcludeMissing - fun apiUrl(apiUrl: JsonField) = apply { - this.apiUrl = apiUrl + fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + + fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(JsonField.of(isUniversalApi)) + + @JsonProperty("is_universal_api") + @ExcludeMissing + fun isUniversalApi(isUniversalApi: JsonField) = apply { + this.isUniversalApi = isUniversalApi } fun proxyUrl(proxyUrl: String) = proxyUrl(JsonField.of(proxyUrl)) @JsonProperty("proxy_url") @ExcludeMissing - fun proxyUrl(proxyUrl: JsonField) = apply { - this.proxyUrl = proxyUrl - } + fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } fun realtimeUrl(realtimeUrl: String) = realtimeUrl(JsonField.of(realtimeUrl)) @JsonProperty("realtime_url") @ExcludeMissing - fun realtimeUrl(realtimeUrl: JsonField) = apply { - this.realtimeUrl = realtimeUrl - } + fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } /** Date of organization creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -219,9 +199,7 @@ class Organization private constructor( /** Date of organization creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -237,14 +215,16 @@ class Organization private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Organization = Organization( - id, - name, - apiUrl, - proxyUrl, - realtimeUrl, - created, - additionalProperties.toUnmodifiable(), - ) + fun build(): Organization = + Organization( + id, + name, + apiUrl, + isUniversalApi, + proxyUrl, + realtimeUrl, + created, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index 56ef4d9..2a32949 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class OrganizationDeleteParams constructor( - private val organizationId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class OrganizationDeleteParams +constructor( + private val organizationId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun organizationId(): String = organizationId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class OrganizationDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationDeleteParams && - this.organizationId == other.organizationId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrganizationDeleteParams && + this.organizationId == other.organizationId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - organizationId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + organizationId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "OrganizationDeleteParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "OrganizationDeleteParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class OrganizationDeleteParams constructor( } /** Organization id */ - fun organizationId(organizationId: String) = apply { - this.organizationId = organizationId - } + fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class OrganizationDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class OrganizationDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): OrganizationDeleteParams = OrganizationDeleteParams( - checkNotNull(organizationId) { - "`organizationId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): OrganizationDeleteParams = + OrganizationDeleteParams( + checkNotNull(organizationId) { "`organizationId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index caf2407..ed6d9bd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -2,79 +2,83 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.OrganizationService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Organization -import com.braintrustdata.api.services.blocking.OrganizationService -class OrganizationListPage private constructor(private val organizationsService: OrganizationService, private val params: OrganizationListParams, private val response: Response, ) { +class OrganizationListPage +private constructor( + private val organizationsService: OrganizationService, + private val params: OrganizationListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationListPage && - this.organizationsService == other.organizationsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is OrganizationListPage && + this.organizationsService == other.organizationsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - organizationsService, - params, - response, - ) + return Objects.hash( + organizationsService, + params, + response, + ) } - override fun toString() = "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = + "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + OrganizationListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + OrganizationListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { organizationsService.list(it) } + return getNextPageParams().map { organizationsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +86,25 @@ class OrganizationListPage private constructor(private val organizationsService: companion object { @JvmStatic - fun of(organizationsService: OrganizationService, params: OrganizationListParams, response: Response) = OrganizationListPage( - organizationsService, - params, - response, - ) + fun of( + organizationsService: OrganizationService, + params: OrganizationListParams, + response: Response + ) = + OrganizationListPage( + organizationsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +119,33 @@ class OrganizationListPage private constructor(private val organizationsService: fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "OrganizationListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "OrganizationListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +173,25 @@ class OrganizationListPage private constructor(private val organizationsService: } } - class AutoPager constructor(private val firstPage: OrganizationListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: OrganizationListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index 25b1697..5dc1299 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -2,83 +2,86 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.OrganizationServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Organization -import com.braintrustdata.api.services.async.OrganizationServiceAsync -class OrganizationListPageAsync private constructor(private val organizationsService: OrganizationServiceAsync, private val params: OrganizationListParams, private val response: Response, ) { +class OrganizationListPageAsync +private constructor( + private val organizationsService: OrganizationServiceAsync, + private val params: OrganizationListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationListPageAsync && - this.organizationsService == other.organizationsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is OrganizationListPageAsync && + this.organizationsService == other.organizationsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - organizationsService, - params, - response, - ) + return Objects.hash( + organizationsService, + params, + response, + ) } - override fun toString() = "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = + "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + OrganizationListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + OrganizationListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - organizationsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { organizationsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +89,25 @@ class OrganizationListPageAsync private constructor(private val organizationsSer companion object { @JvmStatic - fun of(organizationsService: OrganizationServiceAsync, params: OrganizationListParams, response: Response) = OrganizationListPageAsync( - organizationsService, - params, - response, - ) + fun of( + organizationsService: OrganizationServiceAsync, + params: OrganizationListParams, + response: Response + ) = + OrganizationListPageAsync( + organizationsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +122,33 @@ class OrganizationListPageAsync private constructor(private val organizationsSer fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "OrganizationListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "OrganizationListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +176,32 @@ class OrganizationListPageAsync private constructor(private val organizationsSer } } - class AutoPager constructor(private val firstPage: OrganizationListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: OrganizationListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Organization) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Organization) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 8d0e2b8..0050b8e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -2,51 +2,35 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class OrganizationListParams constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val organizationName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class OrganizationListParams +constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val organizationName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -63,31 +47,18 @@ class OrganizationListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.organizationName?.let { - params.put("organization_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.organizationName?.let { params.put("organization_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -96,44 +67,44 @@ class OrganizationListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.organizationName == other.organizationName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrganizationListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.organizationName == other.organizationName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - organizationName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + organizationName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, organizationName=$organizationName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, organizationName=$organizationName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -165,47 +136,35 @@ class OrganizationListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the organization to search for */ fun organizationName(organizationName: String) = apply { @@ -215,13 +174,11 @@ class OrganizationListParams constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,9 +218,7 @@ class OrganizationListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -274,87 +229,93 @@ class OrganizationListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): OrganizationListParams = OrganizationListParams( - endingBefore, - ids, - limit, - orgName, - organizationName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): OrganizationListParams = + OrganizationListParams( + endingBefore, + ids, + limit, + orgName, + organizationName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -364,34 +325,38 @@ class OrganizationListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt new file mode 100644 index 0000000..0f9efbd --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -0,0 +1,591 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional + +class OrganizationMemberUpdateParams +constructor( + private val inviteUsers: InviteUsers?, + private val orgId: String?, + private val orgName: String?, + private val removeUsers: RemoveUsers?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun inviteUsers(): Optional = Optional.ofNullable(inviteUsers) + + fun orgId(): Optional = Optional.ofNullable(orgId) + + fun orgName(): Optional = Optional.ofNullable(orgName) + + fun removeUsers(): Optional = Optional.ofNullable(removeUsers) + + @JvmSynthetic + internal fun getBody(): OrganizationMemberUpdateBody { + return OrganizationMemberUpdateBody( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + @JsonDeserialize(builder = OrganizationMemberUpdateBody.Builder::class) + @NoAutoDetect + class OrganizationMemberUpdateBody + internal constructor( + private val inviteUsers: InviteUsers?, + private val orgId: String?, + private val orgName: String?, + private val removeUsers: RemoveUsers?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Users to invite to the organization */ + @JsonProperty("invite_users") fun inviteUsers(): InviteUsers? = inviteUsers + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. + */ + @JsonProperty("org_id") fun orgId(): String? = orgId + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. + */ + @JsonProperty("org_name") fun orgName(): String? = orgName + + /** Users to remove from the organization */ + @JsonProperty("remove_users") fun removeUsers(): RemoveUsers? = removeUsers + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationMemberUpdateBody && + this.inviteUsers == other.inviteUsers && + this.orgId == other.orgId && + this.orgName == other.orgName && + this.removeUsers == other.removeUsers && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var inviteUsers: InviteUsers? = null + private var orgId: String? = null + private var orgName: String? = null + private var removeUsers: RemoveUsers? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationMemberUpdateBody: OrganizationMemberUpdateBody) = apply { + this.inviteUsers = organizationMemberUpdateBody.inviteUsers + this.orgId = organizationMemberUpdateBody.orgId + this.orgName = organizationMemberUpdateBody.orgName + this.removeUsers = organizationMemberUpdateBody.removeUsers + additionalProperties(organizationMemberUpdateBody.additionalProperties) + } + + /** Users to invite to the organization */ + @JsonProperty("invite_users") + fun inviteUsers(inviteUsers: InviteUsers) = apply { this.inviteUsers = inviteUsers } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the id of the + * organization. + */ + @JsonProperty("org_id") fun orgId(orgId: String) = apply { this.orgId = orgId } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the name of the + * organization. + */ + @JsonProperty("org_name") + fun orgName(orgName: String) = apply { this.orgName = orgName } + + /** Users to remove from the organization */ + @JsonProperty("remove_users") + fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): OrganizationMemberUpdateBody = + OrganizationMemberUpdateBody( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationMemberUpdateParams && + this.inviteUsers == other.inviteUsers && + this.orgId == other.orgId && + this.orgName == other.orgName && + this.removeUsers == other.removeUsers && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var inviteUsers: InviteUsers? = null + private var orgId: String? = null + private var orgName: String? = null + private var removeUsers: RemoveUsers? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = apply { + this.inviteUsers = organizationMemberUpdateParams.inviteUsers + this.orgId = organizationMemberUpdateParams.orgId + this.orgName = organizationMemberUpdateParams.orgName + this.removeUsers = organizationMemberUpdateParams.removeUsers + additionalQueryParams(organizationMemberUpdateParams.additionalQueryParams) + additionalHeaders(organizationMemberUpdateParams.additionalHeaders) + additionalBodyProperties(organizationMemberUpdateParams.additionalBodyProperties) + } + + /** Users to invite to the organization */ + fun inviteUsers(inviteUsers: InviteUsers) = apply { this.inviteUsers = inviteUsers } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. + */ + fun orgId(orgId: String) = apply { this.orgId = orgId } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. + */ + fun orgName(orgName: String) = apply { this.orgName = orgName } + + /** Users to remove from the organization */ + fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): OrganizationMemberUpdateParams = + OrganizationMemberUpdateParams( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + /** Users to invite to the organization */ + @JsonDeserialize(builder = InviteUsers.Builder::class) + @NoAutoDetect + class InviteUsers + private constructor( + private val ids: List?, + private val emails: List?, + private val sendInviteEmails: Boolean?, + private val groupId: String?, + private val groupName: String?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Ids of existing users to invite */ + @JsonProperty("ids") fun ids(): List? = ids + + /** Emails of users to invite */ + @JsonProperty("emails") fun emails(): List? = emails + + /** If true, send invite emails to the users who wore actually added */ + @JsonProperty("send_invite_emails") fun sendInviteEmails(): Boolean? = sendInviteEmails + + /** + * Optional id of a group to add newly-invited users to. Cannot specify both a group id and + * a group name. + */ + @JsonProperty("group_id") fun groupId(): String? = groupId + + /** + * Optional name of a group to add newly-invited users to. Cannot specify both a group id + * and a group name. + */ + @JsonProperty("group_name") fun groupName(): String? = groupName + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InviteUsers && + this.ids == other.ids && + this.emails == other.emails && + this.sendInviteEmails == other.sendInviteEmails && + this.groupId == other.groupId && + this.groupName == other.groupName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + ids, + emails, + sendInviteEmails, + groupId, + groupName, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var ids: List? = null + private var emails: List? = null + private var sendInviteEmails: Boolean? = null + private var groupId: String? = null + private var groupName: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inviteUsers: InviteUsers) = apply { + this.ids = inviteUsers.ids + this.emails = inviteUsers.emails + this.sendInviteEmails = inviteUsers.sendInviteEmails + this.groupId = inviteUsers.groupId + this.groupName = inviteUsers.groupName + additionalProperties(inviteUsers.additionalProperties) + } + + /** Ids of existing users to invite */ + @JsonProperty("ids") fun ids(ids: List) = apply { this.ids = ids } + + /** Emails of users to invite */ + @JsonProperty("emails") + fun emails(emails: List) = apply { this.emails = emails } + + /** If true, send invite emails to the users who wore actually added */ + @JsonProperty("send_invite_emails") + fun sendInviteEmails(sendInviteEmails: Boolean) = apply { + this.sendInviteEmails = sendInviteEmails + } + + /** + * Optional id of a group to add newly-invited users to. Cannot specify both a group id + * and a group name. + */ + @JsonProperty("group_id") + fun groupId(groupId: String) = apply { this.groupId = groupId } + + /** + * Optional name of a group to add newly-invited users to. Cannot specify both a group + * id and a group name. + */ + @JsonProperty("group_name") + fun groupName(groupName: String) = apply { this.groupName = groupName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InviteUsers = + InviteUsers( + ids?.toUnmodifiable(), + emails?.toUnmodifiable(), + sendInviteEmails, + groupId, + groupName, + additionalProperties.toUnmodifiable(), + ) + } + } + + /** Users to remove from the organization */ + @JsonDeserialize(builder = RemoveUsers.Builder::class) + @NoAutoDetect + class RemoveUsers + private constructor( + private val ids: List?, + private val emails: List?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Ids of users to remove */ + @JsonProperty("ids") fun ids(): List? = ids + + /** Emails of users to remove */ + @JsonProperty("emails") fun emails(): List? = emails + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveUsers && + this.ids == other.ids && + this.emails == other.emails && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + ids, + emails, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var ids: List? = null + private var emails: List? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeUsers: RemoveUsers) = apply { + this.ids = removeUsers.ids + this.emails = removeUsers.emails + additionalProperties(removeUsers.additionalProperties) + } + + /** Ids of users to remove */ + @JsonProperty("ids") fun ids(ids: List) = apply { this.ids = ids } + + /** Emails of users to remove */ + @JsonProperty("emails") + fun emails(emails: List) = apply { this.emails = emails } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RemoveUsers = + RemoveUsers( + ids?.toUnmodifiable(), + emails?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt new file mode 100644 index 0000000..524fee4 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +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.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = OrganizationMemberUpdateResponse.Builder::class) +@NoAutoDetect +class OrganizationMemberUpdateResponse +private constructor( + private val status: JsonField, + private val sendEmailError: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun status(): Status = status.getRequired("status") + + /** + * If invite emails failed to send for some reason, the patch operation will still complete, but + * we will return an error message here + */ + fun sendEmailError(): Optional = + Optional.ofNullable(sendEmailError.getNullable("send_email_error")) + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + /** + * If invite emails failed to send for some reason, the patch operation will still complete, but + * we will return an error message here + */ + @JsonProperty("send_email_error") @ExcludeMissing fun _sendEmailError() = sendEmailError + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): OrganizationMemberUpdateResponse = apply { + if (!validated) { + status() + sendEmailError() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationMemberUpdateResponse && + this.status == other.status && + this.sendEmailError == other.sendEmailError && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + status, + sendEmailError, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "OrganizationMemberUpdateResponse{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var status: JsonField = JsonMissing.of() + private var sendEmailError: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationMemberUpdateResponse: OrganizationMemberUpdateResponse) = + apply { + this.status = organizationMemberUpdateResponse.status + this.sendEmailError = organizationMemberUpdateResponse.sendEmailError + additionalProperties(organizationMemberUpdateResponse.additionalProperties) + } + + fun status(status: Status) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + /** + * If invite emails failed to send for some reason, the patch operation will still complete, + * but we will return an error message here + */ + fun sendEmailError(sendEmailError: String) = sendEmailError(JsonField.of(sendEmailError)) + + /** + * If invite emails failed to send for some reason, the patch operation will still complete, + * but we will return an error message here + */ + @JsonProperty("send_email_error") + @ExcludeMissing + fun sendEmailError(sendEmailError: JsonField) = apply { + this.sendEmailError = sendEmailError + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): OrganizationMemberUpdateResponse = + OrganizationMemberUpdateResponse( + status, + sendEmailError, + additionalProperties.toUnmodifiable(), + ) + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SUCCESS = Status(JsonField.of("success")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + SUCCESS, + } + + enum class Value { + SUCCESS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + else -> throw BraintrustInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 0be47be..651b870 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class OrganizationRetrieveParams constructor( - private val organizationId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class OrganizationRetrieveParams +constructor( + private val organizationId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun organizationId(): String = organizationId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class OrganizationRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationRetrieveParams && - this.organizationId == other.organizationId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrganizationRetrieveParams && + this.organizationId == other.organizationId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - organizationId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + organizationId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "OrganizationRetrieveParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "OrganizationRetrieveParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class OrganizationRetrieveParams constructor( } /** Organization id */ - fun organizationId(organizationId: String) = apply { - this.organizationId = organizationId - } + fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class OrganizationRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class OrganizationRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( - checkNotNull(organizationId) { - "`organizationId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): OrganizationRetrieveParams = + OrganizationRetrieveParams( + checkNotNull(organizationId) { "`organizationId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 64a7308..a513fc5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -2,56 +2,37 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class OrganizationUpdateParams constructor( - private val organizationId: String, - private val apiUrl: String?, - private val name: String?, - private val proxyUrl: String?, - private val realtimeUrl: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class OrganizationUpdateParams +constructor( + private val organizationId: String, + private val apiUrl: String?, + private val isUniversalApi: Boolean?, + private val name: String?, + private val proxyUrl: String?, + private val realtimeUrl: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun organizationId(): String = organizationId fun apiUrl(): Optional = Optional.ofNullable(apiUrl) + fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi) + fun name(): Optional = Optional.ofNullable(name) fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl) @@ -60,53 +41,51 @@ class OrganizationUpdateParams constructor( @JvmSynthetic internal fun getBody(): OrganizationUpdateBody { - return OrganizationUpdateBody( - apiUrl, - name, - proxyUrl, - realtimeUrl, - additionalBodyProperties, - ) + return OrganizationUpdateBody( + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } @JsonDeserialize(builder = OrganizationUpdateBody.Builder::class) @NoAutoDetect - class OrganizationUpdateBody internal constructor( - private val apiUrl: String?, - private val name: String?, - private val proxyUrl: String?, - private val realtimeUrl: String?, - private val additionalProperties: Map, - + class OrganizationUpdateBody + internal constructor( + private val apiUrl: String?, + private val isUniversalApi: Boolean?, + private val name: String?, + private val proxyUrl: String?, + private val realtimeUrl: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("api_url") - fun apiUrl(): String? = apiUrl + @JsonProperty("api_url") fun apiUrl(): String? = apiUrl + + @JsonProperty("is_universal_api") fun isUniversalApi(): Boolean? = isUniversalApi /** Name of the organization */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name - @JsonProperty("proxy_url") - fun proxyUrl(): String? = proxyUrl + @JsonProperty("proxy_url") fun proxyUrl(): String? = proxyUrl - @JsonProperty("realtime_url") - fun realtimeUrl(): String? = realtimeUrl + @JsonProperty("realtime_url") fun realtimeUrl(): String? = realtimeUrl @JsonAnyGetter @ExcludeMissing @@ -115,42 +94,46 @@ class OrganizationUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationUpdateBody && - this.apiUrl == other.apiUrl && - this.name == other.name && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrganizationUpdateBody && + this.apiUrl == other.apiUrl && + this.isUniversalApi == other.isUniversalApi && + this.name == other.name && + this.proxyUrl == other.proxyUrl && + this.realtimeUrl == other.realtimeUrl && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - apiUrl, - name, - proxyUrl, - realtimeUrl, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "OrganizationUpdateBody{apiUrl=$apiUrl, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = + "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var apiUrl: String? = null + private var isUniversalApi: Boolean? = null private var name: String? = null private var proxyUrl: String? = null private var realtimeUrl: String? = null @@ -159,32 +142,28 @@ class OrganizationUpdateParams constructor( @JvmSynthetic internal fun from(organizationUpdateBody: OrganizationUpdateBody) = apply { this.apiUrl = organizationUpdateBody.apiUrl + this.isUniversalApi = organizationUpdateBody.isUniversalApi this.name = organizationUpdateBody.name this.proxyUrl = organizationUpdateBody.proxyUrl this.realtimeUrl = organizationUpdateBody.realtimeUrl additionalProperties(organizationUpdateBody.additionalProperties) } - @JsonProperty("api_url") - fun apiUrl(apiUrl: String) = apply { - this.apiUrl = apiUrl + @JsonProperty("api_url") fun apiUrl(apiUrl: String) = apply { this.apiUrl = apiUrl } + + @JsonProperty("is_universal_api") + fun isUniversalApi(isUniversalApi: Boolean) = apply { + this.isUniversalApi = isUniversalApi } /** Name of the organization */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } @JsonProperty("proxy_url") - fun proxyUrl(proxyUrl: String) = apply { - this.proxyUrl = proxyUrl - } + fun proxyUrl(proxyUrl: String) = apply { this.proxyUrl = proxyUrl } @JsonProperty("realtime_url") - fun realtimeUrl(realtimeUrl: String) = apply { - this.realtimeUrl = realtimeUrl - } + fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -200,13 +179,15 @@ class OrganizationUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrganizationUpdateBody = OrganizationUpdateBody( - apiUrl, - name, - proxyUrl, - realtimeUrl, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrganizationUpdateBody = + OrganizationUpdateBody( + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalProperties.toUnmodifiable(), + ) } } @@ -217,42 +198,44 @@ class OrganizationUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationUpdateParams && - this.organizationId == other.organizationId && - this.apiUrl == other.apiUrl && - this.name == other.name && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrganizationUpdateParams && + this.organizationId == other.organizationId && + this.apiUrl == other.apiUrl && + this.isUniversalApi == other.isUniversalApi && + this.name == other.name && + this.proxyUrl == other.proxyUrl && + this.realtimeUrl == other.realtimeUrl && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - organizationId, - apiUrl, - name, - proxyUrl, - realtimeUrl, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + organizationId, + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -260,6 +243,7 @@ class OrganizationUpdateParams constructor( private var organizationId: String? = null private var apiUrl: String? = null + private var isUniversalApi: Boolean? = null private var name: String? = null private var proxyUrl: String? = null private var realtimeUrl: String? = null @@ -271,6 +255,7 @@ class OrganizationUpdateParams constructor( internal fun from(organizationUpdateParams: OrganizationUpdateParams) = apply { this.organizationId = organizationUpdateParams.organizationId this.apiUrl = organizationUpdateParams.apiUrl + this.isUniversalApi = organizationUpdateParams.isUniversalApi this.name = organizationUpdateParams.name this.proxyUrl = organizationUpdateParams.proxyUrl this.realtimeUrl = organizationUpdateParams.realtimeUrl @@ -280,26 +265,18 @@ class OrganizationUpdateParams constructor( } /** Organization id */ - fun organizationId(organizationId: String) = apply { - this.organizationId = organizationId - } + fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } - fun apiUrl(apiUrl: String) = apply { - this.apiUrl = apiUrl - } + fun apiUrl(apiUrl: String) = apply { this.apiUrl = apiUrl } + + fun isUniversalApi(isUniversalApi: Boolean) = apply { this.isUniversalApi = isUniversalApi } /** Name of the organization */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } - fun proxyUrl(proxyUrl: String) = apply { - this.proxyUrl = proxyUrl - } + fun proxyUrl(proxyUrl: String) = apply { this.proxyUrl = proxyUrl } - fun realtimeUrl(realtimeUrl: String) = apply { - this.realtimeUrl = realtimeUrl - } + fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -339,9 +316,7 @@ class OrganizationUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -352,21 +327,22 @@ class OrganizationUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): OrganizationUpdateParams = OrganizationUpdateParams( - checkNotNull(organizationId) { - "`organizationId` is required but was not set" - }, - apiUrl, - name, - proxyUrl, - realtimeUrl, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): OrganizationUpdateParams = + OrganizationUpdateParams( + checkNotNull(organizationId) { "`organizationId` is required but was not set" }, + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index e8d1a9b..cb54d37 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -2,49 +2,32 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Project.Builder::class) @NoAutoDetect -class Project private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val created: JsonField, - private val deletedAt: JsonField, - private val userId: JsonField, - private val settings: JsonField, - private val additionalProperties: Map, - +class Project +private constructor( + private val id: JsonField, + private val orgId: JsonField, + private val name: JsonField, + private val created: JsonField, + private val deletedAt: JsonField, + private val userId: JsonField, + private val settings: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -64,7 +47,8 @@ class Project private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Identifies the user who created the project */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) @@ -72,38 +56,24 @@ class Project private constructor( fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) /** Unique identifier for the project */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** Name of the project */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Date of project creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Date of project deletion, or null if the project is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt /** Identifies the user who created the project */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId - @JsonProperty("settings") - @ExcludeMissing - fun _settings() = settings + @JsonProperty("settings") @ExcludeMissing fun _settings() = settings @JsonAnyGetter @ExcludeMissing @@ -111,57 +81,58 @@ class Project private constructor( fun validate(): Project = apply { if (!validated) { - id() - orgId() - name() - created() - deletedAt() - userId() - settings().map { it.validate() } - validated = true + id() + orgId() + name() + created() + deletedAt() + userId() + settings().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Project && - this.id == other.id && - this.orgId == other.orgId && - this.name == other.name && - this.created == other.created && - this.deletedAt == other.deletedAt && - this.userId == other.userId && - this.settings == other.settings && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Project && + this.id == other.id && + this.orgId == other.orgId && + this.name == other.name && + this.created == other.created && + this.deletedAt == other.deletedAt && + this.userId == other.userId && + this.settings == other.settings && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - orgId, - name, - created, - deletedAt, - userId, - settings, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + orgId, + name, + created, + deletedAt, + userId, + settings, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" + override fun toString() = + "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -191,11 +162,7 @@ class Project private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -203,9 +170,7 @@ class Project private constructor( /** Unique id for the organization that the project belongs under */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) @@ -213,9 +178,7 @@ class Project private constructor( /** Name of the project */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Date of project creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -223,9 +186,7 @@ class Project private constructor( /** Date of project creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of project deletion, or null if the project is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -233,9 +194,7 @@ class Project private constructor( /** Date of project deletion, or null if the project is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Identifies the user who created the project */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -243,17 +202,13 @@ class Project private constructor( /** Identifies the user who created the project */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } fun settings(settings: Settings) = settings(JsonField.of(settings)) @JsonProperty("settings") @ExcludeMissing - fun settings(settings: JsonField) = apply { - this.settings = settings - } + fun settings(settings: JsonField) = apply { this.settings = settings } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -269,33 +224,37 @@ class Project private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Project = Project( - id, - orgId, - name, - created, - deletedAt, - userId, - settings, - additionalProperties.toUnmodifiable(), - ) + fun build(): Project = + Project( + id, + orgId, + name, + created, + deletedAt, + userId, + settings, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Settings.Builder::class) @NoAutoDetect - class Settings private constructor(private val comparisonKey: JsonField, private val additionalProperties: Map, ) { + class Settings + private constructor( + private val comparisonKey: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) + fun comparisonKey(): Optional = + Optional.ofNullable(comparisonKey.getNullable("comparison_key")) /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") - @ExcludeMissing - fun _comparisonKey() = comparisonKey + @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey() = comparisonKey @JsonAnyGetter @ExcludeMissing @@ -303,36 +262,36 @@ class Project private constructor( fun validate(): Settings = apply { if (!validated) { - comparisonKey() - validated = true + comparisonKey() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Settings && - this.comparisonKey == other.comparisonKey && - this.additionalProperties == other.additionalProperties + return other is Settings && + this.comparisonKey == other.comparisonKey && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(comparisonKey, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(comparisonKey, additionalProperties) + } + return hashCode } - override fun toString() = "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + override fun toString() = + "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 2d1cbf2..6a03770 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -2,47 +2,25 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectCreateParams constructor( - private val name: String, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectCreateParams +constructor( + private val name: String, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -51,36 +29,37 @@ class ProjectCreateParams constructor( @JvmSynthetic internal fun getBody(): ProjectCreateBody { - return ProjectCreateBody( - name, - orgName, - additionalBodyProperties, - ) + return ProjectCreateBody( + name, + orgName, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ProjectCreateBody.Builder::class) @NoAutoDetect - class ProjectCreateBody internal constructor(private val name: String?, private val orgName: String?, private val additionalProperties: Map, ) { + class ProjectCreateBody + internal constructor( + private val name: String?, + private val orgName: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the project */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ - @JsonProperty("org_name") - fun orgName(): String? = orgName + @JsonProperty("org_name") fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -89,33 +68,34 @@ class ProjectCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectCreateBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectCreateBody && + this.name == other.name && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -132,20 +112,15 @@ class ProjectCreateParams constructor( } /** Name of the project */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -161,13 +136,12 @@ class ProjectCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectCreateBody = ProjectCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectCreateBody = + ProjectCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -178,36 +152,36 @@ class ProjectCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectCreateParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectCreateParams && + this.name == other.name && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -229,18 +203,14 @@ class ProjectCreateParams constructor( } /** Name of the project */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -280,9 +250,7 @@ class ProjectCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -293,18 +261,18 @@ class ProjectCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectCreateParams = ProjectCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectCreateParams = + ProjectCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 65f382e..830d84e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ProjectDeleteParams constructor( - private val projectId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectDeleteParams +constructor( + private val projectId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class ProjectDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectDeleteParams && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectDeleteParams && + this.projectId == other.projectId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectDeleteParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectDeleteParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class ProjectDeleteParams constructor( } /** Project id */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class ProjectDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class ProjectDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectDeleteParams = ProjectDeleteParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectDeleteParams = + ProjectDeleteParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index 4dd21e0..11d4f3b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -2,79 +2,83 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.ProjectService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Project -import com.braintrustdata.api.services.blocking.ProjectService -class ProjectListPage private constructor(private val projectsService: ProjectService, private val params: ProjectListParams, private val response: Response, ) { +class ProjectListPage +private constructor( + private val projectsService: ProjectService, + private val params: ProjectListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectListPage && - this.projectsService == other.projectsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectListPage && + this.projectsService == other.projectsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectsService, - params, - response, - ) + return Objects.hash( + projectsService, + params, + response, + ) } - override fun toString() = "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = + "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectsService.list(it) } + return getNextPageParams().map { projectsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +86,21 @@ class ProjectListPage private constructor(private val projectsService: ProjectSe companion object { @JvmStatic - fun of(projectsService: ProjectService, params: ProjectListParams, response: Response) = ProjectListPage( - projectsService, - params, - response, - ) + fun of(projectsService: ProjectService, params: ProjectListParams, response: Response) = + ProjectListPage( + projectsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +115,33 @@ class ProjectListPage private constructor(private val projectsService: ProjectSe fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ProjectListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +169,25 @@ class ProjectListPage private constructor(private val projectsService: ProjectSe } } - class AutoPager constructor(private val firstPage: ProjectListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: ProjectListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 6e3419c..15bb897 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -2,83 +2,86 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.ProjectServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Project -import com.braintrustdata.api.services.async.ProjectServiceAsync -class ProjectListPageAsync private constructor(private val projectsService: ProjectServiceAsync, private val params: ProjectListParams, private val response: Response, ) { +class ProjectListPageAsync +private constructor( + private val projectsService: ProjectServiceAsync, + private val params: ProjectListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectListPageAsync && - this.projectsService == other.projectsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectListPageAsync && + this.projectsService == other.projectsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectsService, - params, - response, - ) + return Objects.hash( + projectsService, + params, + response, + ) } - override fun toString() = "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = + "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - projectsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { projectsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +89,25 @@ class ProjectListPageAsync private constructor(private val projectsService: Proj companion object { @JvmStatic - fun of(projectsService: ProjectServiceAsync, params: ProjectListParams, response: Response) = ProjectListPageAsync( - projectsService, - params, - response, - ) + fun of( + projectsService: ProjectServiceAsync, + params: ProjectListParams, + response: Response + ) = + ProjectListPageAsync( + projectsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +122,33 @@ class ProjectListPageAsync private constructor(private val projectsService: Proj fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ProjectListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +176,32 @@ class ProjectListPageAsync private constructor(private val projectsService: Proj } } - class AutoPager constructor(private val firstPage: ProjectListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: ProjectListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Project) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Project) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 4ecfc3e..24ded19 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -2,51 +2,35 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectListParams constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectListParams +constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -63,31 +47,18 @@ class ProjectListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -96,44 +67,44 @@ class ProjectListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -165,63 +136,47 @@ class ProjectListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,9 +216,7 @@ class ProjectListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -274,87 +227,93 @@ class ProjectListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectListParams = ProjectListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectListParams = + ProjectListParams( + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -364,34 +323,38 @@ class ProjectListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index f897414..3ac09d2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -2,47 +2,28 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* +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.databind.annotation.JsonDeserialize +import java.util.Objects -class ProjectLogFeedbackParams constructor( - private val projectId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectLogFeedbackParams +constructor( + private val projectId: String, + private val feedback: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -51,31 +32,32 @@ class ProjectLogFeedbackParams constructor( @JvmSynthetic internal fun getBody(): ProjectLogFeedbackBody { - return ProjectLogFeedbackBody(feedback, additionalBodyProperties) + return ProjectLogFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectLogFeedbackBody.Builder::class) @NoAutoDetect - class ProjectLogFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { + class ProjectLogFeedbackBody + internal constructor( + private val feedback: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** A list of project logs feedback items */ - @JsonProperty("feedback") - fun feedback(): List? = feedback + @JsonProperty("feedback") fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -84,28 +66,28 @@ class ProjectLogFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectLogFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties + return other is ProjectLogFeedbackBody && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode } - override fun toString() = "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -121,9 +103,7 @@ class ProjectLogFeedbackParams constructor( /** A list of project logs feedback items */ @JsonProperty("feedback") - fun feedback(feedback: List) = apply { - this.feedback = feedback - } + fun feedback(feedback: List) = apply { this.feedback = feedback } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -139,9 +119,12 @@ class ProjectLogFeedbackParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogFeedbackBody = ProjectLogFeedbackBody(checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) + fun build(): ProjectLogFeedbackBody = + ProjectLogFeedbackBody( + checkNotNull(feedback) { "`feedback` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) } } @@ -152,36 +135,36 @@ class ProjectLogFeedbackParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFeedbackParams && - this.projectId == other.projectId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectLogFeedbackParams && + this.projectId == other.projectId && + this.feedback == other.feedback && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + feedback, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -203,9 +186,7 @@ class ProjectLogFeedbackParams constructor( } /** Project id */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs feedback items */ fun feedback(feedback: List) = apply { @@ -214,9 +195,7 @@ class ProjectLogFeedbackParams constructor( } /** A list of project logs feedback items */ - fun addFeedback(feedback: Feedback) = apply { - this.feedback.add(feedback) - } + fun addFeedback(feedback: Feedback) = apply { this.feedback.add(feedback) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,9 +235,7 @@ class ProjectLogFeedbackParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -269,73 +246,66 @@ class ProjectLogFeedbackParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFeedbackParams = + ProjectLogFeedbackParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(feedback) { "`feedback` is required but was not set" } + .toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Feedback.Builder::class) @NoAutoDetect - class Feedback private constructor( - private val id: String?, - private val scores: Scores?, - private val expected: JsonValue?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - + class Feedback + private constructor( + private val id: String?, + private val scores: Scores?, + private val expected: JsonValue?, + private val comment: String?, + private val metadata: Metadata?, + private val source: Source?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** - * The id of the project logs event to log feedback for. This is the row `id` - * returned by `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` returned by + * `POST /v1/project_logs/{project_id}/insert` */ - @JsonProperty("id") - fun id(): String? = id + @JsonProperty("id") fun id(): String? = id /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event */ - @JsonProperty("scores") - fun scores(): Scores? = scores + @JsonProperty("scores") fun scores(): Scores? = scores /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") - fun expected(): JsonValue? = expected + @JsonProperty("expected") fun expected(): JsonValue? = expected /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") - fun comment(): String? = comment + @JsonProperty("comment") fun comment(): String? = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata + @JsonProperty("metadata") fun metadata(): Metadata? = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(): Source? = source + @JsonProperty("source") fun source(): Source? = source @JsonAnyGetter @ExcludeMissing @@ -344,41 +314,42 @@ class ProjectLogFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Feedback && + this.id == other.id && + this.scores == other.scores && + this.expected == other.expected && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Feedback{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + override fun toString() = + "Feedback{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -403,52 +374,36 @@ class ProjectLogFeedbackParams constructor( } /** - * The id of the project logs event to log feedback for. This is the row `id` - * returned by `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` returned + * by `POST /v1/project_logs/{project_id}/insert` */ - @JsonProperty("id") - fun id(id: String) = apply { - this.id = id - } + @JsonProperty("id") fun id(id: String) = apply { this.id = id } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged + * into the existing scores for the project logs event */ - @JsonProperty("scores") - fun scores(scores: Scores) = apply { - this.scores = scores - } + @JsonProperty("scores") fun scores(scores: Scores) = apply { this.scores = scores } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ @JsonProperty("expected") - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") - fun comment(comment: String) = apply { - this.comment = comment - } + @JsonProperty("comment") fun comment(comment: String) = apply { this.comment = comment } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you + * can log it here and access it in the Braintrust UI. */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(source: Source) = apply { - this.source = source - } + @JsonProperty("source") fun source(source: Source) = apply { this.source = source } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -464,26 +419,28 @@ class ProjectLogFeedbackParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Feedback = Feedback( - checkNotNull(id) { - "`id` is required but was not set" - }, - scores, - expected, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) + fun build(): Feedback = + Feedback( + checkNotNull(id) { "`id` is required but was not set" }, + scores, + expected, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -494,27 +451,25 @@ class ProjectLogFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -536,21 +491,25 @@ class ProjectLogFeedbackParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -561,27 +520,25 @@ class ProjectLogFeedbackParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -603,26 +560,29 @@ class ProjectLogFeedbackParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } } - class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Source + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Source && - this.value == other.value + return other is Source && this.value == other.value } override fun hashCode() = value.hashCode() @@ -653,19 +613,21 @@ class ProjectLogFeedbackParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } + fun known(): Known = + when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 97ea602..0503588 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -2,50 +2,23 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ProjectLogFetchParams constructor( - private val projectId: String, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectLogFetchParams +constructor( + private val projectId: String, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -60,31 +33,22 @@ class ProjectLogFetchParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.maxRootSpanId?.let { - params.put("max_root_span_id", listOf(it.toString())) - } - this.maxXactId?.let { - params.put("max_xact_id", listOf(it.toString())) - } - this.version?.let { - params.put("version", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } + this.version?.let { params.put("version", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -94,42 +58,42 @@ class ProjectLogFetchParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchParams && - this.projectId == other.projectId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectLogFetchParams && + this.projectId == other.projectId && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -157,72 +121,60 @@ class ProjectLogFetchParams constructor( } /** Project id */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -262,9 +214,7 @@ class ProjectLogFetchParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -275,21 +225,21 @@ class ProjectLogFetchParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectLogFetchParams = ProjectLogFetchParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectLogFetchParams = + ProjectLogFetchParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 210892b..541c014 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -2,52 +2,34 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectLogFetchPostParams constructor( - private val projectId: String, - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectLogFetchPostParams +constructor( + private val projectId: String, + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -66,120 +48,110 @@ class ProjectLogFetchPostParams constructor( @JvmSynthetic internal fun getBody(): ProjectLogFetchPostBody { - return ProjectLogFetchPostBody( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) + return ProjectLogFetchPostBody( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectLogFetchPostBody.Builder::class) @NoAutoDetect - class ProjectLogFetchPostBody internal constructor( - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, - + class ProjectLogFetchPostBody + internal constructor( + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - fun cursor(): String? = cursor + @JsonProperty("cursor") fun cursor(): String? = cursor /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ - @JsonProperty("filters") - fun filters(): List? = filters + @JsonProperty("filters") fun filters(): List? = filters /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - @JsonProperty("limit") - fun limit(): Long? = limit + @JsonProperty("limit") fun limit(): Long? = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_root_span_id") - fun maxRootSpanId(): String? = maxRootSpanId + @JsonProperty("max_root_span_id") fun maxRootSpanId(): String? = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_xact_id") - fun maxXactId(): String? = maxXactId + @JsonProperty("max_xact_id") fun maxXactId(): String? = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") - fun version(): String? = version + @JsonProperty("version") fun version(): String? = version @JsonAnyGetter @ExcludeMissing @@ -188,41 +160,42 @@ class ProjectLogFetchPostParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectLogFetchPostBody && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -247,92 +220,76 @@ class ProjectLogFetchPostParams constructor( } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - fun cursor(cursor: String) = apply { - this.cursor = cursor - } + @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters + * are supported, but we may add more in the future */ @JsonProperty("filters") - fun filters(filters: List) = apply { - this.filters = filters - } + fun filters(filters: List) = apply { this.filters = filters } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ - @JsonProperty("limit") - fun limit(limit: Long) = apply { - this.limit = limit - } + @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ - @JsonProperty("version") - fun version(version: String) = apply { - this.version = version - } + @JsonProperty("version") fun version(version: String) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -348,15 +305,16 @@ class ProjectLogFetchPostParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogFetchPostBody = ProjectLogFetchPostBody( - cursor, - filters?.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFetchPostBody = + ProjectLogFetchPostBody( + cursor, + filters?.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toUnmodifiable(), + ) } } @@ -367,46 +325,46 @@ class ProjectLogFetchPostParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchPostParams && - this.projectId == other.projectId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectLogFetchPostParams && + this.projectId == other.projectId && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -438,24 +396,20 @@ class ProjectLogFetchPostParams constructor( } /** Project id */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: String) = apply { - this.cursor = cursor - } + fun cursor(cursor: String) = apply { this.cursor = cursor } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ fun filters(filters: List) = apply { this.filters.clear() @@ -463,75 +417,63 @@ class ProjectLogFetchPostParams constructor( } /** - * A list of filters on the events to fetch. Currently, only path-lookup type - * filters are supported, but we may add more in the future + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported, but we may add more in the future */ - fun addFilter(filter: Filter) = apply { - this.filters.add(filter) - } + fun addFilter(filter: Filter) = apply { this.filters.add(filter) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -571,9 +513,7 @@ class ProjectLogFetchPostParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -584,65 +524,60 @@ class ProjectLogFetchPostParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - cursor, - if(filters.size == 0) null else filters.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFetchPostParams = + ProjectLogFetchPostParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + cursor, + if (filters.size == 0) null else filters.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** - * A path-lookup filter describes an equality comparison against a specific - * sub-field in the event row. For instance, if you wish to filter on the value of - * `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` and `value="hello"` + * A path-lookup filter describes an equality comparison against a specific sub-field in the + * event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": + * {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` */ @JsonDeserialize(builder = Filter.Builder::class) @NoAutoDetect - class Filter private constructor( - private val type: Type?, - private val path: List?, - private val value: JsonValue?, - private val additionalProperties: Map, - + class Filter + private constructor( + private val type: Type?, + private val path: List?, + private val value: JsonValue?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - fun type(): Type? = type + @JsonProperty("type") fun type(): Type? = type /** - * List of fields describing the path to the value to be checked against. For - * instance, if you wish to filter on the value of `c` in - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For instance, if + * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` */ - @JsonProperty("path") - fun path(): List? = path + @JsonProperty("path") fun path(): List? = path /** - * The value to compare equality-wise against the event value at the specified - * `path`. The value must be a "primitive", that is, any JSON-serializable object - * except for objects and arrays. For instance, if you wish to filter on the value - * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `value="hello"` + * The value to compare equality-wise against the event value at the specified `path`. The + * value must be a "primitive", that is, any JSON-serializable object except for objects and + * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` */ - @JsonProperty("value") - fun value(): JsonValue? = value + @JsonProperty("value") fun value(): JsonValue? = value @JsonAnyGetter @ExcludeMissing @@ -651,35 +586,36 @@ class ProjectLogFetchPostParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Filter && + this.type == other.type && + this.path == other.path && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + path, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "Filter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -698,32 +634,22 @@ class ProjectLogFetchPostParams constructor( } /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - fun type(type: Type) = apply { - this.type = type - } + @JsonProperty("type") fun type(type: Type) = apply { this.type = type } /** - * List of fields describing the path to the value to be checked against. For - * instance, if you wish to filter on the value of `c` in - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For instance, + * if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": + * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` */ - @JsonProperty("path") - fun path(path: List) = apply { - this.path = path - } + @JsonProperty("path") fun path(path: List) = apply { this.path = path } /** - * The value to compare equality-wise against the event value at the specified - * `path`. The value must be a "primitive", that is, any JSON-serializable object - * except for objects and arrays. For instance, if you wish to filter on the value - * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `value="hello"` + * The value to compare equality-wise against the event value at the specified `path`. + * The value must be a "primitive", that is, any JSON-serializable object except for + * objects and arrays. For instance, if you wish to filter on the value of "input.a.b.c" + * in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` */ - @JsonProperty("value") - fun value(value: JsonValue) = apply { - this.value = value - } + @JsonProperty("value") fun value(value: JsonValue) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -739,30 +665,29 @@ class ProjectLogFetchPostParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Filter = Filter( - checkNotNull(type) { - "`type` is required but was not set" - }, - checkNotNull(path) { - "`path` is required but was not set" - }.toUnmodifiable(), - value, - additionalProperties.toUnmodifiable(), - ) + fun build(): Filter = + Filter( + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(path) { "`path` is required but was not set" }.toUnmodifiable(), + value, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -785,15 +710,17 @@ class ProjectLogFetchPostParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + PATH_LOOKUP -> Value.PATH_LOOKUP + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PATH_LOOKUP -> Known.PATH_LOOKUP + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt index 58819cd..bcd1e82 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt @@ -2,40 +2,31 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ProjectLogFetchPostResponse.Builder::class) @NoAutoDetect -class ProjectLogFetchPostResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { +class ProjectLogFetchPostResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { private var validated: Boolean = false @@ -47,25 +38,21 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events() = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -73,42 +60,43 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun validate(): ProjectLogFetchPostResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchPostResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectLogFetchPostResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectLogFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectLogFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -130,29 +118,25 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { - this.events = events - } + fun events(events: JsonField>) = apply { this.events = events } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String) = cursor(JsonField.of(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -168,36 +152,37 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogFetchPostResponse = ProjectLogFetchPostResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFetchPostResponse = + ProjectLogFetchPostResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Event.Builder::class) @NoAutoDetect - class Event private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - + class Event + private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val orgId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -205,16 +190,15 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi private var hashCode: Int = 0 /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -231,48 +215,46 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun logId(): LogId = logId.getRequired("log_id") /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ fun input(): JsonValue = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -280,187 +262,146 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** The `span_id` of the root of the trace this project logs event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** Unique identifier for the project */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") - @ExcludeMissing - fun _logId() = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId() = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ - @JsonProperty("span_parents") - @ExcludeMissing - fun _spanParents() = spanParents + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents /** The `span_id` of the root of the trace this project logs event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes @JsonAnyGetter @ExcludeMissing @@ -468,90 +409,91 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun validate(): Event = apply { if (!validated) { - id() - _xactId() - created() - orgId() - projectId() - logId() - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanId() - spanParents() - rootSpanId() - spanAttributes().map { it.validate() } - validated = true + id() + _xactId() + created() + orgId() + projectId() + logId() + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanId() + spanParents() + rootSpanId() + spanAttributes().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.orgId == other.orgId && - this.projectId == other.projectId && - this.logId == other.logId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Event && + this.id == other.id && + this._xactId == other._xactId && + this.created == other.created && + this.orgId == other.orgId && + this.projectId == other.projectId && + this.logId == other.logId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Event{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + override fun toString() = + "Event{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -600,40 +542,36 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi } /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the project logs (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the project logs (see the `version` + * parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -641,9 +579,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** The timestamp the project logs event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -651,9 +587,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** Unique id for the organization that the project belongs under */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -661,9 +595,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** Unique identifier for the project */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A literal 'g' which identifies the log as a project log */ fun logId(logId: LogId) = logId(JsonField.of(logId)) @@ -671,9 +603,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** A literal 'g' which identifies the log as a project log */ @JsonProperty("log_id") @ExcludeMissing - fun logId(logId: JsonField) = apply { - this.logId = logId - } + fun logId(logId: JsonField) = apply { this.logId = logId } /** * The arguments that uniquely define a user input (an arbitrary, JSON serializable @@ -681,86 +611,74 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question. */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * while digging into analyses. However, we may later use these values to re-score + * outputs or fine-tune your models. */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -768,79 +686,67 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ fun context(context: Context) = context(JsonField.of(context)) /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty + * for the root span of a trace, and should most often contain just one parent element + * for subspans */ fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty + * for the root span of a trace, and should most often contain just one parent element + * for subspans */ @JsonProperty("span_parents") @ExcludeMissing @@ -854,12 +760,11 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** The `span_id` of the root of the trace this project logs event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -882,41 +787,44 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.putAll(additionalProperties) } - fun build(): Event = Event( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) + fun build(): Event = + Event( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) } - class LogId @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class LogId + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is LogId && - this.value == other.value + return other is LogId && this.value == other.value } override fun hashCode() = value.hashCode() @@ -939,33 +847,34 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi _UNKNOWN, } - fun value(): Value = when (this) { - G -> Value.G - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + G -> Value.G + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - G -> Known.G - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } + fun known(): Known = + when (this) { + G -> Known.G + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } fun asString(): String = _value().asStringOrThrow() } /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -973,13 +882,16 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi private var hashCode: Int = 0 /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -987,14 +899,10 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -1002,45 +910,46 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1059,7 +968,8 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -1069,7 +979,8 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -1098,29 +1009,34 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1132,34 +1048,32 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1181,29 +1095,30 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1211,68 +1126,62 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi private var hashCode: Int = 0 /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1280,51 +1189,52 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1358,9 +1268,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** * A unix timestamp recording when the section of code which produced the project @@ -1374,9 +1282,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the project logs event (only @@ -1398,7 +1304,8 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** * The number of tokens in the completion generated by the model (only set if this @@ -1416,9 +1323,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1430,34 +1335,38 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1469,34 +1378,32 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1518,9 +1425,10 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -1529,7 +1437,12 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1542,14 +1455,10 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1557,42 +1466,43 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1614,9 +1524,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -1624,9 +1532,7 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1638,29 +1544,33 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1703,25 +1613,27 @@ class ProjectLogFetchPostResponse private constructor(private val events: JsonFi _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt index 0536a04..4ff0d6a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt @@ -2,40 +2,31 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ProjectLogFetchResponse.Builder::class) @NoAutoDetect -class ProjectLogFetchResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { +class ProjectLogFetchResponse +private constructor( + private val events: JsonField>, + private val cursor: JsonField, + private val additionalProperties: Map, +) { private var validated: Boolean = false @@ -47,25 +38,21 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events() = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -73,42 +60,43 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun validate(): ProjectLogFetchResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectLogFetchResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectLogFetchResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectLogFetchResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -130,29 +118,25 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { - this.events = events - } + fun events(events: JsonField>) = apply { this.events = events } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String) = cursor(JsonField.of(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -168,36 +152,37 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogFetchResponse = ProjectLogFetchResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFetchResponse = + ProjectLogFetchResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Event.Builder::class) @NoAutoDetect - class Event private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - + class Event + private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val orgId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -205,16 +190,15 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< private var hashCode: Int = 0 /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -231,48 +215,46 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun logId(): LogId = logId.getRequired("log_id") /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ fun input(): JsonValue = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -280,187 +262,146 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** The `span_id` of the root of the trace this project logs event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** Unique identifier for the project */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") - @ExcludeMissing - fun _logId() = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId() = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ - @JsonProperty("span_parents") - @ExcludeMissing - fun _spanParents() = spanParents + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents /** The `span_id` of the root of the trace this project logs event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes @JsonAnyGetter @ExcludeMissing @@ -468,90 +409,91 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun validate(): Event = apply { if (!validated) { - id() - _xactId() - created() - orgId() - projectId() - logId() - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanId() - spanParents() - rootSpanId() - spanAttributes().map { it.validate() } - validated = true + id() + _xactId() + created() + orgId() + projectId() + logId() + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanId() + spanParents() + rootSpanId() + spanAttributes().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.orgId == other.orgId && - this.projectId == other.projectId && - this.logId == other.logId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Event && + this.id == other.id && + this._xactId == other._xactId && + this.created == other.created && + this.orgId == other.orgId && + this.projectId == other.projectId && + this.logId == other.logId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Event{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + override fun toString() = + "Event{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -600,40 +542,36 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< } /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the project logs (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be + * used to retrieve a versioned snapshot of the project logs (see the `version` + * parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -641,9 +579,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** The timestamp the project logs event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -651,9 +587,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** Unique id for the organization that the project belongs under */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -661,9 +595,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** Unique identifier for the project */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A literal 'g' which identifies the log as a project log */ fun logId(logId: LogId) = logId(JsonField.of(logId)) @@ -671,9 +603,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** A literal 'g' which identifies the log as a project log */ @JsonProperty("log_id") @ExcludeMissing - fun logId(logId: JsonField) = apply { - this.logId = logId - } + fun logId(logId: JsonField) = apply { this.logId = logId } /** * The arguments that uniquely define a user input (an arbitrary, JSON serializable @@ -681,86 +611,74 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question. */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * while digging into analyses. However, we may later use these values to re-score + * outputs or fine-tune your models. */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -768,79 +686,67 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ fun context(context: Context) = context(JsonField.of(context)) /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a + * full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) + * for full details on tracing */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty + * for the root span of a trace, and should most often contain just one parent element + * for subspans */ fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty + * for the root span of a trace, and should most often contain just one parent element + * for subspans */ @JsonProperty("span_parents") @ExcludeMissing @@ -854,12 +760,11 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** The `span_id` of the root of the trace this project logs event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -882,41 +787,44 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< this.additionalProperties.putAll(additionalProperties) } - fun build(): Event = Event( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) + fun build(): Event = + Event( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) } - class LogId @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class LogId + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is LogId && - this.value == other.value + return other is LogId && this.value == other.value } override fun hashCode() = value.hashCode() @@ -939,33 +847,34 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< _UNKNOWN, } - fun value(): Value = when (this) { - G -> Value.G - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + G -> Value.G + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - G -> Known.G - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } + fun known(): Known = + when (this) { + G -> Known.G + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } fun asString(): String = _value().asStringOrThrow() } /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -973,13 +882,16 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< private var hashCode: Int = 0 /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -987,14 +899,10 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -1002,45 +910,46 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1059,7 +968,8 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -1069,7 +979,8 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -1098,29 +1009,34 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1132,34 +1048,32 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1181,29 +1095,30 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1211,68 +1126,62 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< private var hashCode: Int = 0 /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1280,51 +1189,52 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1358,9 +1268,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** * A unix timestamp recording when the section of code which produced the project @@ -1374,9 +1282,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the project logs event (only @@ -1398,7 +1304,8 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** * The number of tokens in the completion generated by the model (only set if this @@ -1416,9 +1323,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1430,34 +1335,38 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1469,34 +1378,32 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1518,9 +1425,10 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -1529,7 +1437,12 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1542,14 +1455,10 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1557,42 +1466,43 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1614,9 +1524,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -1624,9 +1532,7 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1638,29 +1544,33 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1703,25 +1613,27 @@ class ProjectLogFetchResponse private constructor(private val events: JsonField< _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 42c1d4e..2da5010 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -2,47 +2,40 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectLogInsertParams constructor( - private val projectId: String, - private val events: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectLogInsertParams +constructor( + private val projectId: String, + private val events: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -51,31 +44,32 @@ class ProjectLogInsertParams constructor( @JvmSynthetic internal fun getBody(): ProjectLogInsertBody { - return ProjectLogInsertBody(events, additionalBodyProperties) + return ProjectLogInsertBody(events, additionalBodyProperties) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectLogInsertBody.Builder::class) @NoAutoDetect - class ProjectLogInsertBody internal constructor(private val events: List?, private val additionalProperties: Map, ) { + class ProjectLogInsertBody + internal constructor( + private val events: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** A list of project logs events to insert */ - @JsonProperty("events") - fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -84,28 +78,28 @@ class ProjectLogInsertParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectLogInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties + return other is ProjectLogInsertBody && + this.events == other.events && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode } - override fun toString() = "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -120,10 +114,7 @@ class ProjectLogInsertParams constructor( } /** A list of project logs events to insert */ - @JsonProperty("events") - fun events(events: List) = apply { - this.events = events - } + @JsonProperty("events") fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -139,9 +130,12 @@ class ProjectLogInsertParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogInsertBody = ProjectLogInsertBody(checkNotNull(events) { - "`events` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) + fun build(): ProjectLogInsertBody = + ProjectLogInsertBody( + checkNotNull(events) { "`events` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) } } @@ -152,36 +146,36 @@ class ProjectLogInsertParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogInsertParams && - this.projectId == other.projectId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectLogInsertParams && + this.projectId == other.projectId && + this.events == other.events && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + events, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -203,9 +197,7 @@ class ProjectLogInsertParams constructor( } /** Project id */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs events to insert */ fun events(events: List) = apply { @@ -214,9 +206,7 @@ class ProjectLogInsertParams constructor( } /** A list of project logs events to insert */ - fun addEvent(event: Event) = apply { - this.events.add(event) - } + fun addEvent(event: Event) = apply { this.events.add(event) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,9 +246,7 @@ class ProjectLogInsertParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -269,148 +257,182 @@ class ProjectLogInsertParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectLogInsertParams = ProjectLogInsertParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(events) { - "`events` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectLogInsertParams = + ProjectLogInsertParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Event.Deserializer::class) @JsonSerialize(using = Event.Serializer::class) - class Event private constructor(private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, private val _json: JsonValue? = null, ) { + class Event + private constructor( + private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, + private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun insertProjectLogsEventReplace(): Optional = Optional.ofNullable(insertProjectLogsEventReplace) - fun insertProjectLogsEventMerge(): Optional = Optional.ofNullable(insertProjectLogsEventMerge) + fun insertProjectLogsEventReplace(): Optional = + Optional.ofNullable(insertProjectLogsEventReplace) + + fun insertProjectLogsEventMerge(): Optional = + Optional.ofNullable(insertProjectLogsEventMerge) fun isInsertProjectLogsEventReplace(): Boolean = insertProjectLogsEventReplace != null + fun isInsertProjectLogsEventMerge(): Boolean = insertProjectLogsEventMerge != null - fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") - fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") + fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = + insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") + + fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = + insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - insertProjectLogsEventReplace != null -> visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) - insertProjectLogsEventMerge != null -> visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) - else -> visitor.unknown(_json) - } + return when { + insertProjectLogsEventReplace != null -> + visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) + insertProjectLogsEventMerge != null -> + visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) + else -> visitor.unknown(_json) + } } fun validate(): Event = apply { if (!validated) { - if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertProjectLogsEventReplace?.validate() - insertProjectLogsEventMerge?.validate() - validated = true + if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { + throw BraintrustInvalidDataException("Unknown Event: $_json") + } + insertProjectLogsEventReplace?.validate() + insertProjectLogsEventMerge?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Event && - this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && - this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge + return other is Event && + this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && + this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge } override fun hashCode(): Int { - return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) + return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) } override fun toString(): String { - return when { - insertProjectLogsEventReplace != null -> "Event{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" - insertProjectLogsEventMerge != null -> "Event{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } + return when { + insertProjectLogsEventReplace != null -> + "Event{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" + insertProjectLogsEventMerge != null -> + "Event{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" + _json != null -> "Event{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Event") + } } companion object { @JvmStatic - fun ofInsertProjectLogsEventReplace(insertProjectLogsEventReplace: InsertProjectLogsEventReplace) = Event(insertProjectLogsEventReplace = insertProjectLogsEventReplace) + fun ofInsertProjectLogsEventReplace( + insertProjectLogsEventReplace: InsertProjectLogsEventReplace + ) = Event(insertProjectLogsEventReplace = insertProjectLogsEventReplace) @JvmStatic - fun ofInsertProjectLogsEventMerge(insertProjectLogsEventMerge: InsertProjectLogsEventMerge) = Event(insertProjectLogsEventMerge = insertProjectLogsEventMerge) + fun ofInsertProjectLogsEventMerge( + insertProjectLogsEventMerge: InsertProjectLogsEventMerge + ) = Event(insertProjectLogsEventMerge = insertProjectLogsEventMerge) } interface Visitor { - fun visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace: InsertProjectLogsEventReplace): T + fun visitInsertProjectLogsEventReplace( + insertProjectLogsEventReplace: InsertProjectLogsEventReplace + ): T - fun visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge: InsertProjectLogsEventMerge): T + fun visitInsertProjectLogsEventMerge( + insertProjectLogsEventMerge: InsertProjectLogsEventMerge + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") + throw BraintrustInvalidDataException("Unknown Event: $json") } } class Deserializer : BaseDeserializer(Event::class) { override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Event(insertProjectLogsEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Event(insertProjectLogsEventMerge = it, _json = json) - } - - return Event(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Event(insertProjectLogsEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Event(insertProjectLogsEventMerge = it, _json = json) + } + + return Event(_json = json) } } class Serializer : BaseSerializer(Event::class) { - override fun serialize(value: Event, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.insertProjectLogsEventReplace != null -> generator.writeObject(value.insertProjectLogsEventReplace) - value.insertProjectLogsEventMerge != null -> generator.writeObject(value.insertProjectLogsEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } + override fun serialize( + value: Event, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.insertProjectLogsEventReplace != null -> + generator.writeObject(value.insertProjectLogsEventReplace) + value.insertProjectLogsEventMerge != null -> + generator.writeObject(value.insertProjectLogsEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Event") + } } } @JsonDeserialize(builder = InsertProjectLogsEventReplace.Builder::class) @NoAutoDetect - class InsertProjectLogsEventReplace private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, - + class InsertProjectLogsEventReplace + private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -425,251 +447,223 @@ class ProjectLogInsertParams constructor( /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question. */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * while digging into analyses. However, we may later use these values to re-score + * outputs or fine-tune your models. */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** The timestamp the project logs event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun created(): Optional = + Optional.ofNullable(created.getNullable("created")) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + fun _isMerge(): Optional = + Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships + * are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": + * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, + * only the root span row `"abc"` will show up in the summary view. You can view the + * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" + * row. */ - fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + fun _parentId(): Optional = + Optional.ofNullable(_parentId.getNullable("_parent_id")) /** * The arguments that uniquely define a user input (an arbitrary, JSON serializable * object). */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question. */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * while digging into analyses. However, we may later use these values to re-score + * outputs or fine-tune your models. */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical - * relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships + * are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": + * "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, + * only the root span row `"abc"` will show up in the summary view. You can view the + * full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" + * row. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun __parentId() = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId @JsonAnyGetter @ExcludeMissing @@ -677,78 +671,79 @@ class ProjectLogInsertParams constructor( fun validate(): InsertProjectLogsEventReplace = apply { if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertProjectLogsEventReplace && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -770,23 +765,24 @@ class ProjectLogInsertParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertProjectLogsEventReplace: InsertProjectLogsEventReplace) = apply { - this.input = insertProjectLogsEventReplace.input - this.output = insertProjectLogsEventReplace.output - this.expected = insertProjectLogsEventReplace.expected - this.scores = insertProjectLogsEventReplace.scores - this.metadata = insertProjectLogsEventReplace.metadata - this.tags = insertProjectLogsEventReplace.tags - this.metrics = insertProjectLogsEventReplace.metrics - this.context = insertProjectLogsEventReplace.context - this.spanAttributes = insertProjectLogsEventReplace.spanAttributes - this.id = insertProjectLogsEventReplace.id - this.created = insertProjectLogsEventReplace.created - this._objectDelete = insertProjectLogsEventReplace._objectDelete - this._isMerge = insertProjectLogsEventReplace._isMerge - this._parentId = insertProjectLogsEventReplace._parentId - additionalProperties(insertProjectLogsEventReplace.additionalProperties) - } + internal fun from(insertProjectLogsEventReplace: InsertProjectLogsEventReplace) = + apply { + this.input = insertProjectLogsEventReplace.input + this.output = insertProjectLogsEventReplace.output + this.expected = insertProjectLogsEventReplace.expected + this.scores = insertProjectLogsEventReplace.scores + this.metadata = insertProjectLogsEventReplace.metadata + this.tags = insertProjectLogsEventReplace.tags + this.metrics = insertProjectLogsEventReplace.metrics + this.context = insertProjectLogsEventReplace.context + this.spanAttributes = insertProjectLogsEventReplace.spanAttributes + this.id = insertProjectLogsEventReplace.id + this.created = insertProjectLogsEventReplace.created + this._objectDelete = insertProjectLogsEventReplace._objectDelete + this._isMerge = insertProjectLogsEventReplace._isMerge + this._parentId = insertProjectLogsEventReplace._parentId + additionalProperties(insertProjectLogsEventReplace.additionalProperties) + } /** * The arguments that uniquely define a user input (an arbitrary, JSON serializable @@ -794,46 +790,40 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, + * or not. For example, in an app that generates SQL queries, the `output` should be + * the _result_ of the SQL query generated by the model, not the query itself, * because there may be multiple valid queries that answer a single question. */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * Braintrust currently does not compare `output` to `expected` for you, since there + * are so many different ways to do that correctly. Instead, these values are just + * used to help you navigate while digging into analyses. However, we may later use + * these values to re-score outputs or fine-tune your models. */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare logs. */ fun scores(scores: Scores) = scores(JsonField.of(scores)) @@ -842,16 +832,14 @@ class ProjectLogInsertParams constructor( * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare logs. */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just @@ -871,9 +859,7 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -881,9 +867,7 @@ class ProjectLogInsertParams constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** * Metrics are numerical measurements tracking the execution of the code that @@ -899,32 +883,27 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ fun context(context: Context) = context(JsonField.of(context)) /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -945,9 +924,7 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -955,19 +932,18 @@ class ProjectLogInsertParams constructor( /** The timestamp the project logs event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean) = + _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ @JsonProperty("_object_delete") @ExcludeMissing @@ -981,12 +957,12 @@ class ProjectLogInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) @@ -996,54 +972,50 @@ class ProjectLogInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical * relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": + * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a + * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": + * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in + * the summary view. You can view the full trace hierarchy (in this case, the + * `"llm_call"` row) by clicking on the "abc" row. */ fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * Use the `_parent_id` field to create this row as a subspan of an existing row. It + * cannot be specified alongside `_is_merge=true`. Tracking hierarchical * relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": + * "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a + * sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": + * {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in + * the summary view. You can view the full trace hierarchy (in this case, the + * `"llm_call"` row) by clicking on the "abc" row. */ @JsonProperty("_parent_id") @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { - this._parentId = _parentId - } + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1055,43 +1027,44 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): InsertProjectLogsEventReplace = InsertProjectLogsEventReplace( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertProjectLogsEventReplace = + InsertProjectLogsEventReplace( + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) } /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1099,13 +1072,16 @@ class ProjectLogInsertParams constructor( private var hashCode: Int = 0 /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -1118,9 +1094,7 @@ class ProjectLogInsertParams constructor( fun _callerFilename() = callerFilename /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -1128,45 +1102,46 @@ class ProjectLogInsertParams constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1185,7 +1160,8 @@ class ProjectLogInsertParams constructor( } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -1195,7 +1171,8 @@ class ProjectLogInsertParams constructor( } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -1224,29 +1201,34 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1258,34 +1240,33 @@ class ProjectLogInsertParams constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1307,29 +1288,30 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1352,13 +1334,15 @@ class ProjectLogInsertParams constructor( * The number of tokens in the prompt used to generate the project logs event (only * set if this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) @@ -1367,25 +1351,19 @@ class ProjectLogInsertParams constructor( * A unix timestamp recording when the section of code which produced the project * logs event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** * A unix timestamp recording when the section of code which produced the project * logs event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** * The number of tokens in the prompt used to generate the project logs event (only * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** * The number of tokens in the completion generated by the model (only set if this @@ -1396,9 +1374,7 @@ class ProjectLogInsertParams constructor( fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1406,51 +1382,52 @@ class ProjectLogInsertParams constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1473,46 +1450,42 @@ class ProjectLogInsertParams constructor( } /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the + * project logs event started */ fun start(start: Double) = start(JsonField.of(start)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the + * project logs event started */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the + * project logs event finished */ fun end(end: Double) = end(JsonField.of(end)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the + * project logs event finished */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event + * (only set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event + * (only set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1521,14 +1494,15 @@ class ProjectLogInsertParams constructor( } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1536,15 +1510,17 @@ class ProjectLogInsertParams constructor( this.completionTokens = completionTokens } - /** The total number of tokens in the input and output of the project logs event. */ + /** + * The total number of tokens in the input and output of the project logs event. + */ fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * The total number of tokens in the input and output of the project logs event. + */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1556,34 +1532,38 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1595,34 +1575,33 @@ class ProjectLogInsertParams constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1644,9 +1623,10 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -1655,7 +1635,12 @@ class ProjectLogInsertParams constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1668,14 +1653,10 @@ class ProjectLogInsertParams constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1683,42 +1664,43 @@ class ProjectLogInsertParams constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1740,9 +1722,7 @@ class ProjectLogInsertParams constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -1750,9 +1730,7 @@ class ProjectLogInsertParams constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1764,29 +1742,34 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1829,25 +1812,27 @@ class ProjectLogInsertParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1856,23 +1841,23 @@ class ProjectLogInsertParams constructor( @JsonDeserialize(builder = InsertProjectLogsEventMerge.Builder::class) @NoAutoDetect - class InsertProjectLogsEventMerge private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, - + class InsertProjectLogsEventMerge + private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1887,253 +1872,222 @@ class ProjectLogInsertParams constructor( /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question. */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * while digging into analyses. However, we may later use these values to re-score + * outputs or fine-tune your models. */ fun expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** The timestamp the project logs event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun created(): Optional = + Optional.ofNullable(created.getNullable("created")) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each + * path is a list of field names. The deep merge will not descend below any of the + * specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, + * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced + * `input.a` and `output`, but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** * The arguments that uniquely define a user input (an arbitrary, JSON serializable * object). */ - @JsonProperty("input") - @ExcludeMissing - fun _input() = input + @JsonProperty("input") @ExcludeMissing fun _input() = input /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or + * not. For example, in an app that generates SQL queries, the `output` should be the + * _result_ of the SQL query generated by the model, not the query itself, because there + * may be multiple valid queries that answer a single question. */ - @JsonProperty("output") - @ExcludeMissing - fun _output() = output + @JsonProperty("output") @ExcludeMissing fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently + * does not compare `output` to `expected` for you, since there are so many different + * ways to do that correctly. Instead, these values are just used to help you navigate + * while digging into analyses. However, we may later use these values to re-score + * outputs or fine-tune your models. */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected() = expected + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores() = scores + @JsonProperty("scores") @ExcludeMissing fun _scores() = scores /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ - @JsonProperty("context") - @ExcludeMissing - fun _context() = context + @JsonProperty("context") @ExcludeMissing fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with the + * same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is deep-merged + * into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, + * "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": + * 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": + * 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the + * new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only be + * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each + * path is a list of field names. The deep merge will not descend below any of the + * specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, + * "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced + * `input.a` and `output`, but have still deep-merged `input` and `input.c`. */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths @JsonAnyGetter @ExcludeMissing @@ -2141,78 +2095,79 @@ class ProjectLogInsertParams constructor( fun validate(): InsertProjectLogsEventMerge = apply { if (!validated) { - input() - output() - expected() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true + input() + output() + expected() + scores().map { it.validate() } + metadata().map { it.validate() } + tags() + metrics().map { it.validate() } + context().map { it.validate() } + spanAttributes().map { it.validate() } + id() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertProjectLogsEventMerge && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + input, + output, + expected, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2234,23 +2189,24 @@ class ProjectLogInsertParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertProjectLogsEventMerge: InsertProjectLogsEventMerge) = apply { - this.input = insertProjectLogsEventMerge.input - this.output = insertProjectLogsEventMerge.output - this.expected = insertProjectLogsEventMerge.expected - this.scores = insertProjectLogsEventMerge.scores - this.metadata = insertProjectLogsEventMerge.metadata - this.tags = insertProjectLogsEventMerge.tags - this.metrics = insertProjectLogsEventMerge.metrics - this.context = insertProjectLogsEventMerge.context - this.spanAttributes = insertProjectLogsEventMerge.spanAttributes - this.id = insertProjectLogsEventMerge.id - this.created = insertProjectLogsEventMerge.created - this._objectDelete = insertProjectLogsEventMerge._objectDelete - this._isMerge = insertProjectLogsEventMerge._isMerge - this._mergePaths = insertProjectLogsEventMerge._mergePaths - additionalProperties(insertProjectLogsEventMerge.additionalProperties) - } + internal fun from(insertProjectLogsEventMerge: InsertProjectLogsEventMerge) = + apply { + this.input = insertProjectLogsEventMerge.input + this.output = insertProjectLogsEventMerge.output + this.expected = insertProjectLogsEventMerge.expected + this.scores = insertProjectLogsEventMerge.scores + this.metadata = insertProjectLogsEventMerge.metadata + this.tags = insertProjectLogsEventMerge.tags + this.metrics = insertProjectLogsEventMerge.metrics + this.context = insertProjectLogsEventMerge.context + this.spanAttributes = insertProjectLogsEventMerge.spanAttributes + this.id = insertProjectLogsEventMerge.id + this.created = insertProjectLogsEventMerge.created + this._objectDelete = insertProjectLogsEventMerge._objectDelete + this._isMerge = insertProjectLogsEventMerge._isMerge + this._mergePaths = insertProjectLogsEventMerge._mergePaths + additionalProperties(insertProjectLogsEventMerge.additionalProperties) + } /** * The arguments that uniquely define a user input (an arbitrary, JSON serializable @@ -2258,46 +2214,40 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, + * or not. For example, in an app that generates SQL queries, the `output` should be + * the _result_ of the SQL query generated by the model, not the query itself, * because there may be multiple valid queries that answer a single question. */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * Braintrust currently does not compare `output` to `expected` for you, since there + * are so many different ways to do that correctly. Instead, these values are just + * used to help you navigate while digging into analyses. However, we may later use + * these values to re-score outputs or fine-tune your models. */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare logs. */ fun scores(scores: Scores) = scores(JsonField.of(scores)) @@ -2306,16 +2256,14 @@ class ProjectLogInsertParams constructor( * you a variety of signals that help you determine how accurate the outputs are * compared to what you expect and diagnose failures. For example, a summarization * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * that measures the word similarity between the generated and grouth truth summary. + * The word similarity score could help you determine whether the summarization was + * covering similar concepts or not. You can use these scores to help you sort, + * filter, and compare logs. */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** * A dictionary with additional data about the test example, model outputs, or just @@ -2335,9 +2283,7 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -2345,9 +2291,7 @@ class ProjectLogInsertParams constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** * Metrics are numerical measurements tracking the execution of the code that @@ -2363,32 +2307,27 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ fun context(context: Context) = context(JsonField.of(context)) /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = + spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -2409,9 +2348,7 @@ class ProjectLogInsertParams constructor( */ @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -2419,19 +2356,18 @@ class ProjectLogInsertParams constructor( /** The timestamp the project logs event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean) = + _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events + * will not show up in subsequent fetches for this project logs */ @JsonProperty("_object_delete") @ExcludeMissing @@ -2445,12 +2381,12 @@ class ProjectLogInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) @@ -2460,50 +2396,49 @@ class ProjectLogInsertParams constructor( * completely replaced by the new row. When set to `true`, the new row is * deep-merged into the existing row * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", + * "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": + * 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": + * {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": + * 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where + * each path is a list of field names. The deep merge will not descend below any of + * the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will + * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": + * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have + * replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ - fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + fun _mergePaths(_mergePaths: List>) = + _mergePaths(JsonField.of(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge. It can only - * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, - * where each path is a list of field names. The deep merge will not descend below - * any of the specified merge paths. + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where + * each path is a list of field names. The deep merge will not descend below any of + * the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": + * {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": + * {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will + * be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": + * "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have + * replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing @@ -2521,43 +2456,44 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): InsertProjectLogsEventMerge = InsertProjectLogsEventMerge( - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertProjectLogsEventMerge = + InsertProjectLogsEventMerge( + input, + output, + expected, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } /** * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` + * attributes to track the location in code which produced the project logs event */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - + class Context + private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2565,13 +2501,16 @@ class ProjectLogInsertParams constructor( private var hashCode: Int = 0 /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -2584,9 +2523,7 @@ class ProjectLogInsertParams constructor( fun _callerFilename() = callerFilename /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -2594,45 +2531,46 @@ class ProjectLogInsertParams constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2651,7 +2589,8 @@ class ProjectLogInsertParams constructor( } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = + callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -2661,7 +2600,8 @@ class ProjectLogInsertParams constructor( } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = + callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -2690,29 +2630,34 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Context = Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = + Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** * A dictionary with additional data about the test example, model outputs, or just * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * examples later. For example, you could log the `prompt`, example's `id`, or anything + * else that would be useful to slice/dice later. The values in `metadata` can be any + * JSON-serializable type, but its keys must be strings */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2724,34 +2669,33 @@ class ProjectLogInsertParams constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2773,29 +2717,30 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced + * the project logs event. Use "start" and "end" to track the time span over which the + * project logs event was produced */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - + class Metrics + private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2818,13 +2763,15 @@ class ProjectLogInsertParams constructor( * The number of tokens in the prompt used to generate the project logs event (only * set if this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** * The number of tokens in the completion generated by the model (only set if this * is an LLM span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) @@ -2833,25 +2780,19 @@ class ProjectLogInsertParams constructor( * A unix timestamp recording when the section of code which produced the project * logs event started */ - @JsonProperty("start") - @ExcludeMissing - fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start() = start /** * A unix timestamp recording when the section of code which produced the project * logs event finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end() = end /** * The number of tokens in the prompt used to generate the project logs event (only * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens /** * The number of tokens in the completion generated by the model (only set if this @@ -2862,9 +2803,7 @@ class ProjectLogInsertParams constructor( fun _completionTokens() = completionTokens /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens() = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -2872,51 +2811,52 @@ class ProjectLogInsertParams constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2939,46 +2879,42 @@ class ProjectLogInsertParams constructor( } /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the + * project logs event started */ fun start(start: Double) = start(JsonField.of(start)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the + * project logs event started */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the + * project logs event finished */ fun end(end: Double) = end(JsonField.of(end)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the + * project logs event finished */ @JsonProperty("end") @ExcludeMissing - fun end(end: JsonField) = apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event + * (only set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event + * (only set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -2987,14 +2923,15 @@ class ProjectLogInsertParams constructor( } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) + fun completionTokens(completionTokens: Long) = + completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if + * this is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -3002,15 +2939,17 @@ class ProjectLogInsertParams constructor( this.completionTokens = completionTokens } - /** The total number of tokens in the input and output of the project logs event. */ + /** + * The total number of tokens in the input and output of the project logs event. + */ fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * The total number of tokens in the input and output of the project logs event. + */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3022,34 +2961,38 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Metrics = Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = + Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to + * what you expect and diagnose failures. For example, a summarization app might have + * one score that tells you how accurate the summary is, and another that measures the + * word similarity between the generated and grouth truth summary. The word similarity + * score could help you determine whether the summarization was covering similar + * concepts or not. You can use these scores to help you sort, filter, and compare logs. */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores private constructor(private val additionalProperties: Map, ) { + class Scores + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3061,34 +3004,33 @@ class ProjectLogInsertParams constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && - this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3110,9 +3052,10 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } @@ -3121,7 +3064,12 @@ class ProjectLogInsertParams constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class SpanAttributes + private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3134,14 +3082,10 @@ class ProjectLogInsertParams constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -3149,42 +3093,43 @@ class ProjectLogInsertParams constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3206,9 +3151,7 @@ class ProjectLogInsertParams constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type) = type(JsonField.of(type)) @@ -3216,9 +3159,7 @@ class ProjectLogInsertParams constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3230,29 +3171,34 @@ class ProjectLogInsertParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): SpanAttributes = SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3295,25 +3241,27 @@ class ProjectLogInsertParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = + when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt index 79f5145..57cb17f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt @@ -2,58 +2,39 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ProjectLogInsertResponse.Builder::class) @NoAutoDetect -class ProjectLogInsertResponse private constructor(private val rowIds: JsonField>, private val additionalProperties: Map, ) { +class ProjectLogInsertResponse +private constructor( + private val rowIds: JsonField>, + private val additionalProperties: Map, +) { private var validated: Boolean = false private var hashCode: Int = 0 /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ fun rowIds(): List = rowIds.getRequired("row_ids") /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ - @JsonProperty("row_ids") - @ExcludeMissing - fun _rowIds() = rowIds + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds @JsonAnyGetter @ExcludeMissing @@ -61,36 +42,36 @@ class ProjectLogInsertResponse private constructor(private val rowIds: JsonField fun validate(): ProjectLogInsertResponse = apply { if (!validated) { - rowIds() - validated = true + rowIds() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectLogInsertResponse && - this.rowIds == other.rowIds && - this.additionalProperties == other.additionalProperties + return other is ProjectLogInsertResponse && + this.rowIds == other.rowIds && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(rowIds, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(rowIds, additionalProperties) + } + return hashCode } - override fun toString() = "ProjectLogInsertResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectLogInsertResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -105,20 +86,18 @@ class ProjectLogInsertResponse private constructor(private val rowIds: JsonField } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ @JsonProperty("row_ids") @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { - this.rowIds = rowIds - } + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -134,6 +113,10 @@ class ProjectLogInsertResponse private constructor(private val rowIds: JsonField this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogInsertResponse = ProjectLogInsertResponse(rowIds.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable()) + fun build(): ProjectLogInsertResponse = + ProjectLogInsertResponse( + rowIds.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectReplaceParams.kt deleted file mode 100644 index 3dec7fc..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectReplaceParams.kt +++ /dev/null @@ -1,278 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import java.util.Optional - -class ProjectReplaceParams -constructor( - private val name: String, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun orgName(): Optional = Optional.ofNullable(orgName) - - @JvmSynthetic - internal fun getBody(): ProjectReplaceBody { - return ProjectReplaceBody( - name, - orgName, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - - @JsonDeserialize(builder = ProjectReplaceBody.Builder::class) - @NoAutoDetect - class ProjectReplaceBody - internal constructor( - private val name: String?, - private val orgName: String?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** Name of the project */ - @JsonProperty("name") fun name(): String? = name - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. - */ - @JsonProperty("org_name") fun orgName(): String? = orgName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectReplaceBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectReplaceBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: String? = null - private var orgName: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectReplaceBody: ProjectReplaceBody) = apply { - this.name = projectReplaceBody.name - this.orgName = projectReplaceBody.orgName - additionalProperties(projectReplaceBody.additionalProperties) - } - - /** Name of the project */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. - */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectReplaceBody = - ProjectReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalProperties.toUnmodifiable(), - ) - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectReplaceParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "ProjectReplaceParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var name: String? = null - private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectReplaceParams: ProjectReplaceParams) = apply { - this.name = projectReplaceParams.name - this.orgName = projectReplaceParams.orgName - additionalQueryParams(projectReplaceParams.additionalQueryParams) - additionalHeaders(projectReplaceParams.additionalHeaders) - additionalBodyProperties(projectReplaceParams.additionalBodyProperties) - } - - /** Name of the project */ - fun name(name: String) = apply { this.name = name } - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. - */ - fun orgName(orgName: String) = apply { this.orgName = orgName } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectReplaceParams = - ProjectReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 828ed15..93c5c5c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class ProjectRetrieveParams constructor( - private val projectId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectRetrieveParams +constructor( + private val projectId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class ProjectRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectRetrieveParams && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectRetrieveParams && + this.projectId == other.projectId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectRetrieveParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectRetrieveParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class ProjectRetrieveParams constructor( } /** Project id */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class ProjectRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class ProjectRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectRetrieveParams = ProjectRetrieveParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectRetrieveParams = + ProjectRetrieveParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt index d2b35d9..b141704 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt @@ -2,56 +2,48 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -/** - * A project score is a user-configured score, which can be manually-labeled - * through the UI - */ +/** A project score is a user-configured score, which can be manually-labeled through the UI */ @JsonDeserialize(builder = ProjectScore.Builder::class) @NoAutoDetect -class ProjectScore private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val scoreType: JsonField, - private val categories: JsonField, - private val config: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - +class ProjectScore +private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val scoreType: JsonField, + private val categories: JsonField, + private val config: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -73,70 +65,46 @@ class ProjectScore private constructor( fun name(): String = name.getRequired("name") /** Textual description of the project score */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** The type of the configured score */ fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) - fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) fun config(): Optional = Optional.ofNullable(config.getNullable("config")) - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(): Optional = Optional.ofNullable(position.getNullable("position")) /** Unique identifier for the project score */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** Date of project score creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Textual description of the project score */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** The type of the configured score */ - @JsonProperty("score_type") - @ExcludeMissing - fun _scoreType() = scoreType + @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType - @JsonProperty("categories") - @ExcludeMissing - fun _categories() = categories + @JsonProperty("categories") @ExcludeMissing fun _categories() = categories - @JsonProperty("config") - @ExcludeMissing - fun _config() = config + @JsonProperty("config") @ExcludeMissing fun _config() = config - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ - @JsonProperty("position") - @ExcludeMissing - fun _position() = position + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + @JsonProperty("position") @ExcludeMissing fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -144,66 +112,67 @@ class ProjectScore private constructor( fun validate(): ProjectScore = apply { if (!validated) { - id() - projectId() - userId() - created() - name() - description() - scoreType() - categories() - config().map { it.validate() } - position() - validated = true + id() + projectId() + userId() + created() + name() + description() + scoreType() + categories() + config().map { it.validate() } + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScore && - this.id == other.id && - this.projectId == other.projectId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.config == other.config && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectScore && + this.id == other.id && + this.projectId == other.projectId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.config == other.config && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - projectId, - userId, - created, - name, - description, - scoreType, - categories, - config, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + projectId, + userId, + created, + name, + description, + scoreType, + categories, + config, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -239,11 +208,7 @@ class ProjectScore private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project score */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -251,17 +216,13 @@ class ProjectScore private constructor( /** Unique identifier for the project that the project score belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } fun userId(userId: String) = userId(JsonField.of(userId)) @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Date of project score creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -269,9 +230,7 @@ class ProjectScore private constructor( /** Date of project score creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) @@ -279,9 +238,7 @@ class ProjectScore private constructor( /** Name of the project score */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the project score */ fun description(description: String) = description(JsonField.of(description)) @@ -289,9 +246,7 @@ class ProjectScore private constructor( /** Textual description of the project score */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) @@ -299,41 +254,27 @@ class ProjectScore private constructor( /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing - fun scoreType(scoreType: JsonField) = apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } fun categories(categories: Categories) = categories(JsonField.of(categories)) @JsonProperty("categories") @ExcludeMissing - fun categories(categories: JsonField) = apply { - this.categories = categories - } + fun categories(categories: JsonField) = apply { this.categories = categories } fun config(config: Config) = config(JsonField.of(config)) @JsonProperty("config") @ExcludeMissing - fun config(config: JsonField) = apply { - this.config = config - } + fun config(config: JsonField) = apply { this.config = config } - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(position: String) = position(JsonField.of(position)) - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ @JsonProperty("position") @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } + fun position(position: JsonField) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -349,33 +290,36 @@ class ProjectScore private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScore = ProjectScore( - id, - projectId, - userId, - created, - name, - description, - scoreType, - categories, - config, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScore = + ProjectScore( + id, + projectId, + userId, + created, + name, + description, + scoreType, + categories, + config, + position, + additionalProperties.toUnmodifiable(), + ) } - class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && - this.value == other.value + return other is ScoreType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -410,181 +354,214 @@ class ProjectScore private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( - private val projectScoreCategories: List? = null, - private val unionMember1: UnionMember1? = null, - private val strings: List? = null, - private val unionMember3: UnionMember3? = null, - private val _json: JsonValue? = null, - + class Categories + private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = Optional.ofNullable(projectScoreCategories) + fun projectScoreCategories(): Optional> = + Optional.ofNullable(projectScoreCategories) /** For weighted-type project scores, the weights of each score */ - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ fun strings(): Optional> = Optional.ofNullable(strings) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isUnionMember1(): Boolean = unionMember1 != null + + fun isWeighted(): Boolean = weighted != null + fun isStrings(): Boolean = strings != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asProjectScoreCategories(): List = + projectScoreCategories.getOrThrow("projectScoreCategories") + + fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + fun asStrings(): List = strings.getOrThrow("strings") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - strings != null -> visitor.visitStrings(strings) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> + visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if (projectScoreCategories == null && unionMember1 == null && strings == null && unionMember3 == null) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - unionMember1?.validate() - unionMember3?.validate() - validated = true + if ( + projectScoreCategories == null && + weighted == null && + strings == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.unionMember1 == other.unionMember1 && - this.strings == other.strings && - this.unionMember3 == other.unionMember3 + if (this === other) { + return true + } + + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - unionMember1, - strings, - unionMember3, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" - unionMember1 != null -> "Categories{unionMember1=$unionMember1}" - strings != null -> "Categories{strings=$strings}" - unionMember3 != null -> "Categories{unionMember3=$unionMember3}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> + "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = + Categories(projectScoreCategories = projectScoreCategories) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Categories(unionMember1 = unionMember1) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic - fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Categories(unionMember3 = unionMember3) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } interface Visitor { fun visitProjectScoreCategories(projectScoreCategories: List): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitWeighted(weighted: Weighted): T fun visitStrings(strings: List): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember3 = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.strings != null -> generator.writeObject(value.strings) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.projectScoreCategories != null -> + generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For categorical-type project scores, defines a single category */ @JsonDeserialize(builder = ProjectScoreCategory.Builder::class) @NoAutoDetect - class ProjectScoreCategory private constructor(private val name: JsonField, private val value: JsonField, private val additionalProperties: Map, ) { + class ProjectScoreCategory + private constructor( + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -597,14 +574,10 @@ class ProjectScore private constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") - @ExcludeMissing - fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value() = value @JsonAnyGetter @ExcludeMissing @@ -612,42 +585,43 @@ class ProjectScore private constructor( fun validate(): ProjectScoreCategory = apply { if (!validated) { - name() - value() - validated = true + name() + value() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreCategory && - this.name == other.name && - this.value == other.value && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreCategory && + this.name == other.name && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -669,9 +643,7 @@ class ProjectScore private constructor( /** Name of the category */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) @@ -679,9 +651,7 @@ class ProjectScore private constructor( /** Numerical value of the category. Must be between 0 and 1, inclusive */ @JsonProperty("value") @ExcludeMissing - fun value(value: JsonField) = apply { - this.value = value - } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -693,22 +663,27 @@ class ProjectScore private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): ProjectScoreCategory = ProjectScoreCategory( - name, - value, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreCategory = + ProjectScoreCategory( + name, + value, + additionalProperties.toUnmodifiable(), + ) } } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val additionalProperties: Map, ) { + class Weighted + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -718,36 +693,34 @@ class ProjectScore private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.additionalProperties == other.additionalProperties + return other is Weighted && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -755,8 +728,8 @@ class ProjectScore private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - additionalProperties(unionMember1.additionalProperties) + internal fun from(weighted: Weighted) = apply { + additionalProperties(weighted.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -769,17 +742,21 @@ class ProjectScore private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember3 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -789,36 +766,35 @@ class ProjectScore private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -826,8 +802,8 @@ class ProjectScore private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - additionalProperties(unionMember3.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -840,34 +816,39 @@ class ProjectScore private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember3 = UnionMember3(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = Config.Builder::class) @NoAutoDetect - class Config private constructor(private val multiSelect: JsonField, private val destination: JsonField, private val additionalProperties: Map, ) { + class Config + private constructor( + private val multiSelect: JsonField, + private val destination: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun multiSelect(): Optional = Optional.ofNullable(multiSelect.getNullable("multi_select")) + fun multiSelect(): Optional = + Optional.ofNullable(multiSelect.getNullable("multi_select")) - fun destination(): Optional = Optional.ofNullable(destination.getNullable("destination")) + fun destination(): Optional = + Optional.ofNullable(destination.getNullable("destination")) - @JsonProperty("multi_select") - @ExcludeMissing - fun _multiSelect() = multiSelect + @JsonProperty("multi_select") @ExcludeMissing fun _multiSelect() = multiSelect - @JsonProperty("destination") - @ExcludeMissing - fun _destination() = destination + @JsonProperty("destination") @ExcludeMissing fun _destination() = destination @JsonAnyGetter @ExcludeMissing @@ -875,42 +856,43 @@ class ProjectScore private constructor( fun validate(): Config = apply { if (!validated) { - multiSelect() - destination() - validated = true + multiSelect() + destination() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && - this.multiSelect == other.multiSelect && - this.destination == other.destination && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Config && + this.multiSelect == other.multiSelect && + this.destination == other.destination && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - multiSelect, - destination, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + multiSelect, + destination, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Config{multiSelect=$multiSelect, destination=$destination, additionalProperties=$additionalProperties}" + override fun toString() = + "Config{multiSelect=$multiSelect, destination=$destination, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -956,25 +938,28 @@ class ProjectScore private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Config = Config( - multiSelect, - destination, - additionalProperties.toUnmodifiable(), - ) + fun build(): Config = + Config( + multiSelect, + destination, + additionalProperties.toUnmodifiable(), + ) } - class Destination @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Destination + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Destination && - this.value == other.value + return other is Destination && this.value == other.value } override fun hashCode() = value.hashCode() @@ -997,15 +982,17 @@ class ProjectScore private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - EXPECTED -> Value.EXPECTED - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + EXPECTED -> Value.EXPECTED + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - EXPECTED -> Known.EXPECTED - else -> throw BraintrustInvalidDataException("Unknown Destination: $value") - } + fun known(): Known = + when (this) { + EXPECTED -> Known.EXPECTED + else -> throw BraintrustInvalidDataException("Unknown Destination: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt index 7a31bb9..77cc1b8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt @@ -2,50 +2,42 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectScoreCreateParams constructor( - private val name: String, - private val projectId: String, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectScoreCreateParams +constructor( + private val name: String, + private val projectId: String, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -60,54 +52,47 @@ class ProjectScoreCreateParams constructor( @JvmSynthetic internal fun getBody(): ProjectScoreCreateBody { - return ProjectScoreCreateBody( - name, - projectId, - scoreType, - categories, - description, - additionalBodyProperties, - ) + return ProjectScoreCreateBody( + name, + projectId, + scoreType, + categories, + description, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ProjectScoreCreateBody.Builder::class) @NoAutoDetect - class ProjectScoreCreateBody internal constructor( - private val name: String?, - private val projectId: String?, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalProperties: Map, - + class ProjectScoreCreateBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the project score */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") - fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType - @JsonProperty("categories") - fun categories(): Categories? = categories + @JsonProperty("categories") fun categories(): Categories? = categories /** Textual description of the project score */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -116,39 +101,40 @@ class ProjectScoreCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreCreateBody && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -171,33 +157,22 @@ class ProjectScoreCreateParams constructor( } /** Name of the project score */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } @JsonProperty("categories") - fun categories(categories: Categories) = apply { - this.categories = categories - } + fun categories(categories: Categories) = apply { this.categories = categories } /** Textual description of the project score */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -213,18 +188,15 @@ class ProjectScoreCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScoreCreateBody = ProjectScoreCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - scoreType, - categories, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreCreateBody = + ProjectScoreCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + scoreType, + categories, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -235,42 +207,42 @@ class ProjectScoreCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreCreateParams && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -298,24 +270,16 @@ class ProjectScoreCreateParams constructor( } /** Name of the project score */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { - this.categories = categories - } + fun categories(categories: Categories) = apply { this.categories = categories } /** For categorical-type project scores, the list of all categories */ fun categories(projectScoreCategories: List) = apply { @@ -323,8 +287,8 @@ class ProjectScoreCreateParams constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(unionMember1: Categories.UnionMember1) = apply { - this.categories = Categories.ofUnionMember1(unionMember1) + fun categories(weighted: Categories.Weighted) = apply { + this.categories = Categories.ofWeighted(weighted) } /** For categorical-type project scores, the list of all categories */ @@ -333,14 +297,12 @@ class ProjectScoreCreateParams constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(unionMember3: UnionMember3) = apply { - this.categories = Categories.ofUnionMember3(unionMember3) + fun categories(nullableVariant: Categories.NullableVariant) = apply { + this.categories = Categories.ofNullableVariant(nullableVariant) } /** Textual description of the project score */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -380,9 +342,7 @@ class ProjectScoreCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -393,38 +353,38 @@ class ProjectScoreCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - scoreType, - categories, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreCreateParams = + ProjectScoreCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + scoreType, + categories, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && - this.value == other.value + return other is ScoreType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -459,181 +419,214 @@ class ProjectScoreCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( - private val projectScoreCategories: List? = null, - private val unionMember1: UnionMember1? = null, - private val strings: List? = null, - private val unionMember3: UnionMember3? = null, - private val _json: JsonValue? = null, - + class Categories + private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = Optional.ofNullable(projectScoreCategories) + fun projectScoreCategories(): Optional> = + Optional.ofNullable(projectScoreCategories) /** For weighted-type project scores, the weights of each score */ - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ fun strings(): Optional> = Optional.ofNullable(strings) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isUnionMember1(): Boolean = unionMember1 != null + + fun isWeighted(): Boolean = weighted != null + fun isStrings(): Boolean = strings != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asProjectScoreCategories(): List = + projectScoreCategories.getOrThrow("projectScoreCategories") + + fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + fun asStrings(): List = strings.getOrThrow("strings") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - strings != null -> visitor.visitStrings(strings) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> + visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if (projectScoreCategories == null && unionMember1 == null && strings == null && unionMember3 == null) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - unionMember1?.validate() - unionMember3?.validate() - validated = true + if ( + projectScoreCategories == null && + weighted == null && + strings == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.unionMember1 == other.unionMember1 && - this.strings == other.strings && - this.unionMember3 == other.unionMember3 + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - unionMember1, - strings, - unionMember3, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" - unionMember1 != null -> "Categories{unionMember1=$unionMember1}" - strings != null -> "Categories{strings=$strings}" - unionMember3 != null -> "Categories{unionMember3=$unionMember3}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> + "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = + Categories(projectScoreCategories = projectScoreCategories) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Categories(unionMember1 = unionMember1) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic - fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Categories(unionMember3 = unionMember3) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } interface Visitor { fun visitProjectScoreCategories(projectScoreCategories: List): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitWeighted(weighted: Weighted): T fun visitStrings(strings: List): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember3 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } - return Categories(_json = json) + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.strings != null -> generator.writeObject(value.strings) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.projectScoreCategories != null -> + generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For categorical-type project scores, defines a single category */ @JsonDeserialize(builder = ProjectScoreCategory.Builder::class) @NoAutoDetect - class ProjectScoreCategory private constructor(private val name: JsonField, private val value: JsonField, private val additionalProperties: Map, ) { + class ProjectScoreCategory + private constructor( + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -646,14 +639,10 @@ class ProjectScoreCreateParams constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") - @ExcludeMissing - fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value() = value @JsonAnyGetter @ExcludeMissing @@ -661,42 +650,43 @@ class ProjectScoreCreateParams constructor( fun validate(): ProjectScoreCategory = apply { if (!validated) { - name() - value() - validated = true + name() + value() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreCategory && - this.name == other.name && - this.value == other.value && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreCategory && + this.name == other.name && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -718,9 +708,7 @@ class ProjectScoreCreateParams constructor( /** Name of the category */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) @@ -728,9 +716,7 @@ class ProjectScoreCreateParams constructor( /** Numerical value of the category. Must be between 0 and 1, inclusive */ @JsonProperty("value") @ExcludeMissing - fun value(value: JsonField) = apply { - this.value = value - } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -742,22 +728,27 @@ class ProjectScoreCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectScoreCategory = ProjectScoreCategory( - name, - value, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ProjectScoreCategory = + ProjectScoreCategory( + name, + value, + additionalProperties.toUnmodifiable(), + ) } } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val additionalProperties: Map, ) { + class Weighted + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -767,36 +758,34 @@ class ProjectScoreCreateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.additionalProperties == other.additionalProperties + return other is Weighted && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -804,8 +793,8 @@ class ProjectScoreCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - additionalProperties(unionMember1.additionalProperties) + internal fun from(weighted: Weighted) = apply { + additionalProperties(weighted.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -818,17 +807,21 @@ class ProjectScoreCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember3 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -838,36 +831,35 @@ class ProjectScoreCreateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -875,8 +867,8 @@ class ProjectScoreCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - additionalProperties(unionMember3.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -889,11 +881,13 @@ class ProjectScoreCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember3 = UnionMember3(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index d94dd35..23ff689 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ProjectScoreDeleteParams constructor( - private val projectScoreId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectScoreDeleteParams +constructor( + private val projectScoreId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectScoreId(): String = projectScoreId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class ProjectScoreDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreDeleteParams && - this.projectScoreId == other.projectScoreId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreDeleteParams && + this.projectScoreId == other.projectScoreId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectScoreId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class ProjectScoreDeleteParams constructor( } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { - this.projectScoreId = projectScoreId - } + fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class ProjectScoreDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class ProjectScoreDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( - checkNotNull(projectScoreId) { - "`projectScoreId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectScoreDeleteParams = + ProjectScoreDeleteParams( + checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index a3e9842..f638afa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -2,79 +2,83 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.ProjectScoreService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.ProjectScore -import com.braintrustdata.api.services.blocking.ProjectScoreService -class ProjectScoreListPage private constructor(private val projectScoresService: ProjectScoreService, private val params: ProjectScoreListParams, private val response: Response, ) { +class ProjectScoreListPage +private constructor( + private val projectScoresService: ProjectScoreService, + private val params: ProjectScoreListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreListPage && - this.projectScoresService == other.projectScoresService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectScoreListPage && + this.projectScoresService == other.projectScoresService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectScoresService, - params, - response, - ) + return Objects.hash( + projectScoresService, + params, + response, + ) } - override fun toString() = "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = + "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectScoresService.list(it) } + return getNextPageParams().map { projectScoresService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +86,25 @@ class ProjectScoreListPage private constructor(private val projectScoresService: companion object { @JvmStatic - fun of(projectScoresService: ProjectScoreService, params: ProjectScoreListParams, response: Response) = ProjectScoreListPage( - projectScoresService, - params, - response, - ) + fun of( + projectScoresService: ProjectScoreService, + params: ProjectScoreListParams, + response: Response + ) = + ProjectScoreListPage( + projectScoresService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +119,33 @@ class ProjectScoreListPage private constructor(private val projectScoresService: fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ProjectScoreListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +173,25 @@ class ProjectScoreListPage private constructor(private val projectScoresService: } } - class AutoPager constructor(private val firstPage: ProjectScoreListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: ProjectScoreListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 194c8a1..961d901 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -2,83 +2,86 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.ProjectScoreServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.ProjectScore -import com.braintrustdata.api.services.async.ProjectScoreServiceAsync -class ProjectScoreListPageAsync private constructor(private val projectScoresService: ProjectScoreServiceAsync, private val params: ProjectScoreListParams, private val response: Response, ) { +class ProjectScoreListPageAsync +private constructor( + private val projectScoresService: ProjectScoreServiceAsync, + private val params: ProjectScoreListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreListPageAsync && - this.projectScoresService == other.projectScoresService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectScoreListPageAsync && + this.projectScoresService == other.projectScoresService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectScoresService, - params, - response, - ) + return Objects.hash( + projectScoresService, + params, + response, + ) } - override fun toString() = "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = + "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - projectScoresService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { projectScoresService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +89,25 @@ class ProjectScoreListPageAsync private constructor(private val projectScoresSer companion object { @JvmStatic - fun of(projectScoresService: ProjectScoreServiceAsync, params: ProjectScoreListParams, response: Response) = ProjectScoreListPageAsync( - projectScoresService, - params, - response, - ) + fun of( + projectScoresService: ProjectScoreServiceAsync, + params: ProjectScoreListParams, + response: Response + ) = + ProjectScoreListPageAsync( + projectScoresService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +122,33 @@ class ProjectScoreListPageAsync private constructor(private val projectScoresSer fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ProjectScoreListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +176,32 @@ class ProjectScoreListPageAsync private constructor(private val projectScoresSer } } - class AutoPager constructor(private val firstPage: ProjectScoreListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: ProjectScoreListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (ProjectScore) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (ProjectScore) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt index 795b65e..c5fca8c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt @@ -2,52 +2,36 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectScoreListParams constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val projectScoreName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectScoreListParams +constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val projectScoreName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -66,34 +50,19 @@ class ProjectScoreListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.projectScoreName?.let { - params.put("project_score_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.projectScoreName?.let { params.put("project_score_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -102,46 +71,46 @@ class ProjectScoreListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.projectScoreName == other.projectScoreName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.projectScoreName == other.projectScoreName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectName, - projectScoreName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectName, + projectScoreName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, projectScoreName=$projectScoreName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, projectScoreName=$projectScoreName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -175,52 +144,38 @@ class ProjectScoreListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** Name of the project_score to search for */ fun projectScoreName(projectScoreName: String) = apply { @@ -230,13 +185,11 @@ class ProjectScoreListParams constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -276,9 +229,7 @@ class ProjectScoreListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -289,88 +240,94 @@ class ProjectScoreListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectScoreListParams = ProjectScoreListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - projectScoreName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreListParams = + ProjectScoreListParams( + endingBefore, + ids, + limit, + orgName, + projectName, + projectScoreName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -380,34 +337,38 @@ class ProjectScoreListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt index c0627a6..797e567 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt @@ -2,50 +2,42 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectScoreReplaceParams constructor( - private val name: String, - private val projectId: String, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectScoreReplaceParams +constructor( + private val name: String, + private val projectId: String, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -60,54 +52,47 @@ class ProjectScoreReplaceParams constructor( @JvmSynthetic internal fun getBody(): ProjectScoreReplaceBody { - return ProjectScoreReplaceBody( - name, - projectId, - scoreType, - categories, - description, - additionalBodyProperties, - ) + return ProjectScoreReplaceBody( + name, + projectId, + scoreType, + categories, + description, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ProjectScoreReplaceBody.Builder::class) @NoAutoDetect - class ProjectScoreReplaceBody internal constructor( - private val name: String?, - private val projectId: String?, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalProperties: Map, - + class ProjectScoreReplaceBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the project score */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") - fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType - @JsonProperty("categories") - fun categories(): Categories? = categories + @JsonProperty("categories") fun categories(): Categories? = categories /** Textual description of the project score */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -116,39 +101,40 @@ class ProjectScoreReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreReplaceBody && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -171,33 +157,22 @@ class ProjectScoreReplaceParams constructor( } /** Name of the project score */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } @JsonProperty("categories") - fun categories(categories: Categories) = apply { - this.categories = categories - } + fun categories(categories: Categories) = apply { this.categories = categories } /** Textual description of the project score */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -213,18 +188,15 @@ class ProjectScoreReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScoreReplaceBody = ProjectScoreReplaceBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - scoreType, - categories, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreReplaceBody = + ProjectScoreReplaceBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + scoreType, + categories, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -235,42 +207,42 @@ class ProjectScoreReplaceParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreReplaceParams && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -298,24 +270,16 @@ class ProjectScoreReplaceParams constructor( } /** Name of the project score */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { - this.categories = categories - } + fun categories(categories: Categories) = apply { this.categories = categories } /** For categorical-type project scores, the list of all categories */ fun categories(projectScoreCategories: List) = apply { @@ -323,8 +287,8 @@ class ProjectScoreReplaceParams constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(unionMember1: Categories.UnionMember1) = apply { - this.categories = Categories.ofUnionMember1(unionMember1) + fun categories(weighted: Categories.Weighted) = apply { + this.categories = Categories.ofWeighted(weighted) } /** For categorical-type project scores, the list of all categories */ @@ -333,14 +297,12 @@ class ProjectScoreReplaceParams constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(unionMember3: UnionMember3) = apply { - this.categories = Categories.ofUnionMember3(unionMember3) + fun categories(nullableVariant: Categories.NullableVariant) = apply { + this.categories = Categories.ofNullableVariant(nullableVariant) } /** Textual description of the project score */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -380,9 +342,7 @@ class ProjectScoreReplaceParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -393,38 +353,38 @@ class ProjectScoreReplaceParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - scoreType, - categories, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreReplaceParams = + ProjectScoreReplaceParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + scoreType, + categories, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && - this.value == other.value + return other is ScoreType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -459,181 +419,214 @@ class ProjectScoreReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( - private val projectScoreCategories: List? = null, - private val unionMember1: UnionMember1? = null, - private val strings: List? = null, - private val unionMember3: UnionMember3? = null, - private val _json: JsonValue? = null, - + class Categories + private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = Optional.ofNullable(projectScoreCategories) + fun projectScoreCategories(): Optional> = + Optional.ofNullable(projectScoreCategories) /** For weighted-type project scores, the weights of each score */ - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ fun strings(): Optional> = Optional.ofNullable(strings) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isUnionMember1(): Boolean = unionMember1 != null + + fun isWeighted(): Boolean = weighted != null + fun isStrings(): Boolean = strings != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asProjectScoreCategories(): List = + projectScoreCategories.getOrThrow("projectScoreCategories") + + fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + fun asStrings(): List = strings.getOrThrow("strings") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - strings != null -> visitor.visitStrings(strings) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> + visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if (projectScoreCategories == null && unionMember1 == null && strings == null && unionMember3 == null) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - unionMember1?.validate() - unionMember3?.validate() - validated = true + if ( + projectScoreCategories == null && + weighted == null && + strings == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.unionMember1 == other.unionMember1 && - this.strings == other.strings && - this.unionMember3 == other.unionMember3 + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - unionMember1, - strings, - unionMember3, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" - unionMember1 != null -> "Categories{unionMember1=$unionMember1}" - strings != null -> "Categories{strings=$strings}" - unionMember3 != null -> "Categories{unionMember3=$unionMember3}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> + "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = + Categories(projectScoreCategories = projectScoreCategories) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Categories(unionMember1 = unionMember1) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic - fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Categories(unionMember3 = unionMember3) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } interface Visitor { fun visitProjectScoreCategories(projectScoreCategories: List): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitWeighted(weighted: Weighted): T fun visitStrings(strings: List): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember3 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } - return Categories(_json = json) + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.strings != null -> generator.writeObject(value.strings) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.projectScoreCategories != null -> + generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For categorical-type project scores, defines a single category */ @JsonDeserialize(builder = ProjectScoreCategory.Builder::class) @NoAutoDetect - class ProjectScoreCategory private constructor(private val name: JsonField, private val value: JsonField, private val additionalProperties: Map, ) { + class ProjectScoreCategory + private constructor( + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -646,14 +639,10 @@ class ProjectScoreReplaceParams constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") - @ExcludeMissing - fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value() = value @JsonAnyGetter @ExcludeMissing @@ -661,42 +650,43 @@ class ProjectScoreReplaceParams constructor( fun validate(): ProjectScoreCategory = apply { if (!validated) { - name() - value() - validated = true + name() + value() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreCategory && - this.name == other.name && - this.value == other.value && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreCategory && + this.name == other.name && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -718,9 +708,7 @@ class ProjectScoreReplaceParams constructor( /** Name of the category */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) @@ -728,9 +716,7 @@ class ProjectScoreReplaceParams constructor( /** Numerical value of the category. Must be between 0 and 1, inclusive */ @JsonProperty("value") @ExcludeMissing - fun value(value: JsonField) = apply { - this.value = value - } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -742,22 +728,27 @@ class ProjectScoreReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectScoreCategory = ProjectScoreCategory( - name, - value, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ProjectScoreCategory = + ProjectScoreCategory( + name, + value, + additionalProperties.toUnmodifiable(), + ) } } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val additionalProperties: Map, ) { + class Weighted + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -767,36 +758,34 @@ class ProjectScoreReplaceParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.additionalProperties == other.additionalProperties + return other is Weighted && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -804,8 +793,8 @@ class ProjectScoreReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - additionalProperties(unionMember1.additionalProperties) + internal fun from(weighted: Weighted) = apply { + additionalProperties(weighted.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -818,17 +807,21 @@ class ProjectScoreReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember3 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -838,36 +831,35 @@ class ProjectScoreReplaceParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -875,8 +867,8 @@ class ProjectScoreReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - additionalProperties(unionMember3.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -889,11 +881,13 @@ class ProjectScoreReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember3 = UnionMember3(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 9baf8cd..7ae207a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class ProjectScoreRetrieveParams constructor( - private val projectScoreId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectScoreRetrieveParams +constructor( + private val projectScoreId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectScoreId(): String = projectScoreId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class ProjectScoreRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreRetrieveParams && - this.projectScoreId == other.projectScoreId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreRetrieveParams && + this.projectScoreId == other.projectScoreId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectScoreId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class ProjectScoreRetrieveParams constructor( } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { - this.projectScoreId = projectScoreId - } + fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class ProjectScoreRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class ProjectScoreRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( - checkNotNull(projectScoreId) { - "`projectScoreId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectScoreRetrieveParams = + ProjectScoreRetrieveParams( + checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt index fb00489..0a78714 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt @@ -2,50 +2,42 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectScoreUpdateParams constructor( - private val projectScoreId: String, - private val categories: Categories?, - private val description: String?, - private val name: String?, - private val scoreType: ScoreType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectScoreUpdateParams +constructor( + private val projectScoreId: String, + private val categories: Categories?, + private val description: String?, + private val name: String?, + private val scoreType: ScoreType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectScoreId(): String = projectScoreId @@ -60,55 +52,49 @@ class ProjectScoreUpdateParams constructor( @JvmSynthetic internal fun getBody(): ProjectScoreUpdateBody { - return ProjectScoreUpdateBody( - categories, - description, - name, - scoreType, - additionalBodyProperties, - ) + return ProjectScoreUpdateBody( + categories, + description, + name, + scoreType, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } @JsonDeserialize(builder = ProjectScoreUpdateBody.Builder::class) @NoAutoDetect - class ProjectScoreUpdateBody internal constructor( - private val categories: Categories?, - private val description: String?, - private val name: String?, - private val scoreType: ScoreType?, - private val additionalProperties: Map, - + class ProjectScoreUpdateBody + internal constructor( + private val categories: Categories?, + private val description: String?, + private val name: String?, + private val scoreType: ScoreType?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("categories") - fun categories(): Categories? = categories + @JsonProperty("categories") fun categories(): Categories? = categories /** Textual description of the project score */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** Name of the project score */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** The type of the configured score */ - @JsonProperty("score_type") - fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType @JsonAnyGetter @ExcludeMissing @@ -117,37 +103,38 @@ class ProjectScoreUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreUpdateBody && - this.categories == other.categories && - this.description == other.description && - this.name == other.name && - this.scoreType == other.scoreType && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreUpdateBody && + this.categories == other.categories && + this.description == other.description && + this.name == other.name && + this.scoreType == other.scoreType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - categories, - description, - name, - scoreType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + categories, + description, + name, + scoreType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScoreUpdateBody{categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreUpdateBody{categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -168,27 +155,18 @@ class ProjectScoreUpdateParams constructor( } @JsonProperty("categories") - fun categories(categories: Categories) = apply { - this.categories = categories - } + fun categories(categories: Categories) = apply { this.categories = categories } /** Textual description of the project score */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the project score */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -204,13 +182,14 @@ class ProjectScoreUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScoreUpdateBody = ProjectScoreUpdateBody( - categories, - description, - name, - scoreType, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreUpdateBody = + ProjectScoreUpdateBody( + categories, + description, + name, + scoreType, + additionalProperties.toUnmodifiable(), + ) } } @@ -221,42 +200,42 @@ class ProjectScoreUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreUpdateParams && - this.projectScoreId == other.projectScoreId && - this.categories == other.categories && - this.description == other.description && - this.name == other.name && - this.scoreType == other.scoreType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreUpdateParams && + this.projectScoreId == other.projectScoreId && + this.categories == other.categories && + this.description == other.description && + this.name == other.name && + this.scoreType == other.scoreType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - categories, - description, - name, - scoreType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectScoreId, + categories, + description, + name, + scoreType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -284,14 +263,10 @@ class ProjectScoreUpdateParams constructor( } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { - this.projectScoreId = projectScoreId - } + fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { - this.categories = categories - } + fun categories(categories: Categories) = apply { this.categories = categories } /** For categorical-type project scores, the list of all categories */ fun categories(projectScoreCategories: List) = apply { @@ -299,8 +274,8 @@ class ProjectScoreUpdateParams constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(unionMember1: Categories.UnionMember1) = apply { - this.categories = Categories.ofUnionMember1(unionMember1) + fun categories(weighted: Categories.Weighted) = apply { + this.categories = Categories.ofWeighted(weighted) } /** For categorical-type project scores, the list of all categories */ @@ -309,24 +284,18 @@ class ProjectScoreUpdateParams constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(unionMember3: UnionMember3) = apply { - this.categories = Categories.ofUnionMember3(unionMember3) + fun categories(nullableVariant: Categories.NullableVariant) = apply { + this.categories = Categories.ofNullableVariant(nullableVariant) } /** Textual description of the project score */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the project score */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -366,9 +335,7 @@ class ProjectScoreUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -379,180 +346,211 @@ class ProjectScoreUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( - checkNotNull(projectScoreId) { - "`projectScoreId` is required but was not set" - }, - categories, - description, - name, - scoreType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreUpdateParams = + ProjectScoreUpdateParams( + checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, + categories, + description, + name, + scoreType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( - private val projectScoreCategories: List? = null, - private val unionMember1: UnionMember1? = null, - private val strings: List? = null, - private val unionMember3: UnionMember3? = null, - private val _json: JsonValue? = null, - + class Categories + private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = Optional.ofNullable(projectScoreCategories) + fun projectScoreCategories(): Optional> = + Optional.ofNullable(projectScoreCategories) /** For weighted-type project scores, the weights of each score */ - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ fun strings(): Optional> = Optional.ofNullable(strings) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isUnionMember1(): Boolean = unionMember1 != null + + fun isWeighted(): Boolean = weighted != null + fun isStrings(): Boolean = strings != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asProjectScoreCategories(): List = + projectScoreCategories.getOrThrow("projectScoreCategories") + + fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + fun asStrings(): List = strings.getOrThrow("strings") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - strings != null -> visitor.visitStrings(strings) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> + visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if (projectScoreCategories == null && unionMember1 == null && strings == null && unionMember3 == null) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - unionMember1?.validate() - unionMember3?.validate() - validated = true + if ( + projectScoreCategories == null && + weighted == null && + strings == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.unionMember1 == other.unionMember1 && - this.strings == other.strings && - this.unionMember3 == other.unionMember3 + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - unionMember1, - strings, - unionMember3, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" - unionMember1 != null -> "Categories{unionMember1=$unionMember1}" - strings != null -> "Categories{strings=$strings}" - unionMember3 != null -> "Categories{unionMember3=$unionMember3}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> + "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = + Categories(projectScoreCategories = projectScoreCategories) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Categories(unionMember1 = unionMember1) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic - fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Categories(unionMember3 = unionMember3) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } interface Visitor { fun visitProjectScoreCategories(projectScoreCategories: List): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitWeighted(weighted: Weighted): T fun visitStrings(strings: List): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(unionMember3 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } - return Categories(_json = json) + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.strings != null -> generator.writeObject(value.strings) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.projectScoreCategories != null -> + generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For categorical-type project scores, defines a single category */ @JsonDeserialize(builder = ProjectScoreCategory.Builder::class) @NoAutoDetect - class ProjectScoreCategory private constructor(private val name: JsonField, private val value: JsonField, private val additionalProperties: Map, ) { + class ProjectScoreCategory + private constructor( + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -565,14 +563,10 @@ class ProjectScoreUpdateParams constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") - @ExcludeMissing - fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value() = value @JsonAnyGetter @ExcludeMissing @@ -580,42 +574,43 @@ class ProjectScoreUpdateParams constructor( fun validate(): ProjectScoreCategory = apply { if (!validated) { - name() - value() - validated = true + name() + value() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreCategory && - this.name == other.name && - this.value == other.value && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreCategory && + this.name == other.name && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -637,9 +632,7 @@ class ProjectScoreUpdateParams constructor( /** Name of the category */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) @@ -647,9 +640,7 @@ class ProjectScoreUpdateParams constructor( /** Numerical value of the category. Must be between 0 and 1, inclusive */ @JsonProperty("value") @ExcludeMissing - fun value(value: JsonField) = apply { - this.value = value - } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -661,22 +652,27 @@ class ProjectScoreUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectScoreCategory = ProjectScoreCategory( - name, - value, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ProjectScoreCategory = + ProjectScoreCategory( + name, + value, + additionalProperties.toUnmodifiable(), + ) } } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val additionalProperties: Map, ) { + class Weighted + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -686,36 +682,34 @@ class ProjectScoreUpdateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.additionalProperties == other.additionalProperties + return other is Weighted && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -723,8 +717,8 @@ class ProjectScoreUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - additionalProperties(unionMember1.additionalProperties) + internal fun from(weighted: Weighted) = apply { + additionalProperties(weighted.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -737,17 +731,21 @@ class ProjectScoreUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember3 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -757,36 +755,35 @@ class ProjectScoreUpdateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember3{additionalProperties=$additionalProperties}" + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -794,8 +791,8 @@ class ProjectScoreUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - additionalProperties(unionMember3.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -808,27 +805,31 @@ class ProjectScoreUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember3 = UnionMember3(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } - class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && - this.value == other.value + return other is ScoreType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -863,21 +864,23 @@ class ProjectScoreUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index a89c375..61b80ba 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -2,53 +2,36 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException /** - * A project tag is a user-configured tag for tracking and filtering your - * experiments, logs, and other data + * A project tag is a user-configured tag for tracking and filtering your experiments, logs, and + * other data */ @JsonDeserialize(builder = ProjectTag.Builder::class) @NoAutoDetect -class ProjectTag private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val color: JsonField, - private val additionalProperties: Map, - +class ProjectTag +private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val color: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -70,44 +53,31 @@ class ProjectTag private constructor( fun name(): String = name.getRequired("name") /** Textual description of the project tag */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Color of the tag for the UI */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Unique identifier for the project tag */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** Date of project tag creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Textual description of the project tag */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun _color() = color + @JsonProperty("color") @ExcludeMissing fun _color() = color @JsonAnyGetter @ExcludeMissing @@ -115,57 +85,58 @@ class ProjectTag private constructor( fun validate(): ProjectTag = apply { if (!validated) { - id() - projectId() - userId() - created() - name() - description() - color() - validated = true + id() + projectId() + userId() + created() + name() + description() + color() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTag && - this.id == other.id && - this.projectId == other.projectId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.color == other.color && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTag && + this.id == other.id && + this.projectId == other.projectId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.color == other.color && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - projectId, - userId, - created, - name, - description, - color, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + projectId, + userId, + created, + name, + description, + color, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -195,11 +166,7 @@ class ProjectTag private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project tag */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -207,17 +174,13 @@ class ProjectTag private constructor( /** Unique identifier for the project that the project tag belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } fun userId(userId: String) = userId(JsonField.of(userId)) @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Date of project tag creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -225,9 +188,7 @@ class ProjectTag private constructor( /** Date of project tag creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) @@ -235,9 +196,7 @@ class ProjectTag private constructor( /** Name of the project tag */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the project tag */ fun description(description: String) = description(JsonField.of(description)) @@ -245,9 +204,7 @@ class ProjectTag private constructor( /** Textual description of the project tag */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** Color of the tag for the UI */ fun color(color: String) = color(JsonField.of(color)) @@ -255,9 +212,7 @@ class ProjectTag private constructor( /** Color of the tag for the UI */ @JsonProperty("color") @ExcludeMissing - fun color(color: JsonField) = apply { - this.color = color - } + fun color(color: JsonField) = apply { this.color = color } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -273,15 +228,16 @@ class ProjectTag private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTag = ProjectTag( - id, - projectId, - userId, - created, - name, - description, - color, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTag = + ProjectTag( + id, + projectId, + userId, + created, + name, + description, + color, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index cd42960..9275324 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -2,49 +2,27 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectTagCreateParams constructor( - private val name: String, - private val projectId: String, - private val color: String?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectTagCreateParams +constructor( + private val name: String, + private val projectId: String, + private val color: String?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -57,49 +35,43 @@ class ProjectTagCreateParams constructor( @JvmSynthetic internal fun getBody(): ProjectTagCreateBody { - return ProjectTagCreateBody( - name, - projectId, - color, - description, - additionalBodyProperties, - ) + return ProjectTagCreateBody( + name, + projectId, + color, + description, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ProjectTagCreateBody.Builder::class) @NoAutoDetect - class ProjectTagCreateBody internal constructor( - private val name: String?, - private val projectId: String?, - private val color: String?, - private val description: String?, - private val additionalProperties: Map, - + class ProjectTagCreateBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val color: String?, + private val description: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the project tag */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** Color of the tag for the UI */ - @JsonProperty("color") - fun color(): String? = color + @JsonProperty("color") fun color(): String? = color /** Textual description of the project tag */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -108,37 +80,38 @@ class ProjectTagCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTagCreateBody && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - projectId, - color, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + projectId, + color, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -159,28 +132,18 @@ class ProjectTagCreateParams constructor( } /** Name of the project tag */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Color of the tag for the UI */ - @JsonProperty("color") - fun color(color: String) = apply { - this.color = color - } + @JsonProperty("color") fun color(color: String) = apply { this.color = color } /** Textual description of the project tag */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -196,17 +159,14 @@ class ProjectTagCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTagCreateBody = ProjectTagCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - color, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTagCreateBody = + ProjectTagCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + color, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -217,40 +177,40 @@ class ProjectTagCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagCreateParams && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - color, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + color, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -276,24 +236,16 @@ class ProjectTagCreateParams constructor( } /** Name of the project tag */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Color of the tag for the UI */ - fun color(color: String) = apply { - this.color = color - } + fun color(color: String) = apply { this.color = color } /** Textual description of the project tag */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -333,9 +285,7 @@ class ProjectTagCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -346,22 +296,20 @@ class ProjectTagCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectTagCreateParams = ProjectTagCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - color, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectTagCreateParams = + ProjectTagCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + color, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 6a83753..26f9294 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class ProjectTagDeleteParams constructor( - private val projectTagId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectTagDeleteParams +constructor( + private val projectTagId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectTagId(): String = projectTagId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class ProjectTagDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagDeleteParams && - this.projectTagId == other.projectTagId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagDeleteParams && + this.projectTagId == other.projectTagId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectTagId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class ProjectTagDeleteParams constructor( } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { - this.projectTagId = projectTagId - } + fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class ProjectTagDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class ProjectTagDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( - checkNotNull(projectTagId) { - "`projectTagId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectTagDeleteParams = + ProjectTagDeleteParams( + checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 250f4a7..065e040 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -2,79 +2,83 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.ProjectTagService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.ProjectTag -import com.braintrustdata.api.services.blocking.ProjectTagService -class ProjectTagListPage private constructor(private val projectTagsService: ProjectTagService, private val params: ProjectTagListParams, private val response: Response, ) { +class ProjectTagListPage +private constructor( + private val projectTagsService: ProjectTagService, + private val params: ProjectTagListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagListPage && - this.projectTagsService == other.projectTagsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectTagListPage && + this.projectTagsService == other.projectTagsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectTagsService, - params, - response, - ) + return Objects.hash( + projectTagsService, + params, + response, + ) } - override fun toString() = "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = + "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectTagsService.list(it) } + return getNextPageParams().map { projectTagsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +86,25 @@ class ProjectTagListPage private constructor(private val projectTagsService: Pro companion object { @JvmStatic - fun of(projectTagsService: ProjectTagService, params: ProjectTagListParams, response: Response) = ProjectTagListPage( - projectTagsService, - params, - response, - ) + fun of( + projectTagsService: ProjectTagService, + params: ProjectTagListParams, + response: Response + ) = + ProjectTagListPage( + projectTagsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +119,33 @@ class ProjectTagListPage private constructor(private val projectTagsService: Pro fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ProjectTagListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectTagListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +173,25 @@ class ProjectTagListPage private constructor(private val projectTagsService: Pro } } - class AutoPager constructor(private val firstPage: ProjectTagListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: ProjectTagListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 82405b7..403a179 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -2,83 +2,86 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.ProjectTagServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.ProjectTag -import com.braintrustdata.api.services.async.ProjectTagServiceAsync -class ProjectTagListPageAsync private constructor(private val projectTagsService: ProjectTagServiceAsync, private val params: ProjectTagListParams, private val response: Response, ) { +class ProjectTagListPageAsync +private constructor( + private val projectTagsService: ProjectTagServiceAsync, + private val params: ProjectTagListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagListPageAsync && - this.projectTagsService == other.projectTagsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectTagListPageAsync && + this.projectTagsService == other.projectTagsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectTagsService, - params, - response, - ) + return Objects.hash( + projectTagsService, + params, + response, + ) } - override fun toString() = "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = + "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - projectTagsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { projectTagsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +89,25 @@ class ProjectTagListPageAsync private constructor(private val projectTagsService companion object { @JvmStatic - fun of(projectTagsService: ProjectTagServiceAsync, params: ProjectTagListParams, response: Response) = ProjectTagListPageAsync( - projectTagsService, - params, - response, - ) + fun of( + projectTagsService: ProjectTagServiceAsync, + params: ProjectTagListParams, + response: Response + ) = + ProjectTagListPageAsync( + projectTagsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +122,33 @@ class ProjectTagListPageAsync private constructor(private val projectTagsService fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ProjectTagListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectTagListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +176,32 @@ class ProjectTagListPageAsync private constructor(private val projectTagsService } } - class AutoPager constructor(private val firstPage: ProjectTagListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: ProjectTagListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (ProjectTag) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (ProjectTag) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 7d8e479..f3d6edb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -2,52 +2,36 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectTagListParams constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val projectTagName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectTagListParams +constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val projectTagName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -66,34 +50,19 @@ class ProjectTagListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.projectTagName?.let { - params.put("project_tag_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.projectTagName?.let { params.put("project_tag_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -102,46 +71,46 @@ class ProjectTagListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.projectTagName == other.projectTagName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.projectTagName == other.projectTagName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectName, - projectTagName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectName, + projectTagName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -175,68 +144,50 @@ class ProjectTagListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: String) = apply { - this.projectTagName = projectTagName - } + fun projectTagName(projectTagName: String) = apply { this.projectTagName = projectTagName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -276,9 +227,7 @@ class ProjectTagListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -289,88 +238,94 @@ class ProjectTagListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectTagListParams = ProjectTagListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - projectTagName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectTagListParams = + ProjectTagListParams( + endingBefore, + ids, + limit, + orgName, + projectName, + projectTagName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -380,34 +335,38 @@ class ProjectTagListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index dc663b1..28a4613 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -2,49 +2,27 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectTagReplaceParams constructor( - private val name: String, - private val projectId: String, - private val color: String?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectTagReplaceParams +constructor( + private val name: String, + private val projectId: String, + private val color: String?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -57,49 +35,43 @@ class ProjectTagReplaceParams constructor( @JvmSynthetic internal fun getBody(): ProjectTagReplaceBody { - return ProjectTagReplaceBody( - name, - projectId, - color, - description, - additionalBodyProperties, - ) + return ProjectTagReplaceBody( + name, + projectId, + color, + description, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ProjectTagReplaceBody.Builder::class) @NoAutoDetect - class ProjectTagReplaceBody internal constructor( - private val name: String?, - private val projectId: String?, - private val color: String?, - private val description: String?, - private val additionalProperties: Map, - + class ProjectTagReplaceBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val color: String?, + private val description: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the project tag */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** Color of the tag for the UI */ - @JsonProperty("color") - fun color(): String? = color + @JsonProperty("color") fun color(): String? = color /** Textual description of the project tag */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -108,37 +80,38 @@ class ProjectTagReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTagReplaceBody && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - projectId, - color, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + projectId, + color, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -159,28 +132,18 @@ class ProjectTagReplaceParams constructor( } /** Name of the project tag */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Color of the tag for the UI */ - @JsonProperty("color") - fun color(color: String) = apply { - this.color = color - } + @JsonProperty("color") fun color(color: String) = apply { this.color = color } /** Textual description of the project tag */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -196,17 +159,14 @@ class ProjectTagReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTagReplaceBody = ProjectTagReplaceBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - color, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTagReplaceBody = + ProjectTagReplaceBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + color, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -217,40 +177,40 @@ class ProjectTagReplaceParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagReplaceParams && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - color, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + color, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -276,24 +236,16 @@ class ProjectTagReplaceParams constructor( } /** Name of the project tag */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Color of the tag for the UI */ - fun color(color: String) = apply { - this.color = color - } + fun color(color: String) = apply { this.color = color } /** Textual description of the project tag */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -333,9 +285,7 @@ class ProjectTagReplaceParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -346,22 +296,20 @@ class ProjectTagReplaceParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - color, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectTagReplaceParams = + ProjectTagReplaceParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + color, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index e1cdbb7..89e2905 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class ProjectTagRetrieveParams constructor( - private val projectTagId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ProjectTagRetrieveParams +constructor( + private val projectTagId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectTagId(): String = projectTagId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class ProjectTagRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagRetrieveParams && - this.projectTagId == other.projectTagId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagRetrieveParams && + this.projectTagId == other.projectTagId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectTagId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class ProjectTagRetrieveParams constructor( } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { - this.projectTagId = projectTagId - } + fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class ProjectTagRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class ProjectTagRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( - checkNotNull(projectTagId) { - "`projectTagId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectTagRetrieveParams = + ProjectTagRetrieveParams( + checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 370c66b..e8f94d3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -2,49 +2,27 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectTagUpdateParams constructor( - private val projectTagId: String, - private val color: String?, - private val description: String?, - private val name: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectTagUpdateParams +constructor( + private val projectTagId: String, + private val color: String?, + private val description: String?, + private val name: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectTagId(): String = projectTagId @@ -57,50 +35,45 @@ class ProjectTagUpdateParams constructor( @JvmSynthetic internal fun getBody(): ProjectTagUpdateBody { - return ProjectTagUpdateBody( - color, - description, - name, - additionalBodyProperties, - ) + return ProjectTagUpdateBody( + color, + description, + name, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } @JsonDeserialize(builder = ProjectTagUpdateBody.Builder::class) @NoAutoDetect - class ProjectTagUpdateBody internal constructor( - private val color: String?, - private val description: String?, - private val name: String?, - private val additionalProperties: Map, - + class ProjectTagUpdateBody + internal constructor( + private val color: String?, + private val description: String?, + private val name: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Color of the tag for the UI */ - @JsonProperty("color") - fun color(): String? = color + @JsonProperty("color") fun color(): String? = color /** Textual description of the project tag */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** Name of the project tag */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name @JsonAnyGetter @ExcludeMissing @@ -109,35 +82,36 @@ class ProjectTagUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagUpdateBody && - this.color == other.color && - this.description == other.description && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTagUpdateBody && + this.color == other.color && + this.description == other.description && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - color, - description, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + color, + description, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -156,22 +130,14 @@ class ProjectTagUpdateParams constructor( } /** Color of the tag for the UI */ - @JsonProperty("color") - fun color(color: String) = apply { - this.color = color - } + @JsonProperty("color") fun color(color: String) = apply { this.color = color } /** Textual description of the project tag */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the project tag */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -187,12 +153,13 @@ class ProjectTagUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTagUpdateBody = ProjectTagUpdateBody( - color, - description, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTagUpdateBody = + ProjectTagUpdateBody( + color, + description, + name, + additionalProperties.toUnmodifiable(), + ) } } @@ -203,40 +170,40 @@ class ProjectTagUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagUpdateParams && - this.projectTagId == other.projectTagId && - this.color == other.color && - this.description == other.description && - this.name == other.name && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagUpdateParams && + this.projectTagId == other.projectTagId && + this.color == other.color && + this.description == other.description && + this.name == other.name && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - color, - description, - name, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectTagId, + color, + description, + name, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -262,24 +229,16 @@ class ProjectTagUpdateParams constructor( } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { - this.projectTagId = projectTagId - } + fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } /** Color of the tag for the UI */ - fun color(color: String) = apply { - this.color = color - } + fun color(color: String) = apply { this.color = color } /** Textual description of the project tag */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the project tag */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -319,9 +278,7 @@ class ProjectTagUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -332,20 +289,20 @@ class ProjectTagUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( - checkNotNull(projectTagId) { - "`projectTagId` is required but was not set" - }, - color, - description, - name, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectTagUpdateParams = + ProjectTagUpdateParams( + checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, + color, + description, + name, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index f45f7da..8b151a2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -2,48 +2,26 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ProjectUpdateParams constructor( - private val projectId: String, - private val name: String?, - private val settings: Settings?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectUpdateParams +constructor( + private val projectId: String, + private val name: String?, + private val settings: Settings?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -54,42 +32,43 @@ class ProjectUpdateParams constructor( @JvmSynthetic internal fun getBody(): ProjectUpdateBody { - return ProjectUpdateBody( - name, - settings, - additionalBodyProperties, - ) + return ProjectUpdateBody( + name, + settings, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectUpdateBody.Builder::class) @NoAutoDetect - class ProjectUpdateBody internal constructor(private val name: String?, private val settings: Settings?, private val additionalProperties: Map, ) { + class ProjectUpdateBody + internal constructor( + private val name: String?, + private val settings: Settings?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the project */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ - @JsonProperty("settings") - fun settings(): Settings? = settings + @JsonProperty("settings") fun settings(): Settings? = settings @JsonAnyGetter @ExcludeMissing @@ -98,33 +77,34 @@ class ProjectUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectUpdateBody && - this.name == other.name && - this.settings == other.settings && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectUpdateBody && + this.name == other.name && + this.settings == other.settings && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - settings, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + settings, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -141,19 +121,14 @@ class ProjectUpdateParams constructor( } /** Name of the project */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ @JsonProperty("settings") - fun settings(settings: Settings) = apply { - this.settings = settings - } + fun settings(settings: Settings) = apply { this.settings = settings } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -169,11 +144,12 @@ class ProjectUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectUpdateBody = ProjectUpdateBody( - name, - settings, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectUpdateBody = + ProjectUpdateBody( + name, + settings, + additionalProperties.toUnmodifiable(), + ) } } @@ -184,38 +160,38 @@ class ProjectUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectUpdateParams && - this.projectId == other.projectId && - this.name == other.name && - this.settings == other.settings && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectUpdateParams && + this.projectId == other.projectId && + this.name == other.name && + this.settings == other.settings && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - name, - settings, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + name, + settings, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -239,22 +215,16 @@ class ProjectUpdateParams constructor( } /** Project id */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Name of the project */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ - fun settings(settings: Settings) = apply { - this.settings = settings - } + fun settings(settings: Settings) = apply { this.settings = settings } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -294,9 +264,7 @@ class ProjectUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -307,35 +275,38 @@ class ProjectUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectUpdateParams = ProjectUpdateParams( - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - name, - settings, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectUpdateParams = + ProjectUpdateParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + name, + settings, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ @JsonDeserialize(builder = Settings.Builder::class) @NoAutoDetect - class Settings private constructor(private val comparisonKey: String?, private val additionalProperties: Map, ) { + class Settings + private constructor( + private val comparisonKey: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") - fun comparisonKey(): String? = comparisonKey + @JsonProperty("comparison_key") fun comparisonKey(): String? = comparisonKey @JsonAnyGetter @ExcludeMissing @@ -344,28 +315,28 @@ class ProjectUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Settings && - this.comparisonKey == other.comparisonKey && - this.additionalProperties == other.additionalProperties + return other is Settings && + this.comparisonKey == other.comparisonKey && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(comparisonKey, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(comparisonKey, additionalProperties) + } + return hashCode } - override fun toString() = "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + override fun toString() = + "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -381,9 +352,7 @@ class ProjectUpdateParams constructor( /** The key used to join two experiments (defaults to `input`). */ @JsonProperty("comparison_key") - fun comparisonKey(comparisonKey: String) = apply { - this.comparisonKey = comparisonKey - } + fun comparisonKey(comparisonKey: String) = apply { this.comparisonKey = comparisonKey } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 5160967..3b9cb7b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -2,54 +2,49 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect -class Prompt private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val additionalProperties: Map, - +class Prompt +private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val orgId: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val description: JsonField, + private val created: JsonField, + private val promptData: JsonField, + private val tags: JsonField>, + private val metadata: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -60,10 +55,9 @@ class Prompt private constructor( fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -83,13 +77,15 @@ class Prompt private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Date of prompt creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -98,69 +94,44 @@ class Prompt private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Unique identifier for the prompt */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun _logId() = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug() = slug + @JsonProperty("slug") @ExcludeMissing fun _slug() = slug /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun _promptData() = promptData + @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata @JsonAnyGetter @ExcludeMissing @@ -168,72 +139,73 @@ class Prompt private constructor( fun validate(): Prompt = apply { if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - validated = true + id() + _xactId() + projectId() + logId() + orgId() + name() + slug() + description() + created() + promptData().map { it.validate() } + tags() + metadata().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Prompt && + this.id == other.id && + this._xactId == other._xactId && + this.projectId == other.projectId && + this.logId == other.logId && + this.orgId == other.orgId && + this.name == other.name && + this.slug == other.slug && + this.description == other.description && + this.created == other.created && + this.promptData == other.promptData && + this.tags == other.tags && + this.metadata == other.metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags, + metadata, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -273,31 +245,23 @@ class Prompt private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -305,9 +269,7 @@ class Prompt private constructor( /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) @@ -315,9 +277,7 @@ class Prompt private constructor( /** A literal 'p' which identifies the object as a project prompt */ @JsonProperty("log_id") @ExcludeMissing - fun logId(logId: JsonField) = apply { - this.logId = logId - } + fun logId(logId: JsonField) = apply { this.logId = logId } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -325,9 +285,7 @@ class Prompt private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) @@ -335,9 +293,7 @@ class Prompt private constructor( /** Name of the prompt */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) @@ -345,9 +301,7 @@ class Prompt private constructor( /** Unique identifier for the prompt */ @JsonProperty("slug") @ExcludeMissing - fun slug(slug: JsonField) = apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String) = description(JsonField.of(description)) @@ -355,9 +309,7 @@ class Prompt private constructor( /** Textual description of the prompt */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** Date of prompt creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -365,9 +317,7 @@ class Prompt private constructor( /** Date of prompt creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) @@ -375,9 +325,7 @@ class Prompt private constructor( /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @ExcludeMissing - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -385,9 +333,7 @@ class Prompt private constructor( /** A list of tags for the prompt */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { - this.tags = tags - } + fun tags(tags: JsonField>) = apply { this.tags = tags } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -395,9 +341,7 @@ class Prompt private constructor( /** User-controlled metadata about the prompt */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -413,35 +357,38 @@ class Prompt private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - additionalProperties.toUnmodifiable(), - ) + fun build(): Prompt = + Prompt( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags.map { it.toUnmodifiable() }, + metadata, + additionalProperties.toUnmodifiable(), + ) } - class LogId @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class LogId + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is LogId && - this.value == other.value + return other is LogId && this.value == other.value } override fun hashCode() = value.hashCode() @@ -464,15 +411,17 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - P -> Value.P - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + P -> Value.P + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } + fun known(): Known = + when (this) { + P -> Known.P + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -480,7 +429,10 @@ class Prompt private constructor( /** User-controlled metadata about the prompt */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { + class Metadata + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -492,34 +444,32 @@ class Prompt private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && - this.additionalProperties == other.additionalProperties + return other is Metadata && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -552,12 +502,12 @@ class Prompt private constructor( /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: JsonField, + private val options: JsonField, + private val origin: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -570,17 +520,11 @@ class Prompt private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - @JsonProperty("prompt") - @ExcludeMissing - fun _prompt() = prompt + @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - @JsonProperty("options") - @ExcludeMissing - fun _options() = options + @JsonProperty("options") @ExcludeMissing fun _options() = options - @JsonProperty("origin") - @ExcludeMissing - fun _origin() = origin + @JsonProperty("origin") @ExcludeMissing fun _origin() = origin @JsonAnyGetter @ExcludeMissing @@ -588,45 +532,46 @@ class Prompt private constructor( fun validate(): PromptData = apply { if (!validated) { - prompt() - options().map { it.validate() } - origin().map { it.validate() } - validated = true + prompt() + options().map { it.validate() } + origin().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -648,25 +593,19 @@ class Prompt private constructor( @JsonProperty("prompt") @ExcludeMissing - fun prompt(prompt: JsonField) = apply { - this.prompt = prompt - } + fun prompt(prompt: JsonField) = apply { this.prompt = prompt } fun options(options: Options) = options(JsonField.of(options)) @JsonProperty("options") @ExcludeMissing - fun options(options: JsonField) = apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } fun origin(origin: Origin) = origin(JsonField.of(origin)) @JsonProperty("origin") @ExcludeMissing - fun origin(origin: JsonField) = apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -682,22 +621,23 @@ class Prompt private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: JsonField, + private val params: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -710,17 +650,11 @@ class Prompt private constructor( fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - @JsonProperty("model") - @ExcludeMissing - fun _model() = model + @JsonProperty("model") @ExcludeMissing fun _model() = model - @JsonProperty("params") - @ExcludeMissing - fun _params() = params + @JsonProperty("params") @ExcludeMissing fun _params() = params - @JsonProperty("position") - @ExcludeMissing - fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -728,45 +662,46 @@ class Prompt private constructor( fun validate(): Options = apply { if (!validated) { - model() - params() - position() - validated = true + model() + params() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -788,25 +723,19 @@ class Prompt private constructor( @JsonProperty("model") @ExcludeMissing - fun model(model: JsonField) = apply { - this.model = model - } + fun model(model: JsonField) = apply { this.model = model } fun params(params: Params) = params(JsonField.of(params)) @JsonProperty("params") @ExcludeMissing - fun params(params: JsonField) = apply { - this.params = params - } + fun params(params: JsonField) = apply { this.params = params } fun position(position: String) = position(JsonField.of(position)) @JsonProperty("position") @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } + fun position(position: JsonField) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -818,245 +747,307 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun isOpenAIModelParams(): Boolean = openaiModelParams != null + + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null + + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") + + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -1070,91 +1061,86 @@ class Prompt private constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1170,22 +1156,23 @@ class Prompt private constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -1196,7 +1183,8 @@ class Prompt private constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -1208,9 +1196,7 @@ class Prompt private constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -1220,7 +1206,8 @@ class Prompt private constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -1228,7 +1215,8 @@ class Prompt private constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -1236,7 +1224,8 @@ class Prompt private constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -1244,7 +1233,8 @@ class Prompt private constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -1252,7 +1242,8 @@ class Prompt private constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -1264,190 +1255,202 @@ class Prompt private constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun asAuto(): Auto = auto.getOrThrow("auto") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1456,9 +1459,9 @@ class Prompt private constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1470,31 +1473,37 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1503,9 +1512,9 @@ class Prompt private constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1517,22 +1526,29 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1540,68 +1556,68 @@ class Prompt private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1611,18 +1627,23 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1630,9 +1651,7 @@ class Prompt private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1640,42 +1659,43 @@ class Prompt private constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -1687,39 +1707,42 @@ class Prompt private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1742,15 +1765,18 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1758,146 +1784,160 @@ class Prompt private constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun none(): Optional = Optional.ofNullable(none) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1906,9 +1946,9 @@ class Prompt private constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1920,31 +1960,37 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1953,9 +1999,9 @@ class Prompt private constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1967,22 +2013,30 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1992,78 +2046,75 @@ class Prompt private constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -2073,7 +2124,9 @@ class Prompt private constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -2083,20 +2136,25 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2104,52 +2162,53 @@ class Prompt private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -2161,40 +2220,47 @@ class Prompt private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2217,15 +2283,20 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -2233,25 +2304,26 @@ class Prompt private constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -2261,30 +2333,22 @@ class Prompt private constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -2299,59 +2363,60 @@ class Prompt private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2363,18 +2428,19 @@ class Prompt private constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2393,7 +2459,8 @@ class Prompt private constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2405,19 +2472,16 @@ class Prompt private constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -2426,7 +2490,8 @@ class Prompt private constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -2435,130 +2500,128 @@ class Prompt private constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2568,16 +2631,17 @@ class Prompt private constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2588,7 +2652,8 @@ class Prompt private constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2596,7 +2661,8 @@ class Prompt private constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -2608,120 +2674,115 @@ class Prompt private constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2729,14 +2790,15 @@ class Prompt private constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2747,7 +2809,8 @@ class Prompt private constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2759,94 +2822,98 @@ class Prompt private constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2857,21 +2924,23 @@ class Prompt private constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -2879,35 +2948,32 @@ class Prompt private constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: JsonField, + private val projectId: JsonField, + private val promptVersion: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) + fun promptId(): Optional = + Optional.ofNullable(promptId.getNullable("prompt_id")) - fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) + fun projectId(): Optional = + Optional.ofNullable(projectId.getNullable("project_id")) - fun promptVersion(): Optional = Optional.ofNullable(promptVersion.getNullable("prompt_version")) + fun promptVersion(): Optional = + Optional.ofNullable(promptVersion.getNullable("prompt_version")) - @JsonProperty("prompt_id") - @ExcludeMissing - fun _promptId() = promptId + @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - @JsonProperty("prompt_version") - @ExcludeMissing - fun _promptVersion() = promptVersion + @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion @JsonAnyGetter @ExcludeMissing @@ -2915,45 +2981,46 @@ class Prompt private constructor( fun validate(): Origin = apply { if (!validated) { - promptId() - projectId() - promptVersion() - validated = true + promptId() + projectId() + promptVersion() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2975,19 +3042,16 @@ class Prompt private constructor( @JsonProperty("prompt_id") @ExcludeMissing - fun promptId(promptId: JsonField) = apply { - this.promptId = promptId - } + fun promptId(promptId: JsonField) = apply { this.promptId = promptId } fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) + fun promptVersion(promptVersion: String) = + promptVersion(JsonField.of(promptVersion)) @JsonProperty("prompt_version") @ExcludeMissing @@ -3005,154 +3069,175 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isCompletion(): Boolean = completion != null + + fun isChat(): Boolean = chat != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asCompletion(): Completion = completion.getOrThrow("completion") + + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3162,56 +3247,53 @@ class Prompt private constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3221,27 +3303,23 @@ class Prompt private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3253,29 +3331,34 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3298,28 +3381,30 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -3332,63 +3417,58 @@ class Prompt private constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3399,20 +3479,18 @@ class Prompt private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -3426,9 +3504,7 @@ class Prompt private constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3440,281 +3516,306 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3722,14 +3823,15 @@ class Prompt private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -3744,52 +3846,53 @@ class Prompt private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3812,97 +3915,96 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3910,14 +4012,15 @@ class Prompt private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -3932,52 +4035,53 @@ class Prompt private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4000,304 +4104,410 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent6s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent6s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent6s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent6s) + + fun unnamedSchemaWithArrayParent6s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent6s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent6s(): Boolean = unnamedSchemaWithArrayParent6s != null + + fun isUnnamedSchemaWithArrayParent6s(): Boolean = + unnamedSchemaWithArrayParent6s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent6s(): List = unnamedSchemaWithArrayParent6s.getOrThrow("unnamedSchemaWithArrayParent6s") + + fun asUnnamedSchemaWithArrayParent6s(): + List = + unnamedSchemaWithArrayParent6s.getOrThrow( + "unnamedSchemaWithArrayParent6s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent6s != null -> visitor.visitUnnamedSchemaWithArrayParent6s(unnamedSchemaWithArrayParent6s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent6s != null -> + visitor.visitUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent6s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent6s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent6s == other.unnamedSchemaWithArrayParent6s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent6s == + other.unnamedSchemaWithArrayParent6s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent6s) + return Objects.hash(string, unnamedSchemaWithArrayParent6s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent6s != null -> "Content{unnamedSchemaWithArrayParent6s=$unnamedSchemaWithArrayParent6s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent6s != null -> + "Content{unnamedSchemaWithArrayParent6s=$unnamedSchemaWithArrayParent6s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent6s(unnamedSchemaWithArrayParent6s: List) = Content(unnamedSchemaWithArrayParent6s = unnamedSchemaWithArrayParent6s) + fun ofUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s: + List + ) = + Content( + unnamedSchemaWithArrayParent6s = + unnamedSchemaWithArrayParent6s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent6s(unnamedSchemaWithArrayParent6s: List): T + fun visitUnnamedSchemaWithArrayParent6s( + unnamedSchemaWithArrayParent6s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent6s = it, _json = json) - } - - return Content(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent6s = it, + _json = json + ) + } + + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent6s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent6s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent6s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent6s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent6.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent6.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent6.Serializer::class) - class UnnamedSchemaWithArrayParent6 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent6 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) + + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) + + fun isText(): Boolean = text != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isImageUrl(): Boolean = imageUrl != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asText(): Text = text.getOrThrow("text") + + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent6 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent6: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent6: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent6 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent6 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent6{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent6{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent6{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent6") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent6{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent6{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent6{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent6(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent6(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent6(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent6(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent6: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent6: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent6::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent6 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent6(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent6(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent6 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent6( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent6( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent6(_json = json) + return UnnamedSchemaWithArrayParent6(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent6::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent6, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent6") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent6, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -4312,43 +4522,50 @@ class Prompt private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4359,7 +4576,8 @@ class Prompt private constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4371,23 +4589,33 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4401,68 +4629,71 @@ class Prompt private constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -4474,34 +4705,43 @@ class Prompt private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4509,11 +4749,10 @@ class Prompt private constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -4521,53 +4760,58 @@ class Prompt private constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -4584,7 +4828,8 @@ class Prompt private constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -4592,39 +4837,52 @@ class Prompt private constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4639,7 +4897,8 @@ class Prompt private constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -4655,36 +4914,44 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4693,9 +4960,11 @@ class Prompt private constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4707,15 +4976,20 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -4724,16 +4998,16 @@ class Prompt private constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4742,85 +5016,81 @@ class Prompt private constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4830,25 +5100,24 @@ class Prompt private constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -4858,7 +5127,8 @@ class Prompt private constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -4870,11 +5140,10 @@ class Prompt private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -4882,42 +5151,47 @@ class Prompt private constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4940,22 +5214,30 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4965,63 +5247,62 @@ class Prompt private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -5030,7 +5311,8 @@ class Prompt private constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -5042,11 +5324,11 @@ class Prompt private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -5056,26 +5338,27 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -5088,63 +5371,59 @@ class Prompt private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5152,7 +5431,8 @@ class Prompt private constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -5166,9 +5446,7 @@ class Prompt private constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -5182,11 +5460,11 @@ class Prompt private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -5196,21 +5474,27 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5224,59 +5508,61 @@ class Prompt private constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -5285,7 +5571,8 @@ class Prompt private constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -5297,44 +5584,51 @@ class Prompt private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5357,98 +5651,100 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5456,14 +5752,15 @@ class Prompt private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5478,11 +5775,10 @@ class Prompt private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -5490,40 +5786,45 @@ class Prompt private constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5546,97 +5847,96 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5644,14 +5944,15 @@ class Prompt private constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5666,52 +5967,53 @@ class Prompt private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5734,23 +6036,31 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5758,80 +6068,77 @@ class Prompt private constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -5841,39 +6148,44 @@ class Prompt private constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5896,33 +6208,39 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5945,23 +6263,28 @@ class Prompt private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5971,36 +6294,36 @@ class Prompt private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -6008,8 +6331,8 @@ class Prompt private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -6022,11 +6345,13 @@ class Prompt private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 9ae6b40..39ea06d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -2,51 +2,43 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class PromptCreateParams constructor( - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class PromptCreateParams +constructor( + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -63,61 +55,53 @@ class PromptCreateParams constructor( @JvmSynthetic internal fun getBody(): PromptCreateBody { - return PromptCreateBody( - name, - projectId, - slug, - description, - promptData, - tags, - additionalBodyProperties, - ) + return PromptCreateBody( + name, + projectId, + slug, + description, + promptData, + tags, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = PromptCreateBody.Builder::class) @NoAutoDetect - class PromptCreateBody internal constructor( - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, - + class PromptCreateBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the prompt */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(): String? = slug + @JsonProperty("slug") fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(): List? = tags + @JsonProperty("tags") fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -126,41 +110,42 @@ class PromptCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptCreateBody && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - projectId, - slug, - description, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + projectId, + slug, + description, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -185,40 +170,25 @@ class PromptCreateParams constructor( } /** Name of the prompt */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(slug: String) = apply { - this.slug = slug - } + @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(tags: List) = apply { - this.tags = tags - } + @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -234,21 +204,16 @@ class PromptCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptCreateBody = PromptCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptCreateBody = + PromptCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -259,44 +224,44 @@ class PromptCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptCreateParams && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - slug, - description, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + slug, + description, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -326,29 +291,19 @@ class PromptCreateParams constructor( } /** Name of the prompt */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { - this.slug = slug - } + fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -357,9 +312,7 @@ class PromptCreateParams constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - this.tags.add(tag) - } + fun addTag(tag: String) = apply { this.tags.add(tag) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -399,9 +352,7 @@ class PromptCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -412,50 +363,43 @@ class PromptCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): PromptCreateParams = PromptCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - if(tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): PromptCreateParams = + PromptCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + if (tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: Prompt?, - private val options: Options?, - private val origin: Origin?, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: Prompt?, + private val options: Options?, + private val origin: Origin?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt") - fun prompt(): Prompt? = prompt + @JsonProperty("prompt") fun prompt(): Prompt? = prompt - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options - @JsonProperty("origin") - fun origin(): Origin? = origin + @JsonProperty("origin") fun origin(): Origin? = origin @JsonAnyGetter @ExcludeMissing @@ -464,35 +408,36 @@ class PromptCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -510,20 +455,12 @@ class PromptCreateParams constructor( additionalProperties(promptData.additionalProperties) } - @JsonProperty("prompt") - fun prompt(prompt: Prompt) = apply { - this.prompt = prompt - } + @JsonProperty("prompt") fun prompt(prompt: Prompt) = apply { this.prompt = prompt } @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } - @JsonProperty("origin") - fun origin(origin: Origin) = apply { - this.origin = origin - } + @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -539,34 +476,32 @@ class PromptCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: String?, - private val params: Params?, - private val position: String?, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: String?, + private val params: Params?, + private val position: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("model") - fun model(): String? = model + @JsonProperty("model") fun model(): String? = model - @JsonProperty("params") - fun params(): Params? = params + @JsonProperty("params") fun params(): Params? = params - @JsonProperty("position") - fun position(): String? = position + @JsonProperty("position") fun position(): String? = position @JsonAnyGetter @ExcludeMissing @@ -575,35 +510,36 @@ class PromptCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -621,20 +557,12 @@ class PromptCreateParams constructor( additionalProperties(options.additionalProperties) } - @JsonProperty("model") - fun model(model: String) = apply { - this.model = model - } + @JsonProperty("model") fun model(model: String) = apply { this.model = model } - @JsonProperty("params") - fun params(params: Params) = apply { - this.params = params - } + @JsonProperty("params") fun params(params: Params) = apply { this.params = params } @JsonProperty("position") - fun position(position: String) = apply { - this.position = position - } + fun position(position: String) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -646,245 +574,307 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) + + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun isOpenAIModelParams(): Boolean = openaiModelParams != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null + + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") + + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -898,91 +888,86 @@ class PromptCreateParams constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -998,22 +983,23 @@ class PromptCreateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -1024,7 +1010,8 @@ class PromptCreateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -1036,9 +1023,7 @@ class PromptCreateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -1048,7 +1033,8 @@ class PromptCreateParams constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -1056,7 +1042,8 @@ class PromptCreateParams constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -1064,7 +1051,8 @@ class PromptCreateParams constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -1072,7 +1060,8 @@ class PromptCreateParams constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -1080,7 +1069,8 @@ class PromptCreateParams constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -1092,190 +1082,202 @@ class PromptCreateParams constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun asNone(): None = none.getOrThrow("none") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1284,9 +1286,9 @@ class PromptCreateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1298,31 +1300,37 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1331,9 +1339,9 @@ class PromptCreateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1345,22 +1353,29 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1368,68 +1383,68 @@ class PromptCreateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1439,18 +1454,23 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1458,9 +1478,7 @@ class PromptCreateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1468,42 +1486,43 @@ class PromptCreateParams constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -1515,39 +1534,42 @@ class PromptCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1570,15 +1592,18 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1586,146 +1611,160 @@ class PromptCreateParams constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun function(): Optional = Optional.ofNullable(function) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1734,9 +1773,9 @@ class PromptCreateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1748,31 +1787,37 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1781,9 +1826,9 @@ class PromptCreateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1795,22 +1840,30 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1820,78 +1873,75 @@ class PromptCreateParams constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -1901,7 +1951,9 @@ class PromptCreateParams constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1911,20 +1963,25 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1932,52 +1989,53 @@ class PromptCreateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -1989,40 +2047,47 @@ class PromptCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2045,15 +2110,20 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -2061,25 +2131,26 @@ class PromptCreateParams constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -2089,30 +2160,22 @@ class PromptCreateParams constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -2127,59 +2190,60 @@ class PromptCreateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2191,18 +2255,19 @@ class PromptCreateParams constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2221,7 +2286,8 @@ class PromptCreateParams constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2233,19 +2299,16 @@ class PromptCreateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -2254,7 +2317,8 @@ class PromptCreateParams constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -2263,130 +2327,128 @@ class PromptCreateParams constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2396,16 +2458,17 @@ class PromptCreateParams constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2416,7 +2479,8 @@ class PromptCreateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2424,7 +2488,8 @@ class PromptCreateParams constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -2436,120 +2501,115 @@ class PromptCreateParams constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2557,14 +2617,15 @@ class PromptCreateParams constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2575,7 +2636,8 @@ class PromptCreateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2587,94 +2649,98 @@ class PromptCreateParams constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2685,21 +2751,23 @@ class PromptCreateParams constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -2707,24 +2775,21 @@ class PromptCreateParams constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: String?, - private val projectId: String?, - private val promptVersion: String?, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: String?, + private val projectId: String?, + private val promptVersion: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt_id") - fun promptId(): String? = promptId + @JsonProperty("prompt_id") fun promptId(): String? = promptId - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId - @JsonProperty("prompt_version") - fun promptVersion(): String? = promptVersion + @JsonProperty("prompt_version") fun promptVersion(): String? = promptVersion @JsonAnyGetter @ExcludeMissing @@ -2733,35 +2798,36 @@ class PromptCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2780,14 +2846,10 @@ class PromptCreateParams constructor( } @JsonProperty("prompt_id") - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } @JsonProperty("prompt_version") fun promptVersion(promptVersion: String) = apply { @@ -2804,154 +2866,175 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isCompletion(): Boolean = completion != null + + fun isChat(): Boolean = chat != null + + fun isNullableVariant(): Boolean = nullableVariant != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun asCompletion(): Completion = completion.getOrThrow("completion") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2961,56 +3044,53 @@ class PromptCreateParams constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3020,27 +3100,23 @@ class PromptCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3052,29 +3128,34 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3097,28 +3178,30 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -3131,63 +3214,58 @@ class PromptCreateParams constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3198,20 +3276,18 @@ class PromptCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -3225,9 +3301,7 @@ class PromptCreateParams constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3239,281 +3313,306 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3521,14 +3620,15 @@ class PromptCreateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -3543,52 +3643,53 @@ class PromptCreateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3611,97 +3712,96 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3709,14 +3809,15 @@ class PromptCreateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -3731,52 +3832,53 @@ class PromptCreateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3799,304 +3901,410 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent0s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent0s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent0s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent0s) + + fun unnamedSchemaWithArrayParent0s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent0s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent0s(): Boolean = unnamedSchemaWithArrayParent0s != null + + fun isUnnamedSchemaWithArrayParent0s(): Boolean = + unnamedSchemaWithArrayParent0s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent0s(): List = unnamedSchemaWithArrayParent0s.getOrThrow("unnamedSchemaWithArrayParent0s") + + fun asUnnamedSchemaWithArrayParent0s(): + List = + unnamedSchemaWithArrayParent0s.getOrThrow( + "unnamedSchemaWithArrayParent0s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent0s != null -> visitor.visitUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent0s != null -> + visitor.visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent0s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent0s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent0s == other.unnamedSchemaWithArrayParent0s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent0s == + other.unnamedSchemaWithArrayParent0s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent0s) + return Objects.hash(string, unnamedSchemaWithArrayParent0s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent0s != null -> "Content{unnamedSchemaWithArrayParent0s=$unnamedSchemaWithArrayParent0s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent0s != null -> + "Content{unnamedSchemaWithArrayParent0s=$unnamedSchemaWithArrayParent0s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s: List) = Content(unnamedSchemaWithArrayParent0s = unnamedSchemaWithArrayParent0s) + fun ofUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: + List + ) = + Content( + unnamedSchemaWithArrayParent0s = + unnamedSchemaWithArrayParent0s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s: List): T + fun visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent0s = it, _json = json) - } - - return Content(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent0s = it, + _json = json + ) + } + + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent0s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent0s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent0s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent0s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent0.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent0.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) - class UnnamedSchemaWithArrayParent0 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent0 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) + + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) + + fun isText(): Boolean = text != null + + fun isImageUrl(): Boolean = imageUrl != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun asText(): Text = text.getOrThrow("text") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent0 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent0: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent0: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent0 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent0 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent0{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent0{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent0{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent0{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent0{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent0" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent0(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent0(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent0(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent0(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent0: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent0: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent0::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent0 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent0(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent0(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent0 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent0( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent0( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent0(_json = json) + return UnnamedSchemaWithArrayParent0(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent0::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent0, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent0, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent0" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -4111,43 +4319,50 @@ class PromptCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4158,7 +4373,8 @@ class PromptCreateParams constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4170,23 +4386,33 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4200,68 +4426,71 @@ class PromptCreateParams constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -4273,34 +4502,43 @@ class PromptCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4308,11 +4546,10 @@ class PromptCreateParams constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -4320,53 +4557,58 @@ class PromptCreateParams constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -4383,7 +4625,8 @@ class PromptCreateParams constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -4391,39 +4634,52 @@ class PromptCreateParams constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4438,7 +4694,8 @@ class PromptCreateParams constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -4454,36 +4711,44 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4492,9 +4757,11 @@ class PromptCreateParams constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4506,15 +4773,20 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -4523,16 +4795,16 @@ class PromptCreateParams constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4541,85 +4813,81 @@ class PromptCreateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4629,25 +4897,24 @@ class PromptCreateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -4657,7 +4924,8 @@ class PromptCreateParams constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -4669,11 +4937,10 @@ class PromptCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -4681,42 +4948,47 @@ class PromptCreateParams constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4739,22 +5011,30 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4764,63 +5044,62 @@ class PromptCreateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -4829,7 +5108,8 @@ class PromptCreateParams constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -4841,11 +5121,11 @@ class PromptCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -4855,26 +5135,27 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4887,63 +5168,59 @@ class PromptCreateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4951,7 +5228,8 @@ class PromptCreateParams constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -4965,9 +5243,7 @@ class PromptCreateParams constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -4981,11 +5257,11 @@ class PromptCreateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -4995,21 +5271,27 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5023,59 +5305,61 @@ class PromptCreateParams constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -5084,7 +5368,8 @@ class PromptCreateParams constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -5096,44 +5381,51 @@ class PromptCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5156,98 +5448,100 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5255,14 +5549,15 @@ class PromptCreateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5277,11 +5572,10 @@ class PromptCreateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -5289,40 +5583,45 @@ class PromptCreateParams constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5345,97 +5644,96 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5443,14 +5741,15 @@ class PromptCreateParams constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5465,52 +5764,53 @@ class PromptCreateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5533,23 +5833,31 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5557,80 +5865,77 @@ class PromptCreateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -5640,39 +5945,44 @@ class PromptCreateParams constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5695,33 +6005,39 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5744,23 +6060,28 @@ class PromptCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5770,36 +6091,36 @@ class PromptCreateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5807,8 +6128,8 @@ class PromptCreateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -5821,11 +6142,13 @@ class PromptCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index c4bb185..586d384 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class PromptDeleteParams constructor( - private val promptId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class PromptDeleteParams +constructor( + private val promptId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun promptId(): String = promptId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class PromptDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptDeleteParams && - this.promptId == other.promptId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptDeleteParams && + this.promptId == other.promptId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - promptId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + promptId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "PromptDeleteParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "PromptDeleteParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class PromptDeleteParams constructor( } /** Prompt id */ - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class PromptDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class PromptDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): PromptDeleteParams = PromptDeleteParams( - checkNotNull(promptId) { - "`promptId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): PromptDeleteParams = + PromptDeleteParams( + checkNotNull(promptId) { "`promptId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptFeedbackParams.kt deleted file mode 100644 index 2ac7d10..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptFeedbackParams.kt +++ /dev/null @@ -1,562 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class PromptFeedbackParams constructor( - private val promptId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - -) { - - fun promptId(): String = promptId - - fun feedback(): List = feedback - - @JvmSynthetic - internal fun getBody(): PromptFeedbackBody { - return PromptFeedbackBody(feedback, additionalBodyProperties) - } - - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams - - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } - } - - @JsonDeserialize(builder = PromptFeedbackBody.Builder::class) - @NoAutoDetect - class PromptFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { - - private var hashCode: Int = 0 - - /** A list of prompt feedback items */ - @JsonProperty("feedback") - fun feedback(): List? = feedback - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = "PromptFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - class Builder { - - private var feedback: List? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptFeedbackBody: PromptFeedbackBody) = apply { - this.feedback = promptFeedbackBody.feedback - additionalProperties(promptFeedbackBody.additionalProperties) - } - - /** A list of prompt feedback items */ - @JsonProperty("feedback") - fun feedback(feedback: List) = apply { - this.feedback = feedback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PromptFeedbackBody = PromptFeedbackBody(checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), additionalProperties.toUnmodifiable()) - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptFeedbackParams && - this.promptId == other.promptId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - promptId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = "PromptFeedbackParams{promptId=$promptId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var promptId: String? = null - private var feedback: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(promptFeedbackParams: PromptFeedbackParams) = apply { - this.promptId = promptFeedbackParams.promptId - this.feedback(promptFeedbackParams.feedback) - additionalQueryParams(promptFeedbackParams.additionalQueryParams) - additionalHeaders(promptFeedbackParams.additionalHeaders) - additionalBodyProperties(promptFeedbackParams.additionalBodyProperties) - } - - /** Prompt id */ - fun promptId(promptId: String) = apply { - this.promptId = promptId - } - - /** A list of prompt feedback items */ - fun feedback(feedback: List) = apply { - this.feedback.clear() - this.feedback.addAll(feedback) - } - - /** A list of prompt feedback items */ - fun addFeedback(feedback: Feedback) = apply { - this.feedback.add(feedback) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): PromptFeedbackParams = PromptFeedbackParams( - checkNotNull(promptId) { - "`promptId` is required but was not set" - }, - checkNotNull(feedback) { - "`feedback` is required but was not set" - }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Feedback.Builder::class) - @NoAutoDetect - class Feedback private constructor( - private val id: String?, - private val comment: String?, - private val metadata: Metadata?, - private val source: Source?, - private val additionalProperties: Map, - - ) { - - private var hashCode: Int = 0 - - /** - * The id of the prompt event to log feedback for. This is the row `id` returned by - * `POST /v1/prompt/{prompt_id}/insert` - */ - @JsonProperty("id") - fun id(): String? = id - - /** An optional comment string to log about the prompt event */ - @JsonProperty("comment") - fun comment(): String? = comment - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") - fun metadata(): Metadata? = metadata - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(): Source? = source - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Feedback && - this.id == other.id && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = "Feedback{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var comment: String? = null - private var metadata: Metadata? = null - private var source: Source? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(feedback: Feedback) = apply { - this.id = feedback.id - this.comment = feedback.comment - this.metadata = feedback.metadata - this.source = feedback.source - additionalProperties(feedback.additionalProperties) - } - - /** - * The id of the prompt event to log feedback for. This is the row `id` returned by - * `POST /v1/prompt/{prompt_id}/insert` - */ - @JsonProperty("id") - fun id(id: String) = apply { - this.id = id - } - - /** An optional comment string to log about the prompt event */ - @JsonProperty("comment") - fun comment(comment: String) = apply { - this.comment = comment - } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. - */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { - this.metadata = metadata - } - - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - fun source(source: Source) = apply { - this.source = source - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Feedback = Feedback( - checkNotNull(id) { - "`id` is required but was not set" - }, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata private constructor(private val additionalProperties: Map, ) { - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Source && - this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val APP = Source(JsonField.of("app")) - - @JvmField val API = Source(JsonField.of("api")) - - @JvmField val EXTERNAL = Source(JsonField.of("external")) - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - APP, - API, - EXTERNAL, - } - - enum class Value { - APP, - API, - EXTERNAL, - _UNKNOWN, - } - - fun value(): Value = when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index 82a7570..43cda3c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -2,79 +2,77 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.PromptService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Prompt -import com.braintrustdata.api.services.blocking.PromptService -class PromptListPage private constructor(private val promptsService: PromptService, private val params: PromptListParams, private val response: Response, ) { +class PromptListPage +private constructor( + private val promptsService: PromptService, + private val params: PromptListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptListPage && - this.promptsService == other.promptsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is PromptListPage && + this.promptsService == other.promptsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - promptsService, - params, - response, - ) + return Objects.hash( + promptsService, + params, + response, + ) } - override fun toString() = "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = + "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { promptsService.list(it) } + return getNextPageParams().map { promptsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +80,21 @@ class PromptListPage private constructor(private val promptsService: PromptServi companion object { @JvmStatic - fun of(promptsService: PromptService, params: PromptListParams, response: Response) = PromptListPage( - promptsService, - params, - response, - ) + fun of(promptsService: PromptService, params: PromptListParams, response: Response) = + PromptListPage( + promptsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +109,33 @@ class PromptListPage private constructor(private val promptsService: PromptServi fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "PromptListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +163,25 @@ class PromptListPage private constructor(private val promptsService: PromptServi } } - class AutoPager constructor(private val firstPage: PromptListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: PromptListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index ed5cc93..31a7d45 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -2,83 +2,80 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.PromptServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Prompt -import com.braintrustdata.api.services.async.PromptServiceAsync -class PromptListPageAsync private constructor(private val promptsService: PromptServiceAsync, private val params: PromptListParams, private val response: Response, ) { +class PromptListPageAsync +private constructor( + private val promptsService: PromptServiceAsync, + private val params: PromptListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptListPageAsync && - this.promptsService == other.promptsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is PromptListPageAsync && + this.promptsService == other.promptsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - promptsService, - params, - response, - ) + return Objects.hash( + promptsService, + params, + response, + ) } - override fun toString() = "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = + "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - promptsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { promptsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +83,21 @@ class PromptListPageAsync private constructor(private val promptsService: Prompt companion object { @JvmStatic - fun of(promptsService: PromptServiceAsync, params: PromptListParams, response: Response) = PromptListPageAsync( - promptsService, - params, - response, - ) + fun of(promptsService: PromptServiceAsync, params: PromptListParams, response: Response) = + PromptListPageAsync( + promptsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +112,33 @@ class PromptListPageAsync private constructor(private val promptsService: Prompt fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "PromptListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +166,32 @@ class PromptListPageAsync private constructor(private val promptsService: Prompt } } - class AutoPager constructor(private val firstPage: PromptListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: PromptListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Prompt) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Prompt) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index ea03c08..87d24bb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -2,54 +2,38 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class PromptListParams constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val promptName: String?, - private val slug: String?, - private val startingAfter: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class PromptListParams +constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val promptName: String?, + private val slug: String?, + private val startingAfter: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -72,40 +56,21 @@ class PromptListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.promptName?.let { - params.put("prompt_name", listOf(it.toString())) - } - this.slug?.let { - params.put("slug", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - this.version?.let { - params.put("version", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.promptName?.let { params.put("prompt_name", listOf(it.toString())) } + this.slug?.let { params.put("slug", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + this.version?.let { params.put("version", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -114,50 +79,50 @@ class PromptListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.promptName == other.promptName && - this.slug == other.slug && - this.startingAfter == other.startingAfter && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.promptName == other.promptName && + this.slug == other.slug && + this.startingAfter == other.startingAfter && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectName, - promptName, - slug, - startingAfter, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectName, + promptName, + slug, + startingAfter, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -195,83 +160,61 @@ class PromptListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** Name of the prompt to search for */ - fun promptName(promptName: String) = apply { - this.promptName = promptName - } + fun promptName(promptName: String) = apply { this.promptName = promptName } /** Retrieve prompt with a specific slug */ - fun slug(slug: String) = apply { - this.slug = slug - } + fun slug(slug: String) = apply { this.slug = slug } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String) = apply { - this.version = version - } + fun version(version: String) = apply { this.version = version } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -311,9 +254,7 @@ class PromptListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -324,90 +265,96 @@ class PromptListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): PromptListParams = PromptListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - promptName, - slug, - startingAfter, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): PromptListParams = + PromptListParams( + endingBefore, + ids, + limit, + orgName, + projectName, + promptName, + slug, + startingAfter, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -417,34 +364,38 @@ class PromptListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 67468b4..be51d91 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -2,51 +2,43 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class PromptReplaceParams constructor( - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class PromptReplaceParams +constructor( + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -63,61 +55,53 @@ class PromptReplaceParams constructor( @JvmSynthetic internal fun getBody(): PromptReplaceBody { - return PromptReplaceBody( - name, - projectId, - slug, - description, - promptData, - tags, - additionalBodyProperties, - ) + return PromptReplaceBody( + name, + projectId, + slug, + description, + promptData, + tags, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = PromptReplaceBody.Builder::class) @NoAutoDetect - class PromptReplaceBody internal constructor( - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, - + class PromptReplaceBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the prompt */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(): String? = slug + @JsonProperty("slug") fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(): List? = tags + @JsonProperty("tags") fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -126,41 +110,42 @@ class PromptReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptReplaceBody && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - projectId, - slug, - description, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + projectId, + slug, + description, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -185,40 +170,25 @@ class PromptReplaceParams constructor( } /** Name of the prompt */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - @JsonProperty("slug") - fun slug(slug: String) = apply { - this.slug = slug - } + @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(tags: List) = apply { - this.tags = tags - } + @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -234,21 +204,16 @@ class PromptReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptReplaceBody = PromptReplaceBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptReplaceBody = + PromptReplaceBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -259,44 +224,44 @@ class PromptReplaceParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptReplaceParams && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - slug, - description, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + slug, + description, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -326,29 +291,19 @@ class PromptReplaceParams constructor( } /** Name of the prompt */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { - this.slug = slug - } + fun slug(slug: String) = apply { this.slug = slug } /** Textual description of the prompt */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -357,9 +312,7 @@ class PromptReplaceParams constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - this.tags.add(tag) - } + fun addTag(tag: String) = apply { this.tags.add(tag) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -399,9 +352,7 @@ class PromptReplaceParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -412,50 +363,43 @@ class PromptReplaceParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): PromptReplaceParams = PromptReplaceParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(projectId) { - "`projectId` is required but was not set" - }, - checkNotNull(slug) { - "`slug` is required but was not set" - }, - description, - promptData, - if(tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): PromptReplaceParams = + PromptReplaceParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(slug) { "`slug` is required but was not set" }, + description, + promptData, + if (tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: Prompt?, - private val options: Options?, - private val origin: Origin?, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: Prompt?, + private val options: Options?, + private val origin: Origin?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt") - fun prompt(): Prompt? = prompt + @JsonProperty("prompt") fun prompt(): Prompt? = prompt - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options - @JsonProperty("origin") - fun origin(): Origin? = origin + @JsonProperty("origin") fun origin(): Origin? = origin @JsonAnyGetter @ExcludeMissing @@ -464,35 +408,36 @@ class PromptReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -510,20 +455,12 @@ class PromptReplaceParams constructor( additionalProperties(promptData.additionalProperties) } - @JsonProperty("prompt") - fun prompt(prompt: Prompt) = apply { - this.prompt = prompt - } + @JsonProperty("prompt") fun prompt(prompt: Prompt) = apply { this.prompt = prompt } @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } - @JsonProperty("origin") - fun origin(origin: Origin) = apply { - this.origin = origin - } + @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -539,34 +476,32 @@ class PromptReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: String?, - private val params: Params?, - private val position: String?, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: String?, + private val params: Params?, + private val position: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("model") - fun model(): String? = model + @JsonProperty("model") fun model(): String? = model - @JsonProperty("params") - fun params(): Params? = params + @JsonProperty("params") fun params(): Params? = params - @JsonProperty("position") - fun position(): String? = position + @JsonProperty("position") fun position(): String? = position @JsonAnyGetter @ExcludeMissing @@ -575,35 +510,36 @@ class PromptReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -621,20 +557,12 @@ class PromptReplaceParams constructor( additionalProperties(options.additionalProperties) } - @JsonProperty("model") - fun model(model: String) = apply { - this.model = model - } + @JsonProperty("model") fun model(model: String) = apply { this.model = model } - @JsonProperty("params") - fun params(params: Params) = apply { - this.params = params - } + @JsonProperty("params") fun params(params: Params) = apply { this.params = params } @JsonProperty("position") - fun position(position: String) = apply { - this.position = position - } + fun position(position: String) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -646,245 +574,307 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) + + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun isOpenAIModelParams(): Boolean = openaiModelParams != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null + + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") + + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -898,91 +888,86 @@ class PromptReplaceParams constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -998,22 +983,23 @@ class PromptReplaceParams constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -1024,7 +1010,8 @@ class PromptReplaceParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -1036,9 +1023,7 @@ class PromptReplaceParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -1048,7 +1033,8 @@ class PromptReplaceParams constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -1056,7 +1042,8 @@ class PromptReplaceParams constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -1064,7 +1051,8 @@ class PromptReplaceParams constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -1072,7 +1060,8 @@ class PromptReplaceParams constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -1080,7 +1069,8 @@ class PromptReplaceParams constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -1092,190 +1082,202 @@ class PromptReplaceParams constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun asNone(): None = none.getOrThrow("none") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1284,9 +1286,9 @@ class PromptReplaceParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1298,31 +1300,37 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1331,9 +1339,9 @@ class PromptReplaceParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1345,22 +1353,29 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1368,68 +1383,68 @@ class PromptReplaceParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1439,18 +1454,23 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1458,9 +1478,7 @@ class PromptReplaceParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1468,42 +1486,43 @@ class PromptReplaceParams constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -1515,39 +1534,42 @@ class PromptReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1570,15 +1592,18 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1586,146 +1611,160 @@ class PromptReplaceParams constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun function(): Optional = Optional.ofNullable(function) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1734,9 +1773,9 @@ class PromptReplaceParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1748,31 +1787,37 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1781,9 +1826,9 @@ class PromptReplaceParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1795,22 +1840,30 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1820,78 +1873,75 @@ class PromptReplaceParams constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -1901,7 +1951,9 @@ class PromptReplaceParams constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1911,20 +1963,25 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1932,52 +1989,53 @@ class PromptReplaceParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -1989,40 +2047,47 @@ class PromptReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2045,15 +2110,20 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -2061,25 +2131,26 @@ class PromptReplaceParams constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -2089,30 +2160,22 @@ class PromptReplaceParams constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -2127,59 +2190,60 @@ class PromptReplaceParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2191,18 +2255,19 @@ class PromptReplaceParams constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2221,7 +2286,8 @@ class PromptReplaceParams constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2233,19 +2299,16 @@ class PromptReplaceParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -2254,7 +2317,8 @@ class PromptReplaceParams constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -2263,130 +2327,128 @@ class PromptReplaceParams constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2396,16 +2458,17 @@ class PromptReplaceParams constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2416,7 +2479,8 @@ class PromptReplaceParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2424,7 +2488,8 @@ class PromptReplaceParams constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -2436,120 +2501,115 @@ class PromptReplaceParams constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2557,14 +2617,15 @@ class PromptReplaceParams constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2575,7 +2636,8 @@ class PromptReplaceParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2587,94 +2649,98 @@ class PromptReplaceParams constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2685,21 +2751,23 @@ class PromptReplaceParams constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -2707,24 +2775,21 @@ class PromptReplaceParams constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: String?, - private val projectId: String?, - private val promptVersion: String?, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: String?, + private val projectId: String?, + private val promptVersion: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt_id") - fun promptId(): String? = promptId + @JsonProperty("prompt_id") fun promptId(): String? = promptId - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId - @JsonProperty("prompt_version") - fun promptVersion(): String? = promptVersion + @JsonProperty("prompt_version") fun promptVersion(): String? = promptVersion @JsonAnyGetter @ExcludeMissing @@ -2733,35 +2798,36 @@ class PromptReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2780,14 +2846,10 @@ class PromptReplaceParams constructor( } @JsonProperty("prompt_id") - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } @JsonProperty("prompt_version") fun promptVersion(promptVersion: String) = apply { @@ -2804,154 +2866,175 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) + + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + + fun isCompletion(): Boolean = completion != null + + fun isChat(): Boolean = chat != null + + fun isNullableVariant(): Boolean = nullableVariant != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun asCompletion(): Completion = completion.getOrThrow("completion") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2961,56 +3044,53 @@ class PromptReplaceParams constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3020,27 +3100,23 @@ class PromptReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3052,29 +3128,34 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3097,28 +3178,30 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -3131,63 +3214,58 @@ class PromptReplaceParams constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3198,20 +3276,18 @@ class PromptReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -3225,9 +3301,7 @@ class PromptReplaceParams constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3239,281 +3313,306 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3521,14 +3620,15 @@ class PromptReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -3543,52 +3643,53 @@ class PromptReplaceParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3611,97 +3712,96 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3709,14 +3809,15 @@ class PromptReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -3731,52 +3832,53 @@ class PromptReplaceParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3799,304 +3901,410 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent2s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent2s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent2s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent2s) + + fun unnamedSchemaWithArrayParent2s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent2s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent2s(): Boolean = unnamedSchemaWithArrayParent2s != null + + fun isUnnamedSchemaWithArrayParent2s(): Boolean = + unnamedSchemaWithArrayParent2s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent2s(): List = unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") + + fun asUnnamedSchemaWithArrayParent2s(): + List = + unnamedSchemaWithArrayParent2s.getOrThrow( + "unnamedSchemaWithArrayParent2s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent2s != null -> visitor.visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent2s != null -> + visitor.visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent2s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent2s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent2s == + other.unnamedSchemaWithArrayParent2s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent2s) + return Objects.hash(string, unnamedSchemaWithArrayParent2s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent2s != null -> "Content{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent2s != null -> + "Content{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s: List) = Content(unnamedSchemaWithArrayParent2s = unnamedSchemaWithArrayParent2s) + fun ofUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: + List + ) = + Content( + unnamedSchemaWithArrayParent2s = + unnamedSchemaWithArrayParent2s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s: List): T + fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent2s = it, _json = json) - } - - return Content(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent2s = it, + _json = json + ) + } + + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent2s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent2s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent2s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent2s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent2.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) - class UnnamedSchemaWithArrayParent2 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent2 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) + + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) + + fun isText(): Boolean = text != null + + fun isImageUrl(): Boolean = imageUrl != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun asText(): Text = text.getOrThrow("text") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent2 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent2: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent2: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent2 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent2 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent2{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent2{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent2{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent2{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent2(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent2(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent2(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent2(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent2: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent2: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent2::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent2 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent2(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent2(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent2 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent2( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent2( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent2(_json = json) + return UnnamedSchemaWithArrayParent2(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent2::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent2, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent2, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -4111,43 +4319,50 @@ class PromptReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4158,7 +4373,8 @@ class PromptReplaceParams constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4170,23 +4386,33 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4200,68 +4426,71 @@ class PromptReplaceParams constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -4273,34 +4502,43 @@ class PromptReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4308,11 +4546,10 @@ class PromptReplaceParams constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -4320,53 +4557,58 @@ class PromptReplaceParams constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -4383,7 +4625,8 @@ class PromptReplaceParams constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -4391,39 +4634,52 @@ class PromptReplaceParams constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4438,7 +4694,8 @@ class PromptReplaceParams constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -4454,36 +4711,44 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4492,9 +4757,11 @@ class PromptReplaceParams constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4506,15 +4773,20 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -4523,16 +4795,16 @@ class PromptReplaceParams constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4541,85 +4813,81 @@ class PromptReplaceParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4629,25 +4897,24 @@ class PromptReplaceParams constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -4657,7 +4924,8 @@ class PromptReplaceParams constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -4669,11 +4937,10 @@ class PromptReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -4681,42 +4948,47 @@ class PromptReplaceParams constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4739,22 +5011,30 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4764,63 +5044,62 @@ class PromptReplaceParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -4829,7 +5108,8 @@ class PromptReplaceParams constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -4841,11 +5121,11 @@ class PromptReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -4855,26 +5135,27 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4887,63 +5168,59 @@ class PromptReplaceParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4951,7 +5228,8 @@ class PromptReplaceParams constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -4965,9 +5243,7 @@ class PromptReplaceParams constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -4981,11 +5257,11 @@ class PromptReplaceParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -4995,21 +5271,27 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5023,59 +5305,61 @@ class PromptReplaceParams constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -5084,7 +5368,8 @@ class PromptReplaceParams constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -5096,44 +5381,51 @@ class PromptReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5156,98 +5448,100 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5255,14 +5549,15 @@ class PromptReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5277,11 +5572,10 @@ class PromptReplaceParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -5289,40 +5583,45 @@ class PromptReplaceParams constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5345,97 +5644,96 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5443,14 +5741,15 @@ class PromptReplaceParams constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5465,52 +5764,53 @@ class PromptReplaceParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5533,23 +5833,31 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5557,80 +5865,77 @@ class PromptReplaceParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -5640,39 +5945,44 @@ class PromptReplaceParams constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5695,33 +6005,39 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5744,23 +6060,28 @@ class PromptReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5770,36 +6091,36 @@ class PromptReplaceParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5807,8 +6128,8 @@ class PromptReplaceParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -5821,11 +6142,13 @@ class PromptReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 9ecb3ca..8a0f796 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class PromptRetrieveParams constructor( - private val promptId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class PromptRetrieveParams +constructor( + private val promptId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun promptId(): String = promptId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class PromptRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptRetrieveParams && - this.promptId == other.promptId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptRetrieveParams && + this.promptId == other.promptId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - promptId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + promptId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "PromptRetrieveParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "PromptRetrieveParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class PromptRetrieveParams constructor( } /** Prompt id */ - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class PromptRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class PromptRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): PromptRetrieveParams = PromptRetrieveParams( - checkNotNull(promptId) { - "`promptId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): PromptRetrieveParams = + PromptRetrieveParams( + checkNotNull(promptId) { "`promptId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index 0d4467c..38346e1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -2,50 +2,42 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class PromptUpdateParams constructor( - private val promptId: String, - private val description: String?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class PromptUpdateParams +constructor( + private val promptId: String, + private val description: String?, + private val name: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun promptId(): String = promptId @@ -60,56 +52,50 @@ class PromptUpdateParams constructor( @JvmSynthetic internal fun getBody(): PromptUpdateBody { - return PromptUpdateBody( - description, - name, - promptData, - tags, - additionalBodyProperties, - ) + return PromptUpdateBody( + description, + name, + promptData, + tags, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } @JsonDeserialize(builder = PromptUpdateBody.Builder::class) @NoAutoDetect - class PromptUpdateBody internal constructor( - private val description: String?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, - + class PromptUpdateBody + internal constructor( + private val description: String?, + private val name: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Textual description of the prompt */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** Name of the prompt */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(): List? = tags + @JsonProperty("tags") fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -118,37 +104,38 @@ class PromptUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptUpdateBody && - this.description == other.description && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptUpdateBody && + this.description == other.description && + this.name == other.name && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - description, - name, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + description, + name, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -170,27 +157,17 @@ class PromptUpdateParams constructor( /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the prompt */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ - @JsonProperty("tags") - fun tags(tags: List) = apply { - this.tags = tags - } + @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -206,13 +183,14 @@ class PromptUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptUpdateBody = PromptUpdateBody( - description, - name, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptUpdateBody = + PromptUpdateBody( + description, + name, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -223,42 +201,42 @@ class PromptUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptUpdateParams && - this.promptId == other.promptId && - this.description == other.description && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptUpdateParams && + this.promptId == other.promptId && + this.description == other.description && + this.name == other.name && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - promptId, - description, - name, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + promptId, + description, + name, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -286,24 +264,16 @@ class PromptUpdateParams constructor( } /** Prompt id */ - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } /** Textual description of the prompt */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the prompt */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { - this.promptData = promptData - } + fun promptData(promptData: PromptData) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -312,9 +282,7 @@ class PromptUpdateParams constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - this.tags.add(tag) - } + fun addTag(tag: String) = apply { this.tags.add(tag) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -354,9 +322,7 @@ class PromptUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -367,45 +333,42 @@ class PromptUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): PromptUpdateParams = PromptUpdateParams( - checkNotNull(promptId) { - "`promptId` is required but was not set" - }, - description, - name, - promptData, - if(tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): PromptUpdateParams = + PromptUpdateParams( + checkNotNull(promptId) { "`promptId` is required but was not set" }, + description, + name, + promptData, + if (tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect - class PromptData private constructor( - private val prompt: Prompt?, - private val options: Options?, - private val origin: Origin?, - private val additionalProperties: Map, - + class PromptData + private constructor( + private val prompt: Prompt?, + private val options: Options?, + private val origin: Origin?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt") - fun prompt(): Prompt? = prompt + @JsonProperty("prompt") fun prompt(): Prompt? = prompt - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options - @JsonProperty("origin") - fun origin(): Origin? = origin + @JsonProperty("origin") fun origin(): Origin? = origin @JsonAnyGetter @ExcludeMissing @@ -414,35 +377,36 @@ class PromptUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - prompt, - options, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + prompt, + options, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{prompt=$prompt, options=$options, origin=$origin, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -460,20 +424,12 @@ class PromptUpdateParams constructor( additionalProperties(promptData.additionalProperties) } - @JsonProperty("prompt") - fun prompt(prompt: Prompt) = apply { - this.prompt = prompt - } + @JsonProperty("prompt") fun prompt(prompt: Prompt) = apply { this.prompt = prompt } @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } - @JsonProperty("origin") - fun origin(origin: Origin) = apply { - this.origin = origin - } + @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -489,34 +445,32 @@ class PromptUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = PromptData( - prompt, - options, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = + PromptData( + prompt, + options, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val model: String?, - private val params: Params?, - private val position: String?, - private val additionalProperties: Map, - + class Options + private constructor( + private val model: String?, + private val params: Params?, + private val position: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("model") - fun model(): String? = model + @JsonProperty("model") fun model(): String? = model - @JsonProperty("params") - fun params(): Params? = params + @JsonProperty("params") fun params(): Params? = params - @JsonProperty("position") - fun position(): String? = position + @JsonProperty("position") fun position(): String? = position @JsonAnyGetter @ExcludeMissing @@ -525,35 +479,36 @@ class PromptUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -571,20 +526,12 @@ class PromptUpdateParams constructor( additionalProperties(options.additionalProperties) } - @JsonProperty("model") - fun model(model: String) = apply { - this.model = model - } + @JsonProperty("model") fun model(model: String) = apply { this.model = model } - @JsonProperty("params") - fun params(params: Params) = apply { - this.params = params - } + @JsonProperty("params") fun params(params: Params) = apply { this.params = params } @JsonProperty("position") - fun position(position: String) = apply { - this.position = position - } + fun position(position: String) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -596,245 +543,307 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Options = Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val useCache: UseCache? = null, - private val _json: JsonValue? = null, - + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun useCache(): Optional = Optional.ofNullable(useCache) + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUseCache(): Boolean = useCache != null + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUseCache(): UseCache = useCache.getOrThrow("useCache") + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) + + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) + + fun isOpenAIModelParams(): Boolean = openaiModelParams != null + + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null + + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") + + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - useCache != null -> visitor.visitUseCache(useCache) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> + visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> + visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> + visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> + visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && useCache == null) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - useCache?.validate() - validated = true + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.useCache == other.useCache + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - useCache, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Params{unionMember0=$unionMember0}" - unionMember1 != null -> "Params{unionMember1=$unionMember1}" - unionMember2 != null -> "Params{unionMember2=$unionMember2}" - unionMember3 != null -> "Params{unionMember3=$unionMember3}" - useCache != null -> "Params{useCache=$useCache}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> + "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> + "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> + "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Params(unionMember0 = unionMember0) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Params(unionMember1 = unionMember1) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Params(unionMember2 = unionMember2) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Params(unionMember3 = unionMember3) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) @JvmStatic - fun ofUseCache(useCache: UseCache) = Params(useCache = useCache) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - fun visitUseCache(useCache: UseCache): T + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(useCache = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.useCache != null -> generator.writeObject(value.useCache) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun stop(): Optional> = + Optional.ofNullable(stop.getNullable("stop")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -848,91 +857,86 @@ class PromptUpdateParams constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") - @ExcludeMissing - fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("n") - @ExcludeMissing - fun _n() = n + @JsonProperty("n") @ExcludeMissing fun _n() = n - @JsonProperty("stop") - @ExcludeMissing - fun _stop() = stop + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat().map { it.validate() } - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat().map { it.validate() } + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -948,22 +952,23 @@ class PromptUpdateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.useCache = unionMember0.useCache - this.temperature = unionMember0.temperature - this.topP = unionMember0.topP - this.maxTokens = unionMember0.maxTokens - this.frequencyPenalty = unionMember0.frequencyPenalty - this.presencePenalty = unionMember0.presencePenalty - this.responseFormat = unionMember0.responseFormat - this.toolChoice = unionMember0.toolChoice - this.functionCall = unionMember0.functionCall - this.n = unionMember0.n - this.stop = unionMember0.stop - additionalProperties(unionMember0.additionalProperties) + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -974,7 +979,8 @@ class PromptUpdateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -986,9 +992,7 @@ class PromptUpdateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -998,7 +1002,8 @@ class PromptUpdateParams constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -1006,7 +1011,8 @@ class PromptUpdateParams constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -1014,7 +1020,8 @@ class PromptUpdateParams constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -1022,7 +1029,8 @@ class PromptUpdateParams constructor( this.responseFormat = responseFormat } - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + fun toolChoice(toolChoice: ToolChoice) = + toolChoice(JsonField.of(toolChoice)) @JsonProperty("tool_choice") @ExcludeMissing @@ -1030,7 +1038,8 @@ class PromptUpdateParams constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -1042,190 +1051,202 @@ class PromptUpdateParams constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { - this.stop = stop - } + fun stop(stop: JsonField>) = apply { this.stop = stop } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember0 = UnionMember0( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val name: Name? = null, - private val _json: JsonValue? = null, - + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun name(): Optional = Optional.ofNullable(name) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isName(): Boolean = name != null + fun isAuto(): Boolean = auto != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asName(): Name = name.getOrThrow("name") + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - name != null -> visitor.visitName(name) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && name == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - name?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown FunctionCall: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.name == other.name + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - name, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" - unionMember1 != null -> "FunctionCall{unionMember1=$unionMember1}" - name != null -> "FunctionCall{name=$name}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = FunctionCall(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) @JvmStatic - fun ofName(name: Name) = FunctionCall(name = name) + fun ofFunction(function: Function) = FunctionCall(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitName(name: Name): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(name = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.name != null -> generator.writeObject(value.name) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1234,9 +1255,9 @@ class PromptUpdateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1248,31 +1269,37 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1281,9 +1308,9 @@ class PromptUpdateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1295,22 +1322,29 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Name.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Name private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1318,68 +1352,68 @@ class PromptUpdateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Name = apply { + fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Name && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Name{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(name: Name) = apply { - this.name = name.name - additionalProperties(name.additionalProperties) + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1389,18 +1423,23 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Name = Name(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { + class ResponseFormat + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1408,9 +1447,7 @@ class PromptUpdateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1418,42 +1455,43 @@ class PromptUpdateParams constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(responseFormat: ResponseFormat) = apply { @@ -1465,39 +1503,42 @@ class PromptUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = + ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1520,15 +1561,18 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1536,146 +1580,160 @@ class PromptUpdateParams constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun asAuto(): Auto = auto.getOrThrow("auto") - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - unionMember2?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException( + "Unknown ToolChoice: $_json" + ) + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" - unionMember1 != null -> "ToolChoice{unionMember1=$unionMember1}" - unionMember2 != null -> "ToolChoice{unionMember2=$unionMember2}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ToolChoice(unionMember1 = unionMember1) + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ToolChoice(unionMember2 = unionMember2) + fun ofFunction(function: Function) = ToolChoice(function = function) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitAuto(auto: Auto): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitNone(none: None): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(unionMember2 = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.value == other.value + return other is Auto && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1684,9 +1742,9 @@ class PromptUpdateParams constructor( companion object { - @JvmField val AUTO = UnionMember0(JsonField.of("auto")) + @JvmField val AUTO = Auto(JsonField.of("auto")) - @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) } enum class Known { @@ -1698,31 +1756,37 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> + throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnionMember1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.value == other.value + return other is None && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1731,9 +1795,9 @@ class PromptUpdateParams constructor( companion object { - @JvmField val NONE = UnionMember1(JsonField.of("none")) + @JvmField val NONE = None(JsonField.of("none")) - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } enum class Known { @@ -1745,22 +1809,30 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember1: $value") - } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1770,78 +1842,75 @@ class PromptUpdateParams constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.type = unionMember2.type - this.function = unionMember2.function - additionalProperties(unionMember2.additionalProperties) + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun function(function: Function) = function(JsonField.of(function)) @@ -1851,7 +1920,9 @@ class PromptUpdateParams constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1861,20 +1932,25 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1882,52 +1958,53 @@ class PromptUpdateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -1939,40 +2016,47 @@ class PromptUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = + Function(name, additionalProperties.toUnmodifiable()) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1995,15 +2079,20 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -2011,25 +2100,26 @@ class PromptUpdateParams constructor( } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -2039,30 +2129,22 @@ class PromptUpdateParams constructor( fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("max_tokens") - @ExcludeMissing - fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("top_p") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - @JsonProperty("top_k") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK @JsonProperty("stop_sequences") @ExcludeMissing @@ -2077,59 +2159,60 @@ class PromptUpdateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2141,18 +2224,19 @@ class PromptUpdateParams constructor( private var topK: JsonField = JsonMissing.of() private var stopSequences: JsonField> = JsonMissing.of() private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.useCache = unionMember1.useCache - this.maxTokens = unionMember1.maxTokens - this.temperature = unionMember1.temperature - this.topP = unionMember1.topP - this.topK = unionMember1.topK - this.stopSequences = unionMember1.stopSequences - this.maxTokensToSample = unionMember1.maxTokensToSample - additionalProperties(unionMember1.additionalProperties) + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2171,7 +2255,8 @@ class PromptUpdateParams constructor( this.maxTokens = maxTokens } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2183,19 +2268,16 @@ class PromptUpdateParams constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -2204,7 +2286,8 @@ class PromptUpdateParams constructor( } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -2213,130 +2296,128 @@ class PromptUpdateParams constructor( this.maxTokensToSample = maxTokensToSample } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember1 = UnionMember1( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") - @ExcludeMissing - fun _topP() = topP + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2346,16 +2427,17 @@ class PromptUpdateParams constructor( private var maxOutputTokens: JsonField = JsonMissing.of() private var topP: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.useCache = unionMember2.useCache - this.temperature = unionMember2.temperature - this.maxOutputTokens = unionMember2.maxOutputTokens - this.topP = unionMember2.topP - this.topK = unionMember2.topK - additionalProperties(unionMember2.additionalProperties) + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2366,7 +2448,8 @@ class PromptUpdateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2374,7 +2457,8 @@ class PromptUpdateParams constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -2386,120 +2470,115 @@ class PromptUpdateParams constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): UnionMember2 = UnionMember2( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - @JsonProperty("temperature") - @ExcludeMissing - fun _temperature() = temperature + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2507,14 +2586,15 @@ class PromptUpdateParams constructor( private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.useCache = unionMember3.useCache - this.temperature = unionMember3.temperature - this.topK = unionMember3.topK - additionalProperties(unionMember3.additionalProperties) + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2525,7 +2605,8 @@ class PromptUpdateParams constructor( this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun temperature(temperature: Double) = + temperature(JsonField.of(temperature)) @JsonProperty("temperature") @ExcludeMissing @@ -2537,94 +2618,98 @@ class PromptUpdateParams constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } - @JsonDeserialize(builder = UseCache.Builder::class) + @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class UseCache private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") - @ExcludeMissing - fun _useCache() = useCache + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UseCache = apply { + fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UseCache && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = "UseCache{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(useCache: UseCache) = apply { - this.useCache = useCache.useCache - additionalProperties(useCache.additionalProperties) + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) @@ -2635,21 +2720,23 @@ class PromptUpdateParams constructor( this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UseCache = UseCache(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -2657,24 +2744,21 @@ class PromptUpdateParams constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin private constructor( - private val promptId: String?, - private val projectId: String?, - private val promptVersion: String?, - private val additionalProperties: Map, - + class Origin + private constructor( + private val promptId: String?, + private val projectId: String?, + private val promptVersion: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("prompt_id") - fun promptId(): String? = promptId + @JsonProperty("prompt_id") fun promptId(): String? = promptId - @JsonProperty("project_id") - fun projectId(): String? = projectId + @JsonProperty("project_id") fun projectId(): String? = projectId - @JsonProperty("prompt_version") - fun promptVersion(): String? = promptVersion + @JsonProperty("prompt_version") fun promptVersion(): String? = promptVersion @JsonAnyGetter @ExcludeMissing @@ -2683,35 +2767,36 @@ class PromptUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2730,14 +2815,10 @@ class PromptUpdateParams constructor( } @JsonProperty("prompt_id") - fun promptId(promptId: String) = apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } @JsonProperty("project_id") - fun projectId(projectId: String) = apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } @JsonProperty("prompt_version") fun promptVersion(promptVersion: String) = apply { @@ -2754,154 +2835,175 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Origin = Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = + Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, - + class Prompt + private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun completion(): Optional = Optional.ofNullable(completion) + + fun chat(): Optional = Optional.ofNullable(chat) - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun isCompletion(): Boolean = completion != null + + fun isChat(): Boolean = chat != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asCompletion(): Completion = completion.getOrThrow("completion") + + fun asChat(): Chat = chat.getOrThrow("chat") + + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Prompt = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Prompt{unionMember0=$unionMember0}" - unionMember1 != null -> "Prompt{unionMember1=$unionMember1}" - unionMember2 != null -> "Prompt{unionMember2=$unionMember2}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Prompt(unionMember0 = unionMember0) + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Prompt(unionMember1 = unionMember1) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Prompt(unionMember2 = unionMember2) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitCompletion(completion: Completion): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitChat(chat: Chat): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(unionMember2 = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Completion + private constructor( + private val type: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2911,56 +3013,53 @@ class PromptUpdateParams constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -2970,27 +3069,23 @@ class PromptUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.type = unionMember0.type - this.content = unionMember0.content - additionalProperties(unionMember0.additionalProperties) + internal fun from(completion: Completion) = apply { + this.type = completion.type + this.content = completion.content + additionalProperties(completion.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3002,29 +3097,34 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember0 = UnionMember0( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = + Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3047,28 +3147,30 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, - + class Chat + private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -3081,63 +3183,58 @@ class PromptUpdateParams constructor( fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type - @JsonProperty("messages") - @ExcludeMissing - fun _messages() = messages + @JsonProperty("messages") @ExcludeMissing fun _messages() = messages - @JsonProperty("tools") - @ExcludeMissing - fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools() = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3148,20 +3245,18 @@ class PromptUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.type = unionMember1.type - this.messages = unionMember1.messages - this.tools = unionMember1.tools - additionalProperties(unionMember1.additionalProperties) + internal fun from(chat: Chat) = apply { + this.type = chat.type + this.messages = chat.messages + this.tools = chat.tools + additionalProperties(chat.additionalProperties) } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -3175,9 +3270,7 @@ class PromptUpdateParams constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3189,281 +3282,306 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember1 = UnionMember1( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = + Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null - fun isUnionMember3(): Boolean = unionMember3 != null - fun isUnionMember4(): Boolean = unionMember4 != null - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } fun validate(): Message = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null && unionMember2 == null && unionMember3 == null && unionMember4 == null && unionMember5 == null) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - unionMember2?.validate() - unionMember3?.validate() - unionMember4?.validate() - unionMember5?.validate() - validated = true + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 && - this.unionMember2 == other.unionMember2 && - this.unionMember3 == other.unionMember3 && - this.unionMember4 == other.unionMember4 && - this.unionMember5 == other.unionMember5 + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - unionMember0 != null -> "Message{unionMember0=$unionMember0}" - unionMember1 != null -> "Message{unionMember1=$unionMember1}" - unionMember2 != null -> "Message{unionMember2=$unionMember2}" - unionMember3 != null -> "Message{unionMember3=$unionMember3}" - unionMember4 != null -> "Message{unionMember4=$unionMember4}" - unionMember5 != null -> "Message{unionMember5=$unionMember5}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Message(unionMember0 = unionMember0) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Message(unionMember1 = unionMember1) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Message(unionMember2 = unionMember2) + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = Message(unionMember3 = unionMember3) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = Message(unionMember4 = unionMember4) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = Message(unionMember5 = unionMember5) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitSystem(system: System): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitUser(user: User): T - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitAssistant(assistant: Assistant): T - fun visitUnionMember3(unionMember3: UnionMember3): T + fun visitTool(tool: Tool): T - fun visitUnionMember4(unionMember4: UnionMember4): T + fun visitFunction(function: Function): T - fun visitUnionMember5(unionMember5: UnionMember5): T + fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember1 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember2 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember3 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember4 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(unionMember5 = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class UnionMember0 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3471,14 +3589,15 @@ class PromptUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.content = unionMember0.content - this.role = unionMember0.role - this.name = unionMember0.name - additionalProperties(unionMember0.additionalProperties) + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -3493,52 +3612,53 @@ class PromptUpdateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3561,97 +3681,96 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class UnionMember1 private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember1 && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3659,14 +3778,15 @@ class PromptUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.content = unionMember1.content - this.role = unionMember1.role - this.name = unionMember1.name - additionalProperties(unionMember1.additionalProperties) + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) } fun content(content: Content) = content(JsonField.of(content)) @@ -3681,52 +3801,53 @@ class PromptUpdateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -3749,304 +3870,410 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + USER -> Known.USER + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent1s: List? = null, private val _json: JsonValue? = null, ) { + class Content + private constructor( + private val string: String? = null, + private val unnamedSchemaWithArrayParent1s: + List? = + null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) - fun unnamedSchemaWithArrayParent1s(): Optional> = Optional.ofNullable(unnamedSchemaWithArrayParent1s) + + fun unnamedSchemaWithArrayParent1s(): + Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent1s) fun isString(): Boolean = string != null - fun isUnnamedSchemaWithArrayParent1s(): Boolean = unnamedSchemaWithArrayParent1s != null + + fun isUnnamedSchemaWithArrayParent1s(): Boolean = + unnamedSchemaWithArrayParent1s != null fun asString(): String = string.getOrThrow("string") - fun asUnnamedSchemaWithArrayParent1s(): List = unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") + + fun asUnnamedSchemaWithArrayParent1s(): + List = + unnamedSchemaWithArrayParent1s.getOrThrow( + "unnamedSchemaWithArrayParent1s" + ) fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent1s != null -> visitor.visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent1s != null -> + visitor.visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s + ) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent1s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent1s == null) { + throw BraintrustInvalidDataException( + "Unknown Content: $_json" + ) + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent1s == + other.unnamedSchemaWithArrayParent1s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent1s) + return Objects.hash(string, unnamedSchemaWithArrayParent1s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent1s != null -> "Content{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent1s != null -> + "Content{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { - @JvmStatic - fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofString(string: String) = Content(string = string) @JvmStatic - fun ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s: List) = Content(unnamedSchemaWithArrayParent1s = unnamedSchemaWithArrayParent1s) + fun ofUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: + List + ) = + Content( + unnamedSchemaWithArrayParent1s = + unnamedSchemaWithArrayParent1s + ) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s: List): T + fun visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: + List + ): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Content(unnamedSchemaWithArrayParent1s = it, _json = json) - } - - return Content(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content( + unnamedSchemaWithArrayParent1s = it, + _json = json + ) + } + + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent1s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent1s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent1s != null -> + generator.writeObject( + value.unnamedSchemaWithArrayParent1s + ) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent1.Deserializer::class + ) @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) - class UnnamedSchemaWithArrayParent1 private constructor(private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, private val _json: JsonValue? = null, ) { + class UnnamedSchemaWithArrayParent1 + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun text(): Optional = Optional.ofNullable(text) + + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) + + fun isText(): Boolean = text != null - fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isImageUrl(): Boolean = imageUrl != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asText(): Text = text.getOrThrow("text") + + fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent1 = apply { if (!validated) { - if (unionMember0 == null && unionMember1 == null) { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent1: $_json") - } - unionMember0?.validate() - unionMember1?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent1: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent1 && - this.unionMember0 == other.unionMember0 && - this.unionMember1 == other.unionMember1 + return other is UnnamedSchemaWithArrayParent1 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(unionMember0, unionMember1) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - unionMember0 != null -> "UnnamedSchemaWithArrayParent1{unionMember0=$unionMember0}" - unionMember1 != null -> "UnnamedSchemaWithArrayParent1{unionMember1=$unionMember1}" - _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") - } + return when { + text != null -> "UnnamedSchemaWithArrayParent1{text=$text}" + imageUrl != null -> + "UnnamedSchemaWithArrayParent1{imageUrl=$imageUrl}" + _json != null -> + "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent1" + ) + } } companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = UnnamedSchemaWithArrayParent1(unionMember0 = unionMember0) + fun ofText(text: Text) = + UnnamedSchemaWithArrayParent1(text = text) @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = UnnamedSchemaWithArrayParent1(unionMember1 = unionMember1) + fun ofImageUrl(imageUrl: ImageUrl) = + UnnamedSchemaWithArrayParent1(imageUrl = imageUrl) } interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitText(text: Text): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent1: $json") + throw BraintrustInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent1: $json" + ) } } - class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent1::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent1 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent1(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return UnnamedSchemaWithArrayParent1(unionMember1 = it, _json = json) - } + class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent1 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent1( + text = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return UnnamedSchemaWithArrayParent1( + imageUrl = it, + _json = json + ) + } - return UnnamedSchemaWithArrayParent1(_json = json) + return UnnamedSchemaWithArrayParent1(_json = json) } } - class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent1::class) { - - override fun serialize(value: UnnamedSchemaWithArrayParent1, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") - } + class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent1, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> + generator.writeObject(value.imageUrl) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent1" + ) + } } } - @JsonDeserialize(builder = UnionMember0.Builder::class) + @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class UnionMember0 private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class Text + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + fun text(): Optional = + Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") - @JsonProperty("text") - @ExcludeMissing - fun _text() = text + @JsonProperty("text") @ExcludeMissing fun _text() = text - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember0 = apply { + fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember0{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - this.text = unionMember0.text - this.type = unionMember0.type - additionalProperties(unionMember0.additionalProperties) + internal fun from(text: Text) = apply { + this.text = text.text + this.type = text.type + additionalProperties(text.additionalProperties) } fun text(text: String) = text(JsonField.of(text)) @@ -4061,43 +4288,50 @@ class PromptUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember0 = UnionMember0( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4108,7 +4342,8 @@ class PromptUpdateParams constructor( @JvmField val TEXT = Type(JsonField.of("text")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4120,23 +4355,33 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TEXT -> Known.TEXT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember1.Builder::class) + @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class UnionMember1 private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4150,68 +4395,71 @@ class PromptUpdateParams constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties - fun validate(): UnionMember1 = apply { + fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember1{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - this.imageUrl = unionMember1.imageUrl - this.type = unionMember1.type - additionalProperties(unionMember1.additionalProperties) + internal fun from(imageUrl: ImageUrl) = apply { + this.imageUrl = imageUrl.imageUrl + this.type = imageUrl.type + additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = + imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -4223,34 +4471,43 @@ class PromptUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember1 = UnionMember1( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { + class ImageUrl + private constructor( + private val url: JsonField, + private val detail: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4258,11 +4515,10 @@ class PromptUpdateParams constructor( fun url(): String = url.getRequired("url") - fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url() = url @JsonProperty("detail") @ExcludeMissing @@ -4270,53 +4526,58 @@ class PromptUpdateParams constructor( @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == + other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { @@ -4333,7 +4594,8 @@ class PromptUpdateParams constructor( this.url = url } - fun detail(detail: Detail) = detail(JsonField.of(detail)) + fun detail(detail: Detail) = + detail(JsonField.of(detail)) @JsonProperty("detail") @ExcludeMissing @@ -4341,39 +4603,52 @@ class PromptUpdateParams constructor( this.detail = detail } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + this.additionalProperties.putAll( + additionalProperties + ) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + fun putAdditionalProperty( + key: String, + value: JsonValue + ) = apply { this.additionalProperties.put(key, value) } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll( + additionalProperties + ) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ImageUrl = ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Detail + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && - this.value == other.value + return other is Detail && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4388,7 +4663,8 @@ class PromptUpdateParams constructor( @JvmField val HIGH = Detail(JsonField.of("high")) - @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Detail(JsonField.of(value)) } enum class Known { @@ -4404,36 +4680,44 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> throw BraintrustInvalidDataException("Unknown Detail: $value") - } + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException( + "Unknown Detail: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4442,9 +4726,11 @@ class PromptUpdateParams constructor( companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField + val IMAGE_URL = Type(JsonField.of("image_url")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } enum class Known { @@ -4456,15 +4742,20 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } @@ -4473,16 +4764,16 @@ class PromptUpdateParams constructor( } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4491,85 +4782,81 @@ class PromptUpdateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("tool_calls") - @ExcludeMissing - fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember2{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4579,25 +4866,24 @@ class PromptUpdateParams constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - this.role = unionMember2.role - this.content = unionMember2.content - this.functionCall = unionMember2.functionCall - this.name = unionMember2.name - this.toolCalls = unionMember2.toolCalls - additionalProperties(unionMember2.additionalProperties) + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -4607,7 +4893,8 @@ class PromptUpdateParams constructor( this.content = content } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -4619,11 +4906,10 @@ class PromptUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -4631,42 +4917,47 @@ class PromptUpdateParams constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember2 = UnionMember2( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -4689,22 +4980,30 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4714,63 +5013,62 @@ class PromptUpdateParams constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { @@ -4779,7 +5077,8 @@ class PromptUpdateParams constructor( additionalProperties(functionCall.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -4791,11 +5090,11 @@ class PromptUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -4805,26 +5104,27 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCall = FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - + class ToolCall + private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4837,63 +5137,59 @@ class PromptUpdateParams constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id - @JsonProperty("function") - @ExcludeMissing - fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function() = function - @JsonProperty("type") - @ExcludeMissing - fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -4901,7 +5197,8 @@ class PromptUpdateParams constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(toolCall: ToolCall) = apply { @@ -4915,9 +5212,7 @@ class PromptUpdateParams constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) @@ -4931,11 +5226,11 @@ class PromptUpdateParams constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -4945,21 +5240,27 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ToolCall = ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = + ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { + class Function + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4973,59 +5274,61 @@ class PromptUpdateParams constructor( @ExcludeMissing fun _arguments() = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: + MutableMap = + mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { @@ -5034,7 +5337,8 @@ class PromptUpdateParams constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = + arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -5046,44 +5350,51 @@ class PromptUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = apply { + fun additionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5106,98 +5417,100 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } fun asString(): String = _value().asStringOrThrow() } } } - @JsonDeserialize(builder = UnionMember3.Builder::class) + @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class UnionMember3 private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("tool_call_id") - @ExcludeMissing - fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember3 = apply { + fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember3 && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember3{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5205,14 +5518,15 @@ class PromptUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - this.content = unionMember3.content - this.role = unionMember3.role - this.toolCallId = unionMember3.toolCallId - additionalProperties(unionMember3.additionalProperties) + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5227,11 +5541,10 @@ class PromptUpdateParams constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + fun toolCallId(toolCallId: String) = + toolCallId(JsonField.of(toolCallId)) @JsonProperty("tool_call_id") @ExcludeMissing @@ -5239,40 +5552,45 @@ class PromptUpdateParams constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember3 = UnionMember3( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5295,97 +5613,96 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember4.Builder::class) + @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class UnionMember4 private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember4 = apply { + fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember4 && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember4{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5393,14 +5710,15 @@ class PromptUpdateParams constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - this.content = unionMember4.content - this.name = unionMember4.name - this.role = unionMember4.role - additionalProperties(unionMember4.additionalProperties) + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) } fun content(content: String) = content(JsonField.of(content)) @@ -5415,52 +5733,53 @@ class PromptUpdateParams constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember4 = UnionMember4( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5483,23 +5802,31 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember5.Builder::class) + @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class UnionMember5 private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5507,80 +5834,77 @@ class PromptUpdateParams constructor( fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role() = role - @JsonProperty("content") - @ExcludeMissing - fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content() = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember5 = apply { + fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember5 && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "UnionMember5{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - this.role = unionMember5.role - this.content = unionMember5.content - additionalProperties(unionMember5.additionalProperties) + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) @@ -5590,39 +5914,44 @@ class PromptUpdateParams constructor( this.content = content } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): UnionMember5 = UnionMember5( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && - this.value == other.value + return other is Role && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5645,33 +5974,39 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> + throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.value == other.value + return other is Type && this.value == other.value } override fun hashCode() = value.hashCode() @@ -5694,23 +6029,28 @@ class PromptUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = + when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } - @JsonDeserialize(builder = UnionMember2.Builder::class) + @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class UnionMember2 private constructor(private val additionalProperties: Map, ) { + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5720,36 +6060,36 @@ class PromptUpdateParams constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): UnionMember2 = apply { + fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember2 && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } - override fun toString() = "UnionMember2{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -5757,8 +6097,8 @@ class PromptUpdateParams constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - additionalProperties(unionMember2.additionalProperties) + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) } fun additionalProperties(additionalProperties: Map) = apply { @@ -5771,11 +6111,13 @@ class PromptUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): UnionMember2 = UnionMember2(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt index 9839bea..9d6fdcf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt @@ -2,57 +2,42 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException /** * A role is a collection of permissions which can be granted as part of an ACL * - * Roles can consist of individual permissions, as well as a set of roles they - * inherit from + * Roles can consist of individual permissions, as well as a set of roles they inherit from */ @JsonDeserialize(builder = Role.Builder::class) @NoAutoDetect -class Role private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val deletedAt: JsonField, - private val memberPermissions: JsonField>, - private val memberRoles: JsonField>, - private val additionalProperties: Map, - +class Role +private constructor( + private val id: JsonField, + private val orgId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val deletedAt: JsonField, + private val memberPermissions: JsonField>, + private val memberRoles: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -65,8 +50,8 @@ class Role private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by any + * other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -82,78 +67,64 @@ class Role private constructor( fun name(): String = name.getRequired("name") /** Textual description of the role */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ - fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = + Optional.ofNullable(memberRoles.getNullable("member_roles")) /** Unique identifier for the role */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by any + * other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId /** Identifies the user who created the role */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** Date of role creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Textual description of the role */ - @JsonProperty("description") - @ExcludeMissing - fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description() = description /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") - @ExcludeMissing - fun _memberPermissions() = memberPermissions + @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions() = memberPermissions /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ - @JsonProperty("member_roles") - @ExcludeMissing - fun _memberRoles() = memberRoles + @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles() = memberRoles @JsonAnyGetter @ExcludeMissing @@ -161,63 +132,64 @@ class Role private constructor( fun validate(): Role = apply { if (!validated) { - id() - orgId() - userId() - created() - name() - description() - deletedAt() - memberPermissions().map { it.forEach { it.validate() } } - memberRoles() - validated = true + id() + orgId() + userId() + created() + name() + description() + deletedAt() + memberPermissions().map { it.forEach { it.validate() } } + memberRoles() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && - this.id == other.id && - this.orgId == other.orgId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.deletedAt == other.deletedAt && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Role && + this.id == other.id && + this.orgId == other.orgId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.deletedAt == other.deletedAt && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberPermissions, - memberRoles, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberPermissions, + memberRoles, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" + override fun toString() = + "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -251,17 +223,13 @@ class Role private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the role */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -270,16 +238,14 @@ class Role private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Identifies the user who created the role */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -287,9 +253,7 @@ class Role private constructor( /** Identifies the user who created the role */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Date of role creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -297,9 +261,7 @@ class Role private constructor( /** Date of role creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) @@ -307,9 +269,7 @@ class Role private constructor( /** Name of the role */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the role */ fun description(description: String) = description(JsonField.of(description)) @@ -317,9 +277,7 @@ class Role private constructor( /** Textual description of the role */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -327,12 +285,11 @@ class Role private constructor( /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List) = memberPermissions(JsonField.of(memberPermissions)) + fun memberPermissions(memberPermissions: List) = + memberPermissions(JsonField.of(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -344,16 +301,16 @@ class Role private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ fun memberRoles(memberRoles: List) = memberRoles(JsonField.of(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing @@ -375,23 +332,29 @@ class Role private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Role = Role( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberPermissions.map { it.toUnmodifiable() }, - memberRoles.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Role = + Role( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberPermissions.map { it.toUnmodifiable() }, + memberRoles.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect - class MemberPermission private constructor(private val permission: JsonField, private val restrictObjectType: JsonField, private val additionalProperties: Map, ) { + class MemberPermission + private constructor( + private val permission: JsonField, + private val restrictObjectType: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -400,23 +363,21 @@ class Role private constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") - @ExcludeMissing - fun _permission() = permission + @JsonProperty("permission") @ExcludeMissing fun _permission() = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -429,42 +390,43 @@ class Role private constructor( fun validate(): MemberPermission = apply { if (!validated) { - permission() - restrictObjectType() - validated = true + permission() + restrictObjectType() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is MemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -483,16 +445,16 @@ class Role private constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ @JsonProperty("permission") @ExcludeMissing @@ -501,7 +463,8 @@ class Role private constructor( } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = restrictObjectType(JsonField.of(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType) = + restrictObjectType(JsonField.of(restrictObjectType)) /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -524,25 +487,28 @@ class Role private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MemberPermission = MemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): MemberPermission = + MemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Permission + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && - this.value == other.value + return other is Permission && this.value == other.value } override fun hashCode() = value.hashCode() @@ -593,45 +559,49 @@ class Role private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class RestrictObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && - this.value == other.value + return other is RestrictObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -694,35 +664,38 @@ class Role private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt index 1fd80a3..289139c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt @@ -2,57 +2,40 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class RoleCreateParams constructor( - private val name: String, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class RoleCreateParams +constructor( + private val name: String, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name fun description(): Optional = Optional.ofNullable(description) - fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions) + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions) fun memberRoles(): Optional> = Optional.ofNullable(memberRoles) @@ -60,43 +43,39 @@ class RoleCreateParams constructor( @JvmSynthetic internal fun getBody(): RoleCreateBody { - return RoleCreateBody( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalBodyProperties, - ) + return RoleCreateBody( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = RoleCreateBody.Builder::class) @NoAutoDetect - class RoleCreateBody internal constructor( - private val name: String?, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalProperties: Map, - + class RoleCreateBody + internal constructor( + private val name: String?, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the role */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Textual description of the role */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -105,19 +84,17 @@ class RoleCreateParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - @JsonProperty("member_roles") - fun memberRoles(): List? = memberRoles + @JsonProperty("member_roles") fun memberRoles(): List? = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - @JsonProperty("org_name") - fun orgName(): String? = orgName + @JsonProperty("org_name") fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -126,39 +103,40 @@ class RoleCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleCreateBody && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RoleCreateBody && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -181,16 +159,11 @@ class RoleCreateParams constructor( } /** Name of the role */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Textual description of the role */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -201,23 +174,19 @@ class RoleCreateParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ @JsonProperty("member_roles") - fun memberRoles(memberRoles: List) = apply { - this.memberRoles = memberRoles - } + fun memberRoles(memberRoles: List) = apply { this.memberRoles = memberRoles } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -233,16 +202,15 @@ class RoleCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RoleCreateBody = RoleCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - memberPermissions?.toUnmodifiable(), - memberRoles?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): RoleCreateBody = + RoleCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + description, + memberPermissions?.toUnmodifiable(), + memberRoles?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -253,42 +221,42 @@ class RoleCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleCreateParams && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleCreateParams && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -316,14 +284,10 @@ class RoleCreateParams constructor( } /** Name of the role */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Textual description of the role */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: List) = apply { @@ -339,8 +303,8 @@ class RoleCreateParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ fun memberRoles(memberRoles: List) = apply { this.memberRoles.clear() @@ -350,21 +314,17 @@ class RoleCreateParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - this.memberRoles.add(memberRole) - } + fun addMemberRole(memberRole: String) = apply { this.memberRoles.add(memberRole) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -404,9 +364,7 @@ class RoleCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -417,38 +375,41 @@ class RoleCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): RoleCreateParams = RoleCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - if(memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), - if(memberRoles.size == 0) null else memberRoles.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): RoleCreateParams = + RoleCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + description, + if (memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), + if (memberRoles.size == 0) null else memberRoles.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect - class MemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { + class MemberPermission + private constructor( + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") - fun permission(): Permission? = permission + @JsonProperty("permission") fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -461,33 +422,34 @@ class RoleCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is MemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -506,13 +468,11 @@ class RoleCreateParams constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { - this.permission = permission - } + fun permission(permission: Permission) = apply { this.permission = permission } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -534,25 +494,28 @@ class RoleCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MemberPermission = MemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): MemberPermission = + MemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Permission + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && - this.value == other.value + return other is Permission && this.value == other.value } override fun hashCode() = value.hashCode() @@ -603,45 +566,49 @@ class RoleCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class RestrictObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && - this.value == other.value + return other is RestrictObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -704,35 +671,38 @@ class RoleCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 292a610..8e8f313 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -2,66 +2,37 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional -class RoleDeleteParams constructor( - private val roleId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class RoleDeleteParams +constructor( + private val roleId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun roleId(): String = roleId @JvmSynthetic internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -71,34 +42,34 @@ class RoleDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleDeleteParams && - this.roleId == other.roleId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleDeleteParams && + this.roleId == other.roleId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - roleId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + roleId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "RoleDeleteParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "RoleDeleteParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -118,9 +89,7 @@ class RoleDeleteParams constructor( } /** Role id */ - fun roleId(roleId: String) = apply { - this.roleId = roleId - } + fun roleId(roleId: String) = apply { this.roleId = roleId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -160,9 +129,7 @@ class RoleDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -173,17 +140,17 @@ class RoleDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): RoleDeleteParams = RoleDeleteParams( - checkNotNull(roleId) { - "`roleId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): RoleDeleteParams = + RoleDeleteParams( + checkNotNull(roleId) { "`roleId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index 80dcd01..d49ae5d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -2,79 +2,77 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.RoleService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Role -import com.braintrustdata.api.services.blocking.RoleService -class RoleListPage private constructor(private val rolesService: RoleService, private val params: RoleListParams, private val response: Response, ) { +class RoleListPage +private constructor( + private val rolesService: RoleService, + private val params: RoleListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleListPage && - this.rolesService == other.rolesService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is RoleListPage && + this.rolesService == other.rolesService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - rolesService, - params, - response, - ) + return Objects.hash( + rolesService, + params, + response, + ) } - override fun toString() = "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = + "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { rolesService.list(it) } + return getNextPageParams().map { rolesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +80,21 @@ class RoleListPage private constructor(private val rolesService: RoleService, pr companion object { @JvmStatic - fun of(rolesService: RoleService, params: RoleListParams, response: Response) = RoleListPage( - rolesService, - params, - response, - ) + fun of(rolesService: RoleService, params: RoleListParams, response: Response) = + RoleListPage( + rolesService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +109,33 @@ class RoleListPage private constructor(private val rolesService: RoleService, pr fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "RoleListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "RoleListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +163,25 @@ class RoleListPage private constructor(private val rolesService: RoleService, pr } } - class AutoPager constructor(private val firstPage: RoleListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: RoleListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index 1efc01a..a53c7f0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -2,83 +2,80 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.RoleServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.Role -import com.braintrustdata.api.services.async.RoleServiceAsync -class RoleListPageAsync private constructor(private val rolesService: RoleServiceAsync, private val params: RoleListParams, private val response: Response, ) { +class RoleListPageAsync +private constructor( + private val rolesService: RoleServiceAsync, + private val params: RoleListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleListPageAsync && - this.rolesService == other.rolesService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is RoleListPageAsync && + this.rolesService == other.rolesService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - rolesService, - params, - response, - ) + return Objects.hash( + rolesService, + params, + response, + ) } - override fun toString() = "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = + "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - rolesService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { rolesService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +83,21 @@ class RoleListPageAsync private constructor(private val rolesService: RoleServic companion object { @JvmStatic - fun of(rolesService: RoleServiceAsync, params: RoleListParams, response: Response) = RoleListPageAsync( - rolesService, - params, - response, - ) + fun of(rolesService: RoleServiceAsync, params: RoleListParams, response: Response) = + RoleListPageAsync( + rolesService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +112,33 @@ class RoleListPageAsync private constructor(private val rolesService: RoleServic fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "RoleListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "RoleListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +166,32 @@ class RoleListPageAsync private constructor(private val rolesService: RoleServic } } - class AutoPager constructor(private val firstPage: RoleListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: RoleListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Role) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (Role) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index c4cc3fc..99c8bad 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -2,51 +2,35 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class RoleListParams constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val roleName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class RoleListParams +constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val roleName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -63,31 +47,18 @@ class RoleListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.roleName?.let { - params.put("role_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.roleName?.let { params.put("role_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -96,44 +67,44 @@ class RoleListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.roleName == other.roleName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.roleName == other.roleName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + roleName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -165,63 +136,47 @@ class RoleListParams constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** Name of the role to search for */ - fun roleName(roleName: String) = apply { - this.roleName = roleName - } + fun roleName(roleName: String) = apply { this.roleName = roleName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -261,9 +216,7 @@ class RoleListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -274,87 +227,93 @@ class RoleListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): RoleListParams = RoleListParams( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): RoleListParams = + RoleListParams( + endingBefore, + ids, + limit, + orgName, + roleName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -364,34 +323,38 @@ class RoleListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt index dc72a2c..02b55e0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt @@ -2,57 +2,40 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class RoleReplaceParams constructor( - private val name: String, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class RoleReplaceParams +constructor( + private val name: String, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name fun description(): Optional = Optional.ofNullable(description) - fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions) + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions) fun memberRoles(): Optional> = Optional.ofNullable(memberRoles) @@ -60,43 +43,39 @@ class RoleReplaceParams constructor( @JvmSynthetic internal fun getBody(): RoleReplaceBody { - return RoleReplaceBody( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalBodyProperties, - ) + return RoleReplaceBody( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = RoleReplaceBody.Builder::class) @NoAutoDetect - class RoleReplaceBody internal constructor( - private val name: String?, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalProperties: Map, - + class RoleReplaceBody + internal constructor( + private val name: String?, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the role */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Textual description of the role */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -105,19 +84,17 @@ class RoleReplaceParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - @JsonProperty("member_roles") - fun memberRoles(): List? = memberRoles + @JsonProperty("member_roles") fun memberRoles(): List? = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - @JsonProperty("org_name") - fun orgName(): String? = orgName + @JsonProperty("org_name") fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -126,39 +103,40 @@ class RoleReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleReplaceBody && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RoleReplaceBody && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -181,16 +159,11 @@ class RoleReplaceParams constructor( } /** Name of the role */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Textual description of the role */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -201,23 +174,19 @@ class RoleReplaceParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ @JsonProperty("member_roles") - fun memberRoles(memberRoles: List) = apply { - this.memberRoles = memberRoles - } + fun memberRoles(memberRoles: List) = apply { this.memberRoles = memberRoles } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -233,16 +202,15 @@ class RoleReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RoleReplaceBody = RoleReplaceBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - memberPermissions?.toUnmodifiable(), - memberRoles?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): RoleReplaceBody = + RoleReplaceBody( + checkNotNull(name) { "`name` is required but was not set" }, + description, + memberPermissions?.toUnmodifiable(), + memberRoles?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -253,42 +221,42 @@ class RoleReplaceParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleReplaceParams && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleReplaceParams && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -316,14 +284,10 @@ class RoleReplaceParams constructor( } /** Name of the role */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Textual description of the role */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: List) = apply { @@ -339,8 +303,8 @@ class RoleReplaceParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ fun memberRoles(memberRoles: List) = apply { this.memberRoles.clear() @@ -350,21 +314,17 @@ class RoleReplaceParams constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - this.memberRoles.add(memberRole) - } + fun addMemberRole(memberRole: String) = apply { this.memberRoles.add(memberRole) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -404,9 +364,7 @@ class RoleReplaceParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -417,38 +375,41 @@ class RoleReplaceParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): RoleReplaceParams = RoleReplaceParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - description, - if(memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), - if(memberRoles.size == 0) null else memberRoles.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): RoleReplaceParams = + RoleReplaceParams( + checkNotNull(name) { "`name` is required but was not set" }, + description, + if (memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), + if (memberRoles.size == 0) null else memberRoles.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect - class MemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { + class MemberPermission + private constructor( + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") - fun permission(): Permission? = permission + @JsonProperty("permission") fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -461,33 +422,34 @@ class RoleReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is MemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -506,13 +468,11 @@ class RoleReplaceParams constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { - this.permission = permission - } + fun permission(permission: Permission) = apply { this.permission = permission } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -534,25 +494,28 @@ class RoleReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MemberPermission = MemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): MemberPermission = + MemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Permission + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && - this.value == other.value + return other is Permission && this.value == other.value } override fun hashCode() = value.hashCode() @@ -603,45 +566,49 @@ class RoleReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class RestrictObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && - this.value == other.value + return other is RestrictObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -704,35 +671,38 @@ class RoleReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 0e245da..eac995d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class RoleRetrieveParams constructor( - private val roleId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class RoleRetrieveParams +constructor( + private val roleId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun roleId(): String = roleId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class RoleRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleRetrieveParams && - this.roleId == other.roleId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleRetrieveParams && + this.roleId == other.roleId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - roleId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + roleId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "RoleRetrieveParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "RoleRetrieveParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class RoleRetrieveParams constructor( } /** Role id */ - fun roleId(roleId: String) = apply { - this.roleId = roleId - } + fun roleId(roleId: String) = apply { this.roleId = roleId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class RoleRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class RoleRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): RoleRetrieveParams = RoleRetrieveParams( - checkNotNull(roleId) { - "`roleId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): RoleRetrieveParams = + RoleRetrieveParams( + checkNotNull(roleId) { "`roleId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt index 48d9a95..a77943e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt @@ -2,57 +2,40 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class RoleUpdateParams constructor( - private val roleId: String, - private val addMemberPermissions: List?, - private val addMemberRoles: List?, - private val description: String?, - private val name: String?, - private val removeMemberPermissions: List?, - private val removeMemberRoles: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class RoleUpdateParams +constructor( + private val roleId: String, + private val addMemberPermissions: List?, + private val addMemberRoles: List?, + private val description: String?, + private val name: String?, + private val removeMemberPermissions: List?, + private val removeMemberRoles: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun roleId(): String = roleId - fun addMemberPermissions(): Optional> = Optional.ofNullable(addMemberPermissions) + fun addMemberPermissions(): Optional> = + Optional.ofNullable(addMemberPermissions) fun addMemberRoles(): Optional> = Optional.ofNullable(addMemberRoles) @@ -60,47 +43,46 @@ class RoleUpdateParams constructor( fun name(): Optional = Optional.ofNullable(name) - fun removeMemberPermissions(): Optional> = Optional.ofNullable(removeMemberPermissions) + fun removeMemberPermissions(): Optional> = + Optional.ofNullable(removeMemberPermissions) fun removeMemberRoles(): Optional> = Optional.ofNullable(removeMemberRoles) @JvmSynthetic internal fun getBody(): RoleUpdateBody { - return RoleUpdateBody( - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalBodyProperties, - ) + return RoleUpdateBody( + addMemberPermissions, + addMemberRoles, + description, + name, + removeMemberPermissions, + removeMemberRoles, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } @JsonDeserialize(builder = RoleUpdateBody.Builder::class) @NoAutoDetect - class RoleUpdateBody internal constructor( - private val addMemberPermissions: List?, - private val addMemberRoles: List?, - private val description: String?, - private val name: String?, - private val removeMemberPermissions: List?, - private val removeMemberRoles: List?, - private val additionalProperties: Map, - + class RoleUpdateBody + internal constructor( + private val addMemberPermissions: List?, + private val addMemberRoles: List?, + private val description: String?, + private val name: String?, + private val removeMemberPermissions: List?, + private val removeMemberRoles: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -110,16 +92,13 @@ class RoleUpdateParams constructor( fun addMemberPermissions(): List? = addMemberPermissions /** A list of role IDs to add to the role's inheriting-from set */ - @JsonProperty("add_member_roles") - fun addMemberRoles(): List? = addMemberRoles + @JsonProperty("add_member_roles") fun addMemberRoles(): List? = addMemberRoles /** Textual description of the role */ - @JsonProperty("description") - fun description(): String? = description + @JsonProperty("description") fun description(): String? = description /** Name of the role */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") @@ -136,41 +115,42 @@ class RoleUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleUpdateBody && - this.addMemberPermissions == other.addMemberPermissions && - this.addMemberRoles == other.addMemberRoles && - this.description == other.description && - this.name == other.name && - this.removeMemberPermissions == other.removeMemberPermissions && - this.removeMemberRoles == other.removeMemberRoles && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RoleUpdateBody && + this.addMemberPermissions == other.addMemberPermissions && + this.addMemberRoles == other.addMemberRoles && + this.description == other.description && + this.name == other.name && + this.removeMemberPermissions == other.removeMemberPermissions && + this.removeMemberRoles == other.removeMemberRoles && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + addMemberPermissions, + addMemberRoles, + description, + name, + removeMemberPermissions, + removeMemberRoles, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" + override fun toString() = + "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -208,21 +188,17 @@ class RoleUpdateParams constructor( /** Textual description of the role */ @JsonProperty("description") - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the role */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") - fun removeMemberPermissions(removeMemberPermissions: List) = apply { - this.removeMemberPermissions = removeMemberPermissions - } + fun removeMemberPermissions(removeMemberPermissions: List) = + apply { + this.removeMemberPermissions = removeMemberPermissions + } /** A list of role IDs to remove from the role's inheriting-from set */ @JsonProperty("remove_member_roles") @@ -244,15 +220,16 @@ class RoleUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RoleUpdateBody = RoleUpdateBody( - addMemberPermissions?.toUnmodifiable(), - addMemberRoles?.toUnmodifiable(), - description, - name, - removeMemberPermissions?.toUnmodifiable(), - removeMemberRoles?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): RoleUpdateBody = + RoleUpdateBody( + addMemberPermissions?.toUnmodifiable(), + addMemberRoles?.toUnmodifiable(), + description, + name, + removeMemberPermissions?.toUnmodifiable(), + removeMemberRoles?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -263,46 +240,46 @@ class RoleUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleUpdateParams && - this.roleId == other.roleId && - this.addMemberPermissions == other.addMemberPermissions && - this.addMemberRoles == other.addMemberRoles && - this.description == other.description && - this.name == other.name && - this.removeMemberPermissions == other.removeMemberPermissions && - this.removeMemberRoles == other.removeMemberRoles && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleUpdateParams && + this.roleId == other.roleId && + this.addMemberPermissions == other.addMemberPermissions && + this.addMemberRoles == other.addMemberRoles && + this.description == other.description && + this.name == other.name && + this.removeMemberPermissions == other.removeMemberPermissions && + this.removeMemberRoles == other.removeMemberRoles && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - roleId, - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + roleId, + addMemberPermissions, + addMemberRoles, + description, + name, + removeMemberPermissions, + removeMemberRoles, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -334,9 +311,7 @@ class RoleUpdateParams constructor( } /** Role id */ - fun roleId(roleId: String) = apply { - this.roleId = roleId - } + fun roleId(roleId: String) = apply { this.roleId = roleId } /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: List) = apply { @@ -361,14 +336,10 @@ class RoleUpdateParams constructor( } /** Textual description of the role */ - fun description(description: String) = apply { - this.description = description - } + fun description(description: String) = apply { this.description = description } /** Name of the role */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** A list of permissions to remove from the role */ fun removeMemberPermissions(removeMemberPermissions: List) = apply { @@ -430,9 +401,7 @@ class RoleUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -443,40 +412,44 @@ class RoleUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): RoleUpdateParams = RoleUpdateParams( - checkNotNull(roleId) { - "`roleId` is required but was not set" - }, - if(addMemberPermissions.size == 0) null else addMemberPermissions.toUnmodifiable(), - if(addMemberRoles.size == 0) null else addMemberRoles.toUnmodifiable(), - description, - name, - if(removeMemberPermissions.size == 0) null else removeMemberPermissions.toUnmodifiable(), - if(removeMemberRoles.size == 0) null else removeMemberRoles.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): RoleUpdateParams = + RoleUpdateParams( + checkNotNull(roleId) { "`roleId` is required but was not set" }, + if (addMemberPermissions.size == 0) null else addMemberPermissions.toUnmodifiable(), + if (addMemberRoles.size == 0) null else addMemberRoles.toUnmodifiable(), + description, + name, + if (removeMemberPermissions.size == 0) null + else removeMemberPermissions.toUnmodifiable(), + if (removeMemberRoles.size == 0) null else removeMemberRoles.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = AddMemberPermission.Builder::class) @NoAutoDetect - class AddMemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { + class AddMemberPermission + private constructor( + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") - fun permission(): Permission? = permission + @JsonProperty("permission") fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -489,33 +462,34 @@ class RoleUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AddMemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -534,13 +508,11 @@ class RoleUpdateParams constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { - this.permission = permission - } + fun permission(permission: Permission) = apply { this.permission = permission } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -562,25 +534,28 @@ class RoleUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): AddMemberPermission = AddMemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): AddMemberPermission = + AddMemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Permission + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && - this.value == other.value + return other is Permission && this.value == other.value } override fun hashCode() = value.hashCode() @@ -631,45 +606,49 @@ class RoleUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class RestrictObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && - this.value == other.value + return other is RestrictObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -732,35 +711,38 @@ class RoleUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -768,18 +750,21 @@ class RoleUpdateParams constructor( @JsonDeserialize(builder = RemoveMemberPermission.Builder::class) @NoAutoDetect - class RemoveMemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { + class RemoveMemberPermission + private constructor( + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") - fun permission(): Permission? = permission + @JsonProperty("permission") fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -792,33 +777,34 @@ class RoleUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RemoveMemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -837,13 +823,11 @@ class RoleUpdateParams constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped - * into roles + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { - this.permission = permission - } + fun permission(permission: Permission) = apply { this.permission = permission } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -865,25 +849,28 @@ class RoleUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RemoveMemberPermission = RemoveMemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): RemoveMemberPermission = + RemoveMemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class Permission + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && - this.value == other.value + return other is Permission && this.value == other.value } override fun hashCode() = value.hashCode() @@ -934,45 +921,49 @@ class RoleUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = + when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class RestrictObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && - this.value == other.value + return other is RestrictObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1035,35 +1026,38 @@ class RoleUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 7ed7446..ec0e8bd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -2,47 +2,22 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class TopLevelHelloWorldParams constructor(private val additionalQueryParams: Map>, private val additionalHeaders: Map>, private val additionalBodyProperties: Map, ) { +class TopLevelHelloWorldParams +constructor( + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -51,32 +26,32 @@ class TopLevelHelloWorldParams constructor(private val additionalQueryParams: Ma fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TopLevelHelloWorldParams && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is TopLevelHelloWorldParams && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "TopLevelHelloWorldParams{additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "TopLevelHelloWorldParams{additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -131,9 +106,7 @@ class TopLevelHelloWorldParams constructor(private val additionalQueryParams: Ma additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -144,14 +117,16 @@ class TopLevelHelloWorldParams constructor(private val additionalQueryParams: Ma this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): TopLevelHelloWorldParams = TopLevelHelloWorldParams( - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): TopLevelHelloWorldParams = + TopLevelHelloWorldParams( + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index dd72dcf..c254ff9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -2,48 +2,31 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect -class User private constructor( - private val id: JsonField, - private val givenName: JsonField, - private val familyName: JsonField, - private val email: JsonField, - private val avatarUrl: JsonField, - private val created: JsonField, - private val additionalProperties: Map, - +class User +private constructor( + private val id: JsonField, + private val givenName: JsonField, + private val familyName: JsonField, + private val email: JsonField, + private val avatarUrl: JsonField, + private val created: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -69,34 +52,22 @@ class User private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Unique identifier for the user */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** Given name of the user */ - @JsonProperty("given_name") - @ExcludeMissing - fun _givenName() = givenName + @JsonProperty("given_name") @ExcludeMissing fun _givenName() = givenName /** Family name of the user */ - @JsonProperty("family_name") - @ExcludeMissing - fun _familyName() = familyName + @JsonProperty("family_name") @ExcludeMissing fun _familyName() = familyName /** The user's email */ - @JsonProperty("email") - @ExcludeMissing - fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email() = email /** URL of the user's Avatar image */ - @JsonProperty("avatar_url") - @ExcludeMissing - fun _avatarUrl() = avatarUrl + @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl() = avatarUrl /** Date of user creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created @JsonAnyGetter @ExcludeMissing @@ -104,54 +75,55 @@ class User private constructor( fun validate(): User = apply { if (!validated) { - id() - givenName() - familyName() - email() - avatarUrl() - created() - validated = true + id() + givenName() + familyName() + email() + avatarUrl() + created() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is User && - this.id == other.id && - this.givenName == other.givenName && - this.familyName == other.familyName && - this.email == other.email && - this.avatarUrl == other.avatarUrl && - this.created == other.created && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is User && + this.id == other.id && + this.givenName == other.givenName && + this.familyName == other.familyName && + this.email == other.email && + this.avatarUrl == other.avatarUrl && + this.created == other.created && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - givenName, - familyName, - email, - avatarUrl, - created, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + givenName, + familyName, + email, + avatarUrl, + created, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" + override fun toString() = + "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -179,11 +151,7 @@ class User private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the user */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Given name of the user */ fun givenName(givenName: String) = givenName(JsonField.of(givenName)) @@ -191,9 +159,7 @@ class User private constructor( /** Given name of the user */ @JsonProperty("given_name") @ExcludeMissing - fun givenName(givenName: JsonField) = apply { - this.givenName = givenName - } + fun givenName(givenName: JsonField) = apply { this.givenName = givenName } /** Family name of the user */ fun familyName(familyName: String) = familyName(JsonField.of(familyName)) @@ -201,9 +167,7 @@ class User private constructor( /** Family name of the user */ @JsonProperty("family_name") @ExcludeMissing - fun familyName(familyName: JsonField) = apply { - this.familyName = familyName - } + fun familyName(familyName: JsonField) = apply { this.familyName = familyName } /** The user's email */ fun email(email: String) = email(JsonField.of(email)) @@ -211,9 +175,7 @@ class User private constructor( /** The user's email */ @JsonProperty("email") @ExcludeMissing - fun email(email: JsonField) = apply { - this.email = email - } + fun email(email: JsonField) = apply { this.email = email } /** URL of the user's Avatar image */ fun avatarUrl(avatarUrl: String) = avatarUrl(JsonField.of(avatarUrl)) @@ -221,9 +183,7 @@ class User private constructor( /** URL of the user's Avatar image */ @JsonProperty("avatar_url") @ExcludeMissing - fun avatarUrl(avatarUrl: JsonField) = apply { - this.avatarUrl = avatarUrl - } + fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } /** Date of user creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -231,9 +191,7 @@ class User private constructor( /** Date of user creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -249,14 +207,15 @@ class User private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): User = User( - id, - givenName, - familyName, - email, - avatarUrl, - created, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = + User( + id, + givenName, + familyName, + email, + avatarUrl, + created, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 96010d5..75c893f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -2,79 +2,77 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.UserService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.User -import com.braintrustdata.api.services.blocking.UserService -class UserListPage private constructor(private val usersService: UserService, private val params: UserListParams, private val response: Response, ) { +class UserListPage +private constructor( + private val usersService: UserService, + private val params: UserListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserListPage && - this.usersService == other.usersService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is UserListPage && + this.usersService == other.usersService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - usersService, - params, - response, - ) + return Objects.hash( + usersService, + params, + response, + ) } - override fun toString() = "UserListPage{usersService=$usersService, params=$params, response=$response}" + override fun toString() = + "UserListPage{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + UserListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + UserListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { usersService.list(it) } + return getNextPageParams().map { usersService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +80,21 @@ class UserListPage private constructor(private val usersService: UserService, pr companion object { @JvmStatic - fun of(usersService: UserService, params: UserListParams, response: Response) = UserListPage( - usersService, - params, - response, - ) + fun of(usersService: UserService, params: UserListParams, response: Response) = + UserListPage( + usersService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +109,33 @@ class UserListPage private constructor(private val usersService: UserService, pr fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "UserListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "UserListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +163,25 @@ class UserListPage private constructor(private val usersService: UserService, pr } } - class AutoPager constructor(private val firstPage: UserListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: UserListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 729cb8e..330014e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -2,83 +2,80 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.UserServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.User -import com.braintrustdata.api.services.async.UserServiceAsync -class UserListPageAsync private constructor(private val usersService: UserServiceAsync, private val params: UserListParams, private val response: Response, ) { +class UserListPageAsync +private constructor( + private val usersService: UserServiceAsync, + private val params: UserListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserListPageAsync && - this.usersService == other.usersService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is UserListPageAsync && + this.usersService == other.usersService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - usersService, - params, - response, - ) + return Objects.hash( + usersService, + params, + response, + ) } - override fun toString() = "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" + override fun toString() = + "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + UserListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + UserListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - usersService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { usersService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +83,21 @@ class UserListPageAsync private constructor(private val usersService: UserServic companion object { @JvmStatic - fun of(usersService: UserServiceAsync, params: UserListParams, response: Response) = UserListPageAsync( - usersService, - params, - response, - ) + fun of(usersService: UserServiceAsync, params: UserListParams, response: Response) = + UserListPageAsync( + usersService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +112,33 @@ class UserListPageAsync private constructor(private val usersService: UserServic fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "UserListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "UserListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +166,32 @@ class UserListPageAsync private constructor(private val usersService: UserServic } } - class AutoPager constructor(private val firstPage: UserListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: UserListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (User) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (User) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 660e622..c4c09bc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -2,62 +2,46 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class UserListParams constructor( - private val email: String?, - private val endingBefore: String?, - private val familyName: String?, - private val givenName: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class UserListParams +constructor( + private val email: Email?, + private val endingBefore: String?, + private val familyName: FamilyName?, + private val givenName: GivenName?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { - fun email(): Optional = Optional.ofNullable(email) + fun email(): Optional = Optional.ofNullable(email) fun endingBefore(): Optional = Optional.ofNullable(endingBefore) - fun familyName(): Optional = Optional.ofNullable(familyName) + fun familyName(): Optional = Optional.ofNullable(familyName) - fun givenName(): Optional = Optional.ofNullable(givenName) + fun givenName(): Optional = Optional.ofNullable(givenName) fun ids(): Optional = Optional.ofNullable(ids) @@ -69,37 +53,20 @@ class UserListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.email?.let { - params.put("email", listOf(it.toString())) - } - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.familyName?.let { - params.put("family_name", listOf(it.toString())) - } - this.givenName?.let { - params.put("given_name", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.orgName?.let { - params.put("org_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.email?.let { params.put("email", listOf(it.toString())) } + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.familyName?.let { params.put("family_name", listOf(it.toString())) } + this.givenName?.let { params.put("given_name", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.orgName?.let { params.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -108,57 +75,57 @@ class UserListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserListParams && - this.email == other.email && - this.endingBefore == other.endingBefore && - this.familyName == other.familyName && - this.givenName == other.givenName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is UserListParams && + this.email == other.email && + this.endingBefore == other.endingBefore && + this.familyName == other.familyName && + this.givenName == other.givenName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + email, + endingBefore, + familyName, + givenName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect class Builder { - private var email: String? = null + private var email: Email? = null private var endingBefore: String? = null - private var familyName: String? = null - private var givenName: String? = null + private var familyName: FamilyName? = null + private var givenName: GivenName? = null private var ids: Ids? = null private var limit: Long? = null private var orgName: String? = null @@ -182,76 +149,105 @@ class UserListParams constructor( additionalBodyProperties(userListParams.additionalBodyProperties) } - /** Email of the user to search for */ - fun email(email: String) = apply { - this.email = email - } + /** + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email + */ + fun email(email: Email) = apply { this.email = email } + + /** + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email + */ + fun email(string: String) = apply { this.email = Email.ofString(string) } + + /** + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email + */ + fun email(strings: List) = apply { this.email = Email.ofStrings(strings) } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } - /** Family name of the user to search for */ - fun familyName(familyName: String) = apply { - this.familyName = familyName - } + /** + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name + */ + fun familyName(familyName: FamilyName) = apply { this.familyName = familyName } - /** Given name of the user to search for */ - fun givenName(givenName: String) = apply { - this.givenName = givenName - } + /** + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name + */ + fun familyName(string: String) = apply { this.familyName = FamilyName.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name */ - fun ids(ids: Ids) = apply { - this.ids = ids + fun familyName(strings: List) = apply { + this.familyName = FamilyName.ofStrings(strings) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun givenName(givenName: GivenName) = apply { this.givenName = givenName } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) + fun givenName(string: String) = apply { this.givenName = GivenName.ofString(string) } + + /** + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name + */ + fun givenName(strings: List) = apply { + this.givenName = GivenName.ofStrings(strings) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids) = apply { this.ids = ids } + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { - this.orgName = orgName - } + fun orgName(orgName: String) = apply { this.orgName = orgName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -291,9 +287,7 @@ class UserListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -304,89 +298,438 @@ class UserListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): UserListParams = + UserListParams( + email, + endingBefore, + familyName, + givenName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = Email.Deserializer::class) + @JsonSerialize(using = Email.Serializer::class) + class Email + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } - fun build(): UserListParams = UserListParams( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun validate(): Email = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Email: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Email && this.string == other.string && this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash(string, strings) + } + + override fun toString(): String { + return when { + string != null -> "Email{string=$string}" + strings != null -> "Email{strings=$strings}" + _json != null -> "Email{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Email") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Email(string = string) + + @JvmStatic fun ofStrings(strings: List) = Email(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Email: $json") + } + } + + class Deserializer : BaseDeserializer(Email::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Email { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Email(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Email(strings = it, _json = json) + } + + return Email(_json = json) + } + } + + class Serializer : BaseSerializer(Email::class) { + + override fun serialize( + value: Email, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Email") + } + } + } + } + + @JsonDeserialize(using = FamilyName.Deserializer::class) + @JsonSerialize(using = FamilyName.Serializer::class) + class FamilyName + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): FamilyName = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown FamilyName: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FamilyName && + this.string == other.string && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash(string, strings) + } + + override fun toString(): String { + return when { + string != null -> "FamilyName{string=$string}" + strings != null -> "FamilyName{strings=$strings}" + _json != null -> "FamilyName{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FamilyName") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = FamilyName(string = string) + + @JvmStatic fun ofStrings(strings: List) = FamilyName(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown FamilyName: $json") + } + } + + class Deserializer : BaseDeserializer(FamilyName::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FamilyName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return FamilyName(strings = it, _json = json) + } + + return FamilyName(_json = json) + } + } + + class Serializer : BaseSerializer(FamilyName::class) { + + override fun serialize( + value: FamilyName, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FamilyName") + } + } + } + } + + @JsonDeserialize(using = GivenName.Deserializer::class) + @JsonSerialize(using = GivenName.Serializer::class) + class GivenName + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): GivenName = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown GivenName: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GivenName && + this.string == other.string && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash(string, strings) + } + + override fun toString(): String { + return when { + string != null -> "GivenName{string=$string}" + strings != null -> "GivenName{strings=$strings}" + _json != null -> "GivenName{_unknown=$_json}" + else -> throw IllegalStateException("Invalid GivenName") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = GivenName(string = string) + + @JvmStatic fun ofStrings(strings: List) = GivenName(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown GivenName: $json") + } + } + + class Deserializer : BaseDeserializer(GivenName::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): GivenName { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return GivenName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return GivenName(strings = it, _json = json) + } + + return GivenName(_json = json) + } + } + + class Serializer : BaseSerializer(GivenName::class) { + + override fun serialize( + value: GivenName, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid GivenName") + } + } + } } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -396,34 +739,38 @@ class UserListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index f79dc32..2d26c6c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -2,61 +2,31 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* +import java.util.Objects -class UserRetrieveParams constructor( - private val userId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class UserRetrieveParams +constructor( + private val userId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun userId(): String = userId - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> userId - else -> "" - } + return when (index) { + 0 -> userId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -66,34 +36,34 @@ class UserRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserRetrieveParams && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is UserRetrieveParams && + this.userId == other.userId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - userId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + userId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "UserRetrieveParams{userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "UserRetrieveParams{userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -113,9 +83,7 @@ class UserRetrieveParams constructor( } /** User id */ - fun userId(userId: String) = apply { - this.userId = userId - } + fun userId(userId: String) = apply { this.userId = userId } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -155,9 +123,7 @@ class UserRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -168,17 +134,17 @@ class UserRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): UserRetrieveParams = UserRetrieveParams( - checkNotNull(userId) { - "`userId` is required but was not set" - }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): UserRetrieveParams = + UserRetrieveParams( + checkNotNull(userId) { "`userId` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt index dd4bd36..627fc0c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/View.kt @@ -2,52 +2,38 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = View.Builder::class) @NoAutoDetect -class View private constructor( - private val id: JsonField, - private val objectType: JsonField, - private val objectId: JsonField, - private val viewType: JsonField, - private val name: JsonField, - private val created: JsonField, - private val viewData: JsonField, - private val options: JsonField, - private val userId: JsonField, - private val deletedAt: JsonField, - private val additionalProperties: Map, - +class View +private constructor( + private val id: JsonField, + private val objectType: JsonField, + private val objectId: JsonField, + private val viewType: JsonField, + private val name: JsonField, + private val created: JsonField, + private val viewData: JsonField, + private val options: JsonField, + private val userId: JsonField, + private val deletedAt: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -58,7 +44,8 @@ class View private constructor( fun id(): String = id.getRequired("id") /** The object type that the ACL applies to */ - fun objectType(): Optional = Optional.ofNullable(objectType.getNullable("object_type")) + fun objectType(): Optional = + Optional.ofNullable(objectType.getNullable("object_type")) /** The id of the object the view applies to */ fun objectId(): String = objectId.getRequired("object_id") @@ -82,57 +69,38 @@ class View private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Unique identifier for the view */ - @JsonProperty("id") - @ExcludeMissing - fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id() = id /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType() = objectType + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId() = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun _viewType() = viewType + @JsonProperty("view_type") @ExcludeMissing fun _viewType() = viewType /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name() = name /** Date of view creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created() = created /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun _viewData() = viewData + @JsonProperty("view_data") @ExcludeMissing fun _viewData() = viewData /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing - fun _options() = options + @JsonProperty("options") @ExcludeMissing fun _options() = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt @JsonAnyGetter @ExcludeMissing @@ -140,66 +108,67 @@ class View private constructor( fun validate(): View = apply { if (!validated) { - id() - objectType() - objectId() - viewType() - name() - created() - viewData().map { it.validate() } - options().map { it.validate() } - userId() - deletedAt() - validated = true + id() + objectType() + objectId() + viewType() + name() + created() + viewData().map { it.validate() } + options().map { it.validate() } + userId() + deletedAt() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is View && - this.id == other.id && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.viewType == other.viewType && - this.name == other.name && - this.created == other.created && - this.viewData == other.viewData && - this.options == other.options && - this.userId == other.userId && - this.deletedAt == other.deletedAt && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is View && + this.id == other.id && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.viewType == other.viewType && + this.name == other.name && + this.created == other.created && + this.viewData == other.viewData && + this.options == other.options && + this.userId == other.userId && + this.deletedAt == other.deletedAt && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - id, - objectType, - objectId, - viewType, - name, - created, - viewData, - options, - userId, - deletedAt, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + objectType, + objectId, + viewType, + name, + created, + viewData, + options, + userId, + deletedAt, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" + override fun toString() = + "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -235,11 +204,7 @@ class View private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the view */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { - this.id = id - } + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) @@ -247,9 +212,7 @@ class View private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) @@ -257,9 +220,7 @@ class View private constructor( /** The id of the object the view applies to */ @JsonProperty("object_id") @ExcludeMissing - fun objectId(objectId: JsonField) = apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType) = viewType(JsonField.of(viewType)) @@ -267,9 +228,7 @@ class View private constructor( /** Type of table that the view corresponds to. */ @JsonProperty("view_type") @ExcludeMissing - fun viewType(viewType: JsonField) = apply { - this.viewType = viewType - } + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) @@ -277,9 +236,7 @@ class View private constructor( /** Name of the view */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Date of view creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -287,9 +244,7 @@ class View private constructor( /** Date of view creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** The view definition */ fun viewData(viewData: ViewData) = viewData(JsonField.of(viewData)) @@ -297,9 +252,7 @@ class View private constructor( /** The view definition */ @JsonProperty("view_data") @ExcludeMissing - fun viewData(viewData: JsonField) = apply { - this.viewData = viewData - } + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } /** Options for the view in the app */ fun options(options: Options) = options(JsonField.of(options)) @@ -307,9 +260,7 @@ class View private constructor( /** Options for the view in the app */ @JsonProperty("options") @ExcludeMissing - fun options(options: JsonField) = apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -317,9 +268,7 @@ class View private constructor( /** Identifies the user who created the view */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -327,9 +276,7 @@ class View private constructor( /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -345,33 +292,36 @@ class View private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): View = View( - id, - objectType, - objectId, - viewType, - name, - created, - viewData, - options, - userId, - deletedAt, - additionalProperties.toUnmodifiable(), - ) + fun build(): View = + View( + id, + objectType, + objectId, + viewType, + name, + created, + viewData, + options, + userId, + deletedAt, + additionalProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -434,51 +384,55 @@ class View private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ViewType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && - this.value == other.value + return other is ViewType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -529,29 +483,31 @@ class View private constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -559,35 +515,32 @@ class View private constructor( /** Options for the view in the app */ @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val columnVisibility: JsonField, - private val columnOrder: JsonField>, - private val columnSizing: JsonField, - private val additionalProperties: Map, - + class Options + private constructor( + private val columnVisibility: JsonField, + private val columnOrder: JsonField>, + private val columnSizing: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + fun columnVisibility(): Optional = + Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) - fun columnOrder(): Optional> = Optional.ofNullable(columnOrder.getNullable("columnOrder")) + fun columnOrder(): Optional> = + Optional.ofNullable(columnOrder.getNullable("columnOrder")) - fun columnSizing(): Optional = Optional.ofNullable(columnSizing.getNullable("columnSizing")) + fun columnSizing(): Optional = + Optional.ofNullable(columnSizing.getNullable("columnSizing")) - @JsonProperty("columnVisibility") - @ExcludeMissing - fun _columnVisibility() = columnVisibility + @JsonProperty("columnVisibility") @ExcludeMissing fun _columnVisibility() = columnVisibility - @JsonProperty("columnOrder") - @ExcludeMissing - fun _columnOrder() = columnOrder + @JsonProperty("columnOrder") @ExcludeMissing fun _columnOrder() = columnOrder - @JsonProperty("columnSizing") - @ExcludeMissing - fun _columnSizing() = columnSizing + @JsonProperty("columnSizing") @ExcludeMissing fun _columnSizing() = columnSizing @JsonAnyGetter @ExcludeMissing @@ -595,45 +548,46 @@ class View private constructor( fun validate(): Options = apply { if (!validated) { - columnVisibility().map { it.validate() } - columnOrder() - columnSizing().map { it.validate() } - validated = true + columnVisibility().map { it.validate() } + columnOrder() + columnSizing().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.columnVisibility == other.columnVisibility && - this.columnOrder == other.columnOrder && - this.columnSizing == other.columnSizing && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.columnVisibility == other.columnVisibility && + this.columnOrder == other.columnOrder && + this.columnSizing == other.columnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - columnVisibility, - columnOrder, - columnSizing, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + columnVisibility, + columnOrder, + columnSizing, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -651,7 +605,8 @@ class View private constructor( additionalProperties(options.additionalProperties) } - fun columnVisibility(columnVisibility: ColumnVisibility) = columnVisibility(JsonField.of(columnVisibility)) + fun columnVisibility(columnVisibility: ColumnVisibility) = + columnVisibility(JsonField.of(columnVisibility)) @JsonProperty("columnVisibility") @ExcludeMissing @@ -689,17 +644,21 @@ class View private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Options = Options( - columnVisibility, - columnOrder.map { it.toUnmodifiable() }, - columnSizing, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + columnVisibility, + columnOrder.map { it.toUnmodifiable() }, + columnSizing, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ColumnSizing.Builder::class) @NoAutoDetect - class ColumnSizing private constructor(private val additionalProperties: Map, ) { + class ColumnSizing + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -711,34 +670,33 @@ class View private constructor( fun validate(): ColumnSizing = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnSizing && - this.additionalProperties == other.additionalProperties + return other is ColumnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -760,9 +718,10 @@ class View private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): ColumnSizing = ColumnSizing(additionalProperties.toUnmodifiable()) } @@ -770,7 +729,10 @@ class View private constructor( @JsonDeserialize(builder = ColumnVisibility.Builder::class) @NoAutoDetect - class ColumnVisibility private constructor(private val additionalProperties: Map, ) { + class ColumnVisibility + private constructor( + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -782,34 +744,33 @@ class View private constructor( fun validate(): ColumnVisibility = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnVisibility && - this.additionalProperties == other.additionalProperties + return other is ColumnVisibility && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -831,11 +792,13 @@ class View private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toUnmodifiable()) + fun build(): ColumnVisibility = + ColumnVisibility(additionalProperties.toUnmodifiable()) } } } @@ -843,7 +806,11 @@ class View private constructor( /** The view definition */ @JsonDeserialize(builder = ViewData.Builder::class) @NoAutoDetect - class ViewData private constructor(private val search: JsonField, private val additionalProperties: Map, ) { + class ViewData + private constructor( + private val search: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -851,9 +818,7 @@ class View private constructor( fun search(): Optional = Optional.ofNullable(search.getNullable("search")) - @JsonProperty("search") - @ExcludeMissing - fun _search() = search + @JsonProperty("search") @ExcludeMissing fun _search() = search @JsonAnyGetter @ExcludeMissing @@ -861,36 +826,36 @@ class View private constructor( fun validate(): ViewData = apply { if (!validated) { - search().map { it.validate() } - validated = true + search().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewData && - this.search == other.search && - this.additionalProperties == other.additionalProperties + return other is ViewData && + this.search == other.search && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(search, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(search, additionalProperties) + } + return hashCode } - override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewData{search=$search, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -908,9 +873,7 @@ class View private constructor( @JsonProperty("search") @ExcludeMissing - fun search(search: JsonField) = apply { - this.search = search - } + fun search(search: JsonField) = apply { this.search = search } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -931,20 +894,21 @@ class View private constructor( @JsonDeserialize(builder = Search.Builder::class) @NoAutoDetect - class Search private constructor( - private val filter: JsonField>, - private val tag: JsonField>, - private val match: JsonField>, - private val sort: JsonField>, - private val additionalProperties: Map, - + class Search + private constructor( + private val filter: JsonField>, + private val tag: JsonField>, + private val match: JsonField>, + private val sort: JsonField>, + private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 - fun filter(): Optional> = Optional.ofNullable(filter.getNullable("filter")) + fun filter(): Optional> = + Optional.ofNullable(filter.getNullable("filter")) fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) @@ -952,21 +916,13 @@ class View private constructor( fun sort(): Optional> = Optional.ofNullable(sort.getNullable("sort")) - @JsonProperty("filter") - @ExcludeMissing - fun _filter() = filter + @JsonProperty("filter") @ExcludeMissing fun _filter() = filter - @JsonProperty("tag") - @ExcludeMissing - fun _tag() = tag + @JsonProperty("tag") @ExcludeMissing fun _tag() = tag - @JsonProperty("match") - @ExcludeMissing - fun _match() = match + @JsonProperty("match") @ExcludeMissing fun _match() = match - @JsonProperty("sort") - @ExcludeMissing - fun _sort() = sort + @JsonProperty("sort") @ExcludeMissing fun _sort() = sort @JsonAnyGetter @ExcludeMissing @@ -974,48 +930,49 @@ class View private constructor( fun validate(): Search = apply { if (!validated) { - filter() - tag() - match() - sort() - validated = true + filter() + tag() + match() + sort() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Search && - this.filter == other.filter && - this.tag == other.tag && - this.match == other.match && - this.sort == other.sort && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Search && + this.filter == other.filter && + this.tag == other.tag && + this.match == other.match && + this.sort == other.sort && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - filter, - tag, - match, - sort, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + filter, + tag, + match, + sort, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" + override fun toString() = + "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1039,33 +996,25 @@ class View private constructor( @JsonProperty("filter") @ExcludeMissing - fun filter(filter: JsonField>) = apply { - this.filter = filter - } + fun filter(filter: JsonField>) = apply { this.filter = filter } fun tag(tag: List) = tag(JsonField.of(tag)) @JsonProperty("tag") @ExcludeMissing - fun tag(tag: JsonField>) = apply { - this.tag = tag - } + fun tag(tag: JsonField>) = apply { this.tag = tag } fun match(match: List) = match(JsonField.of(match)) @JsonProperty("match") @ExcludeMissing - fun match(match: JsonField>) = apply { - this.match = match - } + fun match(match: JsonField>) = apply { this.match = match } fun sort(sort: List) = sort(JsonField.of(sort)) @JsonProperty("sort") @ExcludeMissing - fun sort(sort: JsonField>) = apply { - this.sort = sort - } + fun sort(sort: JsonField>) = apply { this.sort = sort } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1077,17 +1026,19 @@ class View private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Search = Search( - filter.map { it.toUnmodifiable() }, - tag.map { it.toUnmodifiable() }, - match.map { it.toUnmodifiable() }, - sort.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Search = + Search( + filter.map { it.toUnmodifiable() }, + tag.map { it.toUnmodifiable() }, + match.map { it.toUnmodifiable() }, + sort.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt index 479983c..5d02dcf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt @@ -2,53 +2,36 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ViewCreateParams constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: Options?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ViewCreateParams +constructor( + private val name: String, + private val objectId: String, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: Options?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -69,73 +52,63 @@ class ViewCreateParams constructor( @JvmSynthetic internal fun getBody(): ViewCreateBody { - return ViewCreateBody( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalBodyProperties, - ) + return ViewCreateBody( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ViewCreateBody.Builder::class) @NoAutoDetect - class ViewCreateBody internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: Options?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalProperties: Map, - + class ViewCreateBody + internal constructor( + private val name: String?, + private val objectId: String?, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: Options?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the view */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(): String? = objectId + @JsonProperty("object_id") fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") fun objectType(): ObjectType? = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - fun viewType(): ViewType? = viewType + @JsonProperty("view_type") fun viewType(): ViewType? = viewType /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - fun deletedAt(): OffsetDateTime? = deletedAt + @JsonProperty("deleted_at") fun deletedAt(): OffsetDateTime? = deletedAt /** Options for the view in the app */ - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - fun userId(): String? = userId + @JsonProperty("user_id") fun userId(): String? = userId /** The view definition */ - @JsonProperty("view_data") - fun viewData(): ViewData? = viewData + @JsonProperty("view_data") fun viewData(): ViewData? = viewData @JsonAnyGetter @ExcludeMissing @@ -144,45 +117,46 @@ class ViewCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewCreateBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewCreateBody && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -211,52 +185,34 @@ class ViewCreateParams constructor( } /** Name of the view */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** Type of table that the view corresponds to. */ @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") - fun deletedAt(deletedAt: OffsetDateTime) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } /** Options for the view in the app */ @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } /** Identifies the user who created the view */ - @JsonProperty("user_id") - fun userId(userId: String) = apply { - this.userId = userId - } + @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } /** The view definition */ @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { - this.viewData = viewData - } + fun viewData(viewData: ViewData) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -272,21 +228,18 @@ class ViewCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewCreateBody = ViewCreateBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewCreateBody = + ViewCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties.toUnmodifiable(), + ) } } @@ -297,48 +250,48 @@ class ViewCreateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewCreateParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewCreateParams && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -372,44 +325,28 @@ class ViewCreateParams constructor( } /** Name of the view */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } /** Options for the view in the app */ - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { - this.userId = userId - } + fun userId(userId: String) = apply { this.userId = userId } /** The view definition */ - fun viewData(viewData: ViewData) = apply { - this.viewData = viewData - } + fun viewData(viewData: ViewData) = apply { this.viewData = viewData } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -449,9 +386,7 @@ class ViewCreateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -462,41 +397,41 @@ class ViewCreateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewCreateParams = ViewCreateParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewCreateParams = + ViewCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -559,51 +494,55 @@ class ViewCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ViewType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && - this.value == other.value + return other is ViewType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -654,29 +593,31 @@ class ViewCreateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -684,12 +625,12 @@ class ViewCreateParams constructor( /** Options for the view in the app */ @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val columnVisibility: ColumnVisibility?, - private val columnOrder: List?, - private val columnSizing: ColumnSizing?, - private val additionalProperties: Map, - + class Options + private constructor( + private val columnVisibility: ColumnVisibility?, + private val columnOrder: List?, + private val columnSizing: ColumnSizing?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -697,11 +638,9 @@ class ViewCreateParams constructor( @JsonProperty("columnVisibility") fun columnVisibility(): ColumnVisibility? = columnVisibility - @JsonProperty("columnOrder") - fun columnOrder(): List? = columnOrder + @JsonProperty("columnOrder") fun columnOrder(): List? = columnOrder - @JsonProperty("columnSizing") - fun columnSizing(): ColumnSizing? = columnSizing + @JsonProperty("columnSizing") fun columnSizing(): ColumnSizing? = columnSizing @JsonAnyGetter @ExcludeMissing @@ -710,35 +649,36 @@ class ViewCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.columnVisibility == other.columnVisibility && - this.columnOrder == other.columnOrder && - this.columnSizing == other.columnSizing && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.columnVisibility == other.columnVisibility && + this.columnOrder == other.columnOrder && + this.columnSizing == other.columnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - columnVisibility, - columnOrder, - columnSizing, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + columnVisibility, + columnOrder, + columnSizing, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -762,9 +702,7 @@ class ViewCreateParams constructor( } @JsonProperty("columnOrder") - fun columnOrder(columnOrder: List) = apply { - this.columnOrder = columnOrder - } + fun columnOrder(columnOrder: List) = apply { this.columnOrder = columnOrder } @JsonProperty("columnSizing") fun columnSizing(columnSizing: ColumnSizing) = apply { @@ -785,17 +723,21 @@ class ViewCreateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Options = Options( - columnVisibility, - columnOrder?.toUnmodifiable(), - columnSizing, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + columnVisibility, + columnOrder?.toUnmodifiable(), + columnSizing, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ColumnSizing.Builder::class) @NoAutoDetect - class ColumnSizing private constructor(private val additionalProperties: Map, ) { + class ColumnSizing + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -806,27 +748,26 @@ class ViewCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnSizing && - this.additionalProperties == other.additionalProperties + return other is ColumnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -848,9 +789,10 @@ class ViewCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): ColumnSizing = ColumnSizing(additionalProperties.toUnmodifiable()) } @@ -858,7 +800,10 @@ class ViewCreateParams constructor( @JsonDeserialize(builder = ColumnVisibility.Builder::class) @NoAutoDetect - class ColumnVisibility private constructor(private val additionalProperties: Map, ) { + class ColumnVisibility + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -869,27 +814,26 @@ class ViewCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnVisibility && - this.additionalProperties == other.additionalProperties + return other is ColumnVisibility && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -911,11 +855,13 @@ class ViewCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toUnmodifiable()) + fun build(): ColumnVisibility = + ColumnVisibility(additionalProperties.toUnmodifiable()) } } } @@ -923,12 +869,15 @@ class ViewCreateParams constructor( /** The view definition */ @JsonDeserialize(builder = ViewData.Builder::class) @NoAutoDetect - class ViewData private constructor(private val search: Search?, private val additionalProperties: Map, ) { + class ViewData + private constructor( + private val search: Search?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("search") - fun search(): Search? = search + @JsonProperty("search") fun search(): Search? = search @JsonAnyGetter @ExcludeMissing @@ -937,28 +886,28 @@ class ViewCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewData && - this.search == other.search && - this.additionalProperties == other.additionalProperties + return other is ViewData && + this.search == other.search && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(search, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(search, additionalProperties) + } + return hashCode } - override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewData{search=$search, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -972,10 +921,7 @@ class ViewCreateParams constructor( additionalProperties(viewData.additionalProperties) } - @JsonProperty("search") - fun search(search: Search) = apply { - this.search = search - } + @JsonProperty("search") fun search(search: Search) = apply { this.search = search } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -996,28 +942,24 @@ class ViewCreateParams constructor( @JsonDeserialize(builder = Search.Builder::class) @NoAutoDetect - class Search private constructor( - private val filter: List?, - private val tag: List?, - private val match: List?, - private val sort: List?, - private val additionalProperties: Map, - + class Search + private constructor( + private val filter: List?, + private val tag: List?, + private val match: List?, + private val sort: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("filter") - fun filter(): List? = filter + @JsonProperty("filter") fun filter(): List? = filter - @JsonProperty("tag") - fun tag(): List? = tag + @JsonProperty("tag") fun tag(): List? = tag - @JsonProperty("match") - fun match(): List? = match + @JsonProperty("match") fun match(): List? = match - @JsonProperty("sort") - fun sort(): List? = sort + @JsonProperty("sort") fun sort(): List? = sort @JsonAnyGetter @ExcludeMissing @@ -1026,37 +968,38 @@ class ViewCreateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Search && - this.filter == other.filter && - this.tag == other.tag && - this.match == other.match && - this.sort == other.sort && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Search && + this.filter == other.filter && + this.tag == other.tag && + this.match == other.match && + this.sort == other.sort && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - filter, - tag, - match, - sort, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + filter, + tag, + match, + sort, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" + override fun toString() = + "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1077,24 +1020,14 @@ class ViewCreateParams constructor( } @JsonProperty("filter") - fun filter(filter: List) = apply { - this.filter = filter - } + fun filter(filter: List) = apply { this.filter = filter } - @JsonProperty("tag") - fun tag(tag: List) = apply { - this.tag = tag - } + @JsonProperty("tag") fun tag(tag: List) = apply { this.tag = tag } @JsonProperty("match") - fun match(match: List) = apply { - this.match = match - } + fun match(match: List) = apply { this.match = match } - @JsonProperty("sort") - fun sort(sort: List) = apply { - this.sort = sort - } + @JsonProperty("sort") fun sort(sort: List) = apply { this.sort = sort } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1106,17 +1039,19 @@ class ViewCreateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Search = Search( - filter?.toUnmodifiable(), - tag?.toUnmodifiable(), - match?.toUnmodifiable(), - sort?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Search = + Search( + filter?.toUnmodifiable(), + tag?.toUnmodifiable(), + match?.toUnmodifiable(), + sort?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt index 444bdc7..3eebfbc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt @@ -2,48 +2,30 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ViewDeleteParams constructor( - private val viewId: String, - private val objectId: String, - private val objectType: ObjectType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ViewDeleteParams +constructor( + private val viewId: String, + private val objectId: String, + private val objectType: ObjectType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun viewId(): String = viewId @@ -54,39 +36,40 @@ class ViewDeleteParams constructor( @JvmSynthetic internal fun getBody(): ViewDeleteBody { - return ViewDeleteBody( - objectId, - objectType, - additionalBodyProperties, - ) + return ViewDeleteBody( + objectId, + objectType, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @JsonDeserialize(builder = ViewDeleteBody.Builder::class) @NoAutoDetect - class ViewDeleteBody internal constructor(private val objectId: String?, private val objectType: ObjectType?, private val additionalProperties: Map, ) { + class ViewDeleteBody + internal constructor( + private val objectId: String?, + private val objectType: ObjectType?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(): String? = objectId + @JsonProperty("object_id") fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") fun objectType(): ObjectType? = objectType @JsonAnyGetter @ExcludeMissing @@ -95,33 +78,34 @@ class ViewDeleteParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewDeleteBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewDeleteBody && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - objectId, - objectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + objectId, + objectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -139,15 +123,11 @@ class ViewDeleteParams constructor( /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -163,13 +143,12 @@ class ViewDeleteParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewDeleteBody = ViewDeleteBody( - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewDeleteBody = + ViewDeleteBody( + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + additionalProperties.toUnmodifiable(), + ) } } @@ -180,38 +159,38 @@ class ViewDeleteParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewDeleteParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewDeleteParams && + this.viewId == other.viewId && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + viewId, + objectId, + objectType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -235,19 +214,13 @@ class ViewDeleteParams constructor( } /** View id */ - fun viewId(viewId: String) = apply { - this.viewId = viewId - } + fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -287,9 +260,7 @@ class ViewDeleteParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -300,36 +271,36 @@ class ViewDeleteParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewDeleteParams = ViewDeleteParams( - checkNotNull(viewId) { - "`viewId` is required but was not set" - }, - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewDeleteParams = + ViewDeleteParams( + checkNotNull(viewId) { "`viewId` is required but was not set" }, + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -392,35 +363,37 @@ class ViewDeleteParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 83c385f..4fc74c4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -2,79 +2,77 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.blocking.ViewService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate import java.util.stream.Stream import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.View -import com.braintrustdata.api.services.blocking.ViewService -class ViewListPage private constructor(private val viewsService: ViewService, private val params: ViewListParams, private val response: Response, ) { +class ViewListPage +private constructor( + private val viewsService: ViewService, + private val params: ViewListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewListPage && - this.viewsService == other.viewsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ViewListPage && + this.viewsService == other.viewsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - viewsService, - params, - response, - ) + return Objects.hash( + viewsService, + params, + response, + ) } - override fun toString() = "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = + "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { viewsService.list(it) } + return getNextPageParams().map { viewsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -82,16 +80,21 @@ class ViewListPage private constructor(private val viewsService: ViewService, pr companion object { @JvmStatic - fun of(viewsService: ViewService, params: ViewListParams, response: Response) = ViewListPage( - viewsService, - params, - response, - ) + fun of(viewsService: ViewService, params: ViewListParams, response: Response) = + ViewListPage( + viewsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -106,33 +109,33 @@ class ViewListPage private constructor(private val viewsService: ViewService, pr fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ViewListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -160,22 +163,25 @@ class ViewListPage private constructor(private val viewsService: ViewService, pr } } - class AutoPager constructor(private val firstPage: ViewListPage, ) : Iterable { + class AutoPager + constructor( + private val firstPage: ViewListPage, + ) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { - while (index < page.objects().size) { - yield(page.objects()[index++]) - } - page = page.getNextPage().orElse(null) ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 } } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index 24a2b10..f781d4f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -2,83 +2,80 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.services.async.ViewServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.Spliterator -import java.util.Spliterators -import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.View -import com.braintrustdata.api.services.async.ViewServiceAsync -class ViewListPageAsync private constructor(private val viewsService: ViewServiceAsync, private val params: ViewListParams, private val response: Response, ) { +class ViewListPageAsync +private constructor( + private val viewsService: ViewServiceAsync, + private val params: ViewListParams, + private val response: Response, +) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewListPageAsync && - this.viewsService == other.viewsService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ViewListPageAsync && + this.viewsService == other.viewsService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - viewsService, - params, - response, - ) + return Objects.hash( + viewsService, + params, + response, + ) } - override fun toString() = "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = + "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - viewsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { viewsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,16 +83,21 @@ class ViewListPageAsync private constructor(private val viewsService: ViewServic companion object { @JvmStatic - fun of(viewsService: ViewServiceAsync, params: ViewListParams, response: Response) = ViewListPageAsync( - viewsService, - params, - response, - ) + fun of(viewsService: ViewServiceAsync, params: ViewListParams, response: Response) = + ViewListPageAsync( + viewsService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -110,33 +112,33 @@ class ViewListPageAsync private constructor(private val viewsService: ViewServic fun validate(): Response = apply { if (!validated) { - objects().map { it.validate() } - validated = true + objects().map { it.validate() } + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = "ViewListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -164,31 +166,32 @@ class ViewListPageAsync private constructor(private val viewsService: ViewServic } } - class AutoPager constructor(private val firstPage: ViewListPageAsync, ) { + class AutoPager + constructor( + private val firstPage: ViewListPageAsync, + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (View) -> Boolean, executor: Executor): CompletableFuture = thenComposeAsync({ page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach( + action: (View) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt index c5a05c7..208dce0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt @@ -2,54 +2,41 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize 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 org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ViewListParams constructor( - private val objectId: String, - private val objectType: ObjectType?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val projectName: String?, - private val startingAfter: String?, - private val viewName: String?, - private val viewType: ViewType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ViewListParams +constructor( + private val objectId: String, + private val objectType: ObjectType?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val projectName: String?, + private val startingAfter: String?, + private val viewName: String?, + private val viewType: ViewType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun objectId(): String = objectId @@ -72,40 +59,21 @@ class ViewListParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { - params.put("object_id", listOf(it.toString())) - } - this.objectType.let { - params.put("object_type", listOf(it.toString())) - } - this.endingBefore?.let { - params.put("ending_before", listOf(it.toString())) - } - this.ids?.let { - params.put("ids", listOf(it.toString())) - } - this.limit?.let { - params.put("limit", listOf(it.toString())) - } - this.projectName?.let { - params.put("project_name", listOf(it.toString())) - } - this.startingAfter?.let { - params.put("starting_after", listOf(it.toString())) - } - this.viewName?.let { - params.put("view_name", listOf(it.toString())) - } - this.viewType?.let { - params.put("view_type", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.objectId.let { params.put("object_id", listOf(it.toString())) } + this.objectType.let { params.put("object_type", listOf(it.toString())) } + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.ids?.let { params.put("ids", listOf(it.toString())) } + this.limit?.let { params.put("limit", listOf(it.toString())) } + this.projectName?.let { params.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + this.viewName?.let { params.put("view_name", listOf(it.toString())) } + this.viewType?.let { params.put("view_type", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams @@ -114,50 +82,50 @@ class ViewListParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewListParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.viewName == other.viewName && - this.viewType == other.viewType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewListParams && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.projectName == other.projectName && + this.startingAfter == other.startingAfter && + this.viewName == other.viewName && + this.viewType == other.viewType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - endingBefore, - ids, - limit, - projectName, - startingAfter, - viewName, - viewType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + objectId, + objectType, + endingBefore, + ids, + limit, + projectName, + startingAfter, + viewName, + viewType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, projectName=$projectName, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, projectName=$projectName, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -193,80 +161,58 @@ class ViewListParams constructor( } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids) = apply { - this.ids = ids - } + fun ids(ids: Ids) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(string: String) = apply { - this.ids = Ids.ofString(string) - } + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(strings: List) = apply { - this.ids = Ids.ofStrings(strings) - } + fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { - this.limit = limit - } + fun limit(limit: Long) = apply { this.limit = limit } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { - this.projectName = projectName - } + fun projectName(projectName: String) = apply { this.projectName = projectName } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } /** Name of the view to search for */ - fun viewName(viewName: String) = apply { - this.viewName = viewName - } + fun viewName(viewName: String) = apply { this.viewName = viewName } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType) = apply { this.viewType = viewType } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -306,9 +252,7 @@ class ViewListParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -319,40 +263,42 @@ class ViewListParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewListParams = ViewListParams( - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - endingBefore, - ids, - limit, - projectName, - startingAfter, - viewName, - viewType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewListParams = + ViewListParams( + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + endingBefore, + ids, + limit, + projectName, + startingAfter, + viewName, + viewType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -415,103 +361,109 @@ class ViewListParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun string(): Optional = Optional.ofNullable(string) + fun strings(): Optional> = Optional.ofNullable(strings) fun isString(): Boolean = string != null + fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") + fun asStrings(): List = strings.getOrThrow("strings") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && - this.string == other.string && - this.strings == other.strings + return other is Ids && this.string == other.string && this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } interface Visitor { @@ -521,50 +473,56 @@ class ViewListParams constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } - class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ViewType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && - this.value == other.value + return other is ViewType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -615,29 +573,31 @@ class ViewListParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt index 8239ecb..cc1fd5e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt @@ -2,53 +2,36 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ViewReplaceParams constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: Options?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ViewReplaceParams +constructor( + private val name: String, + private val objectId: String, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: Options?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -69,73 +52,63 @@ class ViewReplaceParams constructor( @JvmSynthetic internal fun getBody(): ViewReplaceBody { - return ViewReplaceBody( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalBodyProperties, - ) + return ViewReplaceBody( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @JsonDeserialize(builder = ViewReplaceBody.Builder::class) @NoAutoDetect - class ViewReplaceBody internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: Options?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalProperties: Map, - + class ViewReplaceBody + internal constructor( + private val name: String?, + private val objectId: String?, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: Options?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the view */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(): String? = objectId + @JsonProperty("object_id") fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") fun objectType(): ObjectType? = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - fun viewType(): ViewType? = viewType + @JsonProperty("view_type") fun viewType(): ViewType? = viewType /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - fun deletedAt(): OffsetDateTime? = deletedAt + @JsonProperty("deleted_at") fun deletedAt(): OffsetDateTime? = deletedAt /** Options for the view in the app */ - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - fun userId(): String? = userId + @JsonProperty("user_id") fun userId(): String? = userId /** The view definition */ - @JsonProperty("view_data") - fun viewData(): ViewData? = viewData + @JsonProperty("view_data") fun viewData(): ViewData? = viewData @JsonAnyGetter @ExcludeMissing @@ -144,45 +117,46 @@ class ViewReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewReplaceBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewReplaceBody && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -211,52 +185,34 @@ class ViewReplaceParams constructor( } /** Name of the view */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** Type of table that the view corresponds to. */ @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") - fun deletedAt(deletedAt: OffsetDateTime) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } /** Options for the view in the app */ @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } /** Identifies the user who created the view */ - @JsonProperty("user_id") - fun userId(userId: String) = apply { - this.userId = userId - } + @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } /** The view definition */ @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { - this.viewData = viewData - } + fun viewData(viewData: ViewData) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -272,21 +228,18 @@ class ViewReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewReplaceBody = ViewReplaceBody( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewReplaceBody = + ViewReplaceBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties.toUnmodifiable(), + ) } } @@ -297,48 +250,48 @@ class ViewReplaceParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewReplaceParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewReplaceParams && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -372,44 +325,28 @@ class ViewReplaceParams constructor( } /** Name of the view */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } /** Options for the view in the app */ - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { - this.userId = userId - } + fun userId(userId: String) = apply { this.userId = userId } /** The view definition */ - fun viewData(viewData: ViewData) = apply { - this.viewData = viewData - } + fun viewData(viewData: ViewData) = apply { this.viewData = viewData } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -449,9 +386,7 @@ class ViewReplaceParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -462,41 +397,41 @@ class ViewReplaceParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewReplaceParams = ViewReplaceParams( - checkNotNull(name) { - "`name` is required but was not set" - }, - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewReplaceParams = + ViewReplaceParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -559,51 +494,55 @@ class ViewReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ViewType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && - this.value == other.value + return other is ViewType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -654,29 +593,31 @@ class ViewReplaceParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -684,12 +625,12 @@ class ViewReplaceParams constructor( /** Options for the view in the app */ @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val columnVisibility: ColumnVisibility?, - private val columnOrder: List?, - private val columnSizing: ColumnSizing?, - private val additionalProperties: Map, - + class Options + private constructor( + private val columnVisibility: ColumnVisibility?, + private val columnOrder: List?, + private val columnSizing: ColumnSizing?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -697,11 +638,9 @@ class ViewReplaceParams constructor( @JsonProperty("columnVisibility") fun columnVisibility(): ColumnVisibility? = columnVisibility - @JsonProperty("columnOrder") - fun columnOrder(): List? = columnOrder + @JsonProperty("columnOrder") fun columnOrder(): List? = columnOrder - @JsonProperty("columnSizing") - fun columnSizing(): ColumnSizing? = columnSizing + @JsonProperty("columnSizing") fun columnSizing(): ColumnSizing? = columnSizing @JsonAnyGetter @ExcludeMissing @@ -710,35 +649,36 @@ class ViewReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.columnVisibility == other.columnVisibility && - this.columnOrder == other.columnOrder && - this.columnSizing == other.columnSizing && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.columnVisibility == other.columnVisibility && + this.columnOrder == other.columnOrder && + this.columnSizing == other.columnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - columnVisibility, - columnOrder, - columnSizing, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + columnVisibility, + columnOrder, + columnSizing, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -762,9 +702,7 @@ class ViewReplaceParams constructor( } @JsonProperty("columnOrder") - fun columnOrder(columnOrder: List) = apply { - this.columnOrder = columnOrder - } + fun columnOrder(columnOrder: List) = apply { this.columnOrder = columnOrder } @JsonProperty("columnSizing") fun columnSizing(columnSizing: ColumnSizing) = apply { @@ -785,17 +723,21 @@ class ViewReplaceParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Options = Options( - columnVisibility, - columnOrder?.toUnmodifiable(), - columnSizing, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + columnVisibility, + columnOrder?.toUnmodifiable(), + columnSizing, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ColumnSizing.Builder::class) @NoAutoDetect - class ColumnSizing private constructor(private val additionalProperties: Map, ) { + class ColumnSizing + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -806,27 +748,26 @@ class ViewReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnSizing && - this.additionalProperties == other.additionalProperties + return other is ColumnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -848,9 +789,10 @@ class ViewReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): ColumnSizing = ColumnSizing(additionalProperties.toUnmodifiable()) } @@ -858,7 +800,10 @@ class ViewReplaceParams constructor( @JsonDeserialize(builder = ColumnVisibility.Builder::class) @NoAutoDetect - class ColumnVisibility private constructor(private val additionalProperties: Map, ) { + class ColumnVisibility + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -869,27 +814,26 @@ class ViewReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnVisibility && - this.additionalProperties == other.additionalProperties + return other is ColumnVisibility && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -911,11 +855,13 @@ class ViewReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toUnmodifiable()) + fun build(): ColumnVisibility = + ColumnVisibility(additionalProperties.toUnmodifiable()) } } } @@ -923,12 +869,15 @@ class ViewReplaceParams constructor( /** The view definition */ @JsonDeserialize(builder = ViewData.Builder::class) @NoAutoDetect - class ViewData private constructor(private val search: Search?, private val additionalProperties: Map, ) { + class ViewData + private constructor( + private val search: Search?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("search") - fun search(): Search? = search + @JsonProperty("search") fun search(): Search? = search @JsonAnyGetter @ExcludeMissing @@ -937,28 +886,28 @@ class ViewReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewData && - this.search == other.search && - this.additionalProperties == other.additionalProperties + return other is ViewData && + this.search == other.search && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(search, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(search, additionalProperties) + } + return hashCode } - override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewData{search=$search, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -972,10 +921,7 @@ class ViewReplaceParams constructor( additionalProperties(viewData.additionalProperties) } - @JsonProperty("search") - fun search(search: Search) = apply { - this.search = search - } + @JsonProperty("search") fun search(search: Search) = apply { this.search = search } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -996,28 +942,24 @@ class ViewReplaceParams constructor( @JsonDeserialize(builder = Search.Builder::class) @NoAutoDetect - class Search private constructor( - private val filter: List?, - private val tag: List?, - private val match: List?, - private val sort: List?, - private val additionalProperties: Map, - + class Search + private constructor( + private val filter: List?, + private val tag: List?, + private val match: List?, + private val sort: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("filter") - fun filter(): List? = filter + @JsonProperty("filter") fun filter(): List? = filter - @JsonProperty("tag") - fun tag(): List? = tag + @JsonProperty("tag") fun tag(): List? = tag - @JsonProperty("match") - fun match(): List? = match + @JsonProperty("match") fun match(): List? = match - @JsonProperty("sort") - fun sort(): List? = sort + @JsonProperty("sort") fun sort(): List? = sort @JsonAnyGetter @ExcludeMissing @@ -1026,37 +968,38 @@ class ViewReplaceParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Search && - this.filter == other.filter && - this.tag == other.tag && - this.match == other.match && - this.sort == other.sort && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Search && + this.filter == other.filter && + this.tag == other.tag && + this.match == other.match && + this.sort == other.sort && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - filter, - tag, - match, - sort, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + filter, + tag, + match, + sort, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" + override fun toString() = + "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -1077,24 +1020,14 @@ class ViewReplaceParams constructor( } @JsonProperty("filter") - fun filter(filter: List) = apply { - this.filter = filter - } + fun filter(filter: List) = apply { this.filter = filter } - @JsonProperty("tag") - fun tag(tag: List) = apply { - this.tag = tag - } + @JsonProperty("tag") fun tag(tag: List) = apply { this.tag = tag } @JsonProperty("match") - fun match(match: List) = apply { - this.match = match - } + fun match(match: List) = apply { this.match = match } - @JsonProperty("sort") - fun sort(sort: List) = apply { - this.sort = sort - } + @JsonProperty("sort") fun sort(sort: List) = apply { this.sort = sort } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1106,17 +1039,19 @@ class ViewReplaceParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Search = Search( - filter?.toUnmodifiable(), - tag?.toUnmodifiable(), - match?.toUnmodifiable(), - sort?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Search = + Search( + filter?.toUnmodifiable(), + tag?.toUnmodifiable(), + match?.toUnmodifiable(), + sort?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt index 8ef9328..698e35c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt @@ -2,48 +2,25 @@ package com.braintrustdata.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.Enum import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Objects +import java.util.Optional -class ViewRetrieveParams constructor( - private val viewId: String, - private val objectId: String, - private val objectType: ObjectType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, - +class ViewRetrieveParams +constructor( + private val viewId: String, + private val objectId: String, + private val objectType: ObjectType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun viewId(): String = viewId @@ -54,25 +31,20 @@ class ViewRetrieveParams constructor( @JvmSynthetic internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { - params.put("object_id", listOf(it.toString())) - } - this.objectType.let { - params.put("object_type", listOf(it.toString())) - } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.objectId.let { params.put("object_id", listOf(it.toString())) } + this.objectType.let { params.put("object_type", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -82,38 +54,38 @@ class ViewRetrieveParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewRetrieveParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewRetrieveParams && + this.viewId == other.viewId && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + viewId, + objectId, + objectType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -137,19 +109,13 @@ class ViewRetrieveParams constructor( } /** View id */ - fun viewId(viewId: String) = apply { - this.viewId = viewId - } + fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -189,9 +155,7 @@ class ViewRetrieveParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -202,36 +166,36 @@ class ViewRetrieveParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ViewRetrieveParams = ViewRetrieveParams( - checkNotNull(viewId) { - "`viewId` is required but was not set" - }, - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ViewRetrieveParams = + ViewRetrieveParams( + checkNotNull(viewId) { "`viewId` is required but was not set" }, + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -294,35 +258,37 @@ class ViewRetrieveParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt index 58bf62a..01027a9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt @@ -2,53 +2,35 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.apache.hc.core5.http.ContentType -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional -import java.util.UUID -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* - -class ViewUpdateParams constructor( - private val viewId: String, - private val objectId: String, - private val objectType: ObjectType?, - private val name: String?, - private val options: Options?, - private val userId: String?, - private val viewData: ViewData?, - private val viewType: ViewType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ViewUpdateParams +constructor( + private val viewId: String, + private val objectId: String, + private val objectType: ObjectType?, + private val name: String?, + private val options: Options?, + private val userId: String?, + private val viewData: ViewData?, + private val viewType: ViewType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, ) { fun viewId(): String = viewId @@ -69,74 +51,65 @@ class ViewUpdateParams constructor( @JvmSynthetic internal fun getBody(): ViewUpdateBody { - return ViewUpdateBody( - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalBodyProperties, - ) + return ViewUpdateBody( + objectId, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalBodyProperties, + ) } - @JvmSynthetic - internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic - internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @JsonDeserialize(builder = ViewUpdateBody.Builder::class) @NoAutoDetect - class ViewUpdateBody internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val name: String?, - private val options: Options?, - private val userId: String?, - private val viewData: ViewData?, - private val viewType: ViewType?, - private val additionalProperties: Map, - + class ViewUpdateBody + internal constructor( + private val objectId: String?, + private val objectType: ObjectType?, + private val name: String?, + private val options: Options?, + private val userId: String?, + private val viewData: ViewData?, + private val viewType: ViewType?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(): String? = objectId + @JsonProperty("object_id") fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") fun objectType(): ObjectType? = objectType /** Name of the view */ - @JsonProperty("name") - fun name(): String? = name + @JsonProperty("name") fun name(): String? = name /** Options for the view in the app */ - @JsonProperty("options") - fun options(): Options? = options + @JsonProperty("options") fun options(): Options? = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - fun userId(): String? = userId + @JsonProperty("user_id") fun userId(): String? = userId /** The view definition */ - @JsonProperty("view_data") - fun viewData(): ViewData? = viewData + @JsonProperty("view_data") fun viewData(): ViewData? = viewData /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - fun viewType(): ViewType? = viewType + @JsonProperty("view_type") fun viewType(): ViewType? = viewType @JsonAnyGetter @ExcludeMissing @@ -145,43 +118,44 @@ class ViewUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewUpdateBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.name == other.name && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.viewType == other.viewType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewUpdateBody && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.name == other.name && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.viewType == other.viewType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + objectId, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -209,45 +183,29 @@ class ViewUpdateParams constructor( /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** Name of the view */ - @JsonProperty("name") - fun name(name: String) = apply { - this.name = name - } + @JsonProperty("name") fun name(name: String) = apply { this.name = name } /** Options for the view in the app */ @JsonProperty("options") - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } /** Identifies the user who created the view */ - @JsonProperty("user_id") - fun userId(userId: String) = apply { - this.userId = userId - } + @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } /** The view definition */ @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { - this.viewData = viewData - } + fun viewData(viewData: ViewData) = apply { this.viewData = viewData } /** Type of table that the view corresponds to. */ @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType) = apply { this.viewType = viewType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -263,18 +221,17 @@ class ViewUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewUpdateBody = ViewUpdateBody( - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewUpdateBody = + ViewUpdateBody( + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalProperties.toUnmodifiable(), + ) } } @@ -285,48 +242,48 @@ class ViewUpdateParams constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewUpdateParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.name == other.name && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.viewType == other.viewType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewUpdateParams && + this.viewId == other.viewId && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.name == other.name && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.viewType == other.viewType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + viewId, + objectId, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } @NoAutoDetect @@ -360,44 +317,28 @@ class ViewUpdateParams constructor( } /** View id */ - fun viewId(viewId: String) = apply { - this.viewId = viewId - } + fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { - this.objectId = objectId - } + fun objectId(objectId: String) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { - this.objectType = objectType - } + fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } /** Name of the view */ - fun name(name: String) = apply { - this.name = name - } + fun name(name: String) = apply { this.name = name } /** Options for the view in the app */ - fun options(options: Options) = apply { - this.options = options - } + fun options(options: Options) = apply { this.options = options } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { - this.userId = userId - } + fun userId(userId: String) = apply { this.userId = userId } /** The view definition */ - fun viewData(viewData: ViewData) = apply { - this.viewData = viewData - } + fun viewData(viewData: ViewData) = apply { this.viewData = viewData } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType) = apply { this.viewType = viewType } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -437,9 +378,7 @@ class ViewUpdateParams constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { - this.additionalHeaders.put(name, mutableListOf()) - } + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -450,41 +389,41 @@ class ViewUpdateParams constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewUpdateParams = ViewUpdateParams( - checkNotNull(viewId) { - "`viewId` is required but was not set" - }, - checkNotNull(objectId) { - "`objectId` is required but was not set" - }, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewUpdateParams = + ViewUpdateParams( + checkNotNull(viewId) { "`viewId` is required but was not set" }, + checkNotNull(objectId) { "`objectId` is required but was not set" }, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && - this.value == other.value + return other is ObjectType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -547,35 +486,37 @@ class ViewUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = + when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -583,12 +524,12 @@ class ViewUpdateParams constructor( /** Options for the view in the app */ @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options private constructor( - private val columnVisibility: ColumnVisibility?, - private val columnOrder: List?, - private val columnSizing: ColumnSizing?, - private val additionalProperties: Map, - + class Options + private constructor( + private val columnVisibility: ColumnVisibility?, + private val columnOrder: List?, + private val columnSizing: ColumnSizing?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -596,11 +537,9 @@ class ViewUpdateParams constructor( @JsonProperty("columnVisibility") fun columnVisibility(): ColumnVisibility? = columnVisibility - @JsonProperty("columnOrder") - fun columnOrder(): List? = columnOrder + @JsonProperty("columnOrder") fun columnOrder(): List? = columnOrder - @JsonProperty("columnSizing") - fun columnSizing(): ColumnSizing? = columnSizing + @JsonProperty("columnSizing") fun columnSizing(): ColumnSizing? = columnSizing @JsonAnyGetter @ExcludeMissing @@ -609,35 +548,36 @@ class ViewUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.columnVisibility == other.columnVisibility && - this.columnOrder == other.columnOrder && - this.columnSizing == other.columnSizing && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.columnVisibility == other.columnVisibility && + this.columnOrder == other.columnOrder && + this.columnSizing == other.columnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - columnVisibility, - columnOrder, - columnSizing, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + columnVisibility, + columnOrder, + columnSizing, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" + override fun toString() = + "Options{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -661,9 +601,7 @@ class ViewUpdateParams constructor( } @JsonProperty("columnOrder") - fun columnOrder(columnOrder: List) = apply { - this.columnOrder = columnOrder - } + fun columnOrder(columnOrder: List) = apply { this.columnOrder = columnOrder } @JsonProperty("columnSizing") fun columnSizing(columnSizing: ColumnSizing) = apply { @@ -684,17 +622,21 @@ class ViewUpdateParams constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Options = Options( - columnVisibility, - columnOrder?.toUnmodifiable(), - columnSizing, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = + Options( + columnVisibility, + columnOrder?.toUnmodifiable(), + columnSizing, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ColumnSizing.Builder::class) @NoAutoDetect - class ColumnSizing private constructor(private val additionalProperties: Map, ) { + class ColumnSizing + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -705,27 +647,26 @@ class ViewUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnSizing && - this.additionalProperties == other.additionalProperties + return other is ColumnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -747,9 +688,10 @@ class ViewUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): ColumnSizing = ColumnSizing(additionalProperties.toUnmodifiable()) } @@ -757,7 +699,10 @@ class ViewUpdateParams constructor( @JsonDeserialize(builder = ColumnVisibility.Builder::class) @NoAutoDetect - class ColumnVisibility private constructor(private val additionalProperties: Map, ) { + class ColumnVisibility + private constructor( + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -768,27 +713,26 @@ class ViewUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnVisibility && - this.additionalProperties == other.additionalProperties + return other is ColumnVisibility && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -810,11 +754,13 @@ class ViewUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toUnmodifiable()) + fun build(): ColumnVisibility = + ColumnVisibility(additionalProperties.toUnmodifiable()) } } } @@ -822,12 +768,15 @@ class ViewUpdateParams constructor( /** The view definition */ @JsonDeserialize(builder = ViewData.Builder::class) @NoAutoDetect - class ViewData private constructor(private val search: Search?, private val additionalProperties: Map, ) { + class ViewData + private constructor( + private val search: Search?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("search") - fun search(): Search? = search + @JsonProperty("search") fun search(): Search? = search @JsonAnyGetter @ExcludeMissing @@ -836,28 +785,28 @@ class ViewUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewData && - this.search == other.search && - this.additionalProperties == other.additionalProperties + return other is ViewData && + this.search == other.search && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(search, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(search, additionalProperties) + } + return hashCode } - override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewData{search=$search, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -871,10 +820,7 @@ class ViewUpdateParams constructor( additionalProperties(viewData.additionalProperties) } - @JsonProperty("search") - fun search(search: Search) = apply { - this.search = search - } + @JsonProperty("search") fun search(search: Search) = apply { this.search = search } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -895,28 +841,24 @@ class ViewUpdateParams constructor( @JsonDeserialize(builder = Search.Builder::class) @NoAutoDetect - class Search private constructor( - private val filter: List?, - private val tag: List?, - private val match: List?, - private val sort: List?, - private val additionalProperties: Map, - + class Search + private constructor( + private val filter: List?, + private val tag: List?, + private val match: List?, + private val sort: List?, + private val additionalProperties: Map, ) { private var hashCode: Int = 0 - @JsonProperty("filter") - fun filter(): List? = filter + @JsonProperty("filter") fun filter(): List? = filter - @JsonProperty("tag") - fun tag(): List? = tag + @JsonProperty("tag") fun tag(): List? = tag - @JsonProperty("match") - fun match(): List? = match + @JsonProperty("match") fun match(): List? = match - @JsonProperty("sort") - fun sort(): List? = sort + @JsonProperty("sort") fun sort(): List? = sort @JsonAnyGetter @ExcludeMissing @@ -925,37 +867,38 @@ class ViewUpdateParams constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Search && - this.filter == other.filter && - this.tag == other.tag && - this.match == other.match && - this.sort == other.sort && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Search && + this.filter == other.filter && + this.tag == other.tag && + this.match == other.match && + this.sort == other.sort && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash( - filter, - tag, - match, - sort, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = + Objects.hash( + filter, + tag, + match, + sort, + additionalProperties, + ) + } + return hashCode } - override fun toString() = "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" + override fun toString() = + "Search{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" companion object { - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -976,24 +919,14 @@ class ViewUpdateParams constructor( } @JsonProperty("filter") - fun filter(filter: List) = apply { - this.filter = filter - } + fun filter(filter: List) = apply { this.filter = filter } - @JsonProperty("tag") - fun tag(tag: List) = apply { - this.tag = tag - } + @JsonProperty("tag") fun tag(tag: List) = apply { this.tag = tag } @JsonProperty("match") - fun match(match: List) = apply { - this.match = match - } + fun match(match: List) = apply { this.match = match } - @JsonProperty("sort") - fun sort(sort: List) = apply { - this.sort = sort - } + @JsonProperty("sort") fun sort(sort: List) = apply { this.sort = sort } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1005,33 +938,37 @@ class ViewUpdateParams constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Search = Search( - filter?.toUnmodifiable(), - tag?.toUnmodifiable(), - match?.toUnmodifiable(), - sort?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Search = + Search( + filter?.toUnmodifiable(), + tag?.toUnmodifiable(), + match?.toUnmodifiable(), + sort?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } } - class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { + class ViewType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && - this.value == other.value + return other is ViewType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -1082,29 +1019,31 @@ class ViewUpdateParams constructor( _UNKNOWN, } - fun value(): Value = when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = + when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = + when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt index a651b21..253bc27 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt @@ -2,37 +2,34 @@ package com.braintrustdata.api.services -import java.io.InputStream -import java.io.OutputStream -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.braintrustdata.api.core.http.BinaryResponseContent import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.errors.BadRequestException import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.errors.BraintrustException -import com.braintrustdata.api.errors.BraintrustServiceException import com.braintrustdata.api.errors.InternalServerException -import com.braintrustdata.api.errors.BadRequestException import com.braintrustdata.api.errors.NotFoundException import com.braintrustdata.api.errors.PermissionDeniedException import com.braintrustdata.api.errors.RateLimitException import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.io.InputStream +import java.io.OutputStream +import java.util.Optional -@JvmSynthetic -internal fun emptyHandler(): Handler = EmptyHandler +@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandler private object EmptyHandler : Handler { override fun handle(response: HttpResponse): Void? = null } -@JvmSynthetic -internal fun stringHandler(): Handler = StringHandler +@JvmSynthetic internal fun stringHandler(): Handler = StringHandler -@JvmSynthetic -internal fun binaryHandler(): Handler = BinaryHandler +@JvmSynthetic internal fun binaryHandler(): Handler = BinaryHandler private object StringHandler : Handler { override fun handle(response: HttpResponse): String { @@ -42,7 +39,18 @@ private object StringHandler : Handler { private object BinaryHandler : Handler { override fun handle(response: HttpResponse): BinaryResponseContent { - return BinaryResponseContentImpl(response); + return object : BinaryResponseContent { + override fun contentType(): Optional = + Optional.ofNullable(response.headers().get("Content-Type").firstOrNull()) + + override fun body(): InputStream = response.body() + + override fun close() = response.close() + + override fun writeTo(outputStream: OutputStream) { + response.body().copyTo(outputStream) + } + } } } @@ -81,10 +89,19 @@ internal fun Handler.withErrorHandler(errorHandler: Handler return this@withErrorHandler.handle(response) 400 -> throw BadRequestException(response.headers(), errorHandler.handle(response)) - 401 -> throw UnauthorizedException(response.headers(), errorHandler.handle(response)) - 403 -> throw PermissionDeniedException(response.headers(), errorHandler.handle(response)) + 401 -> + throw UnauthorizedException(response.headers(), errorHandler.handle(response)) + 403 -> + throw PermissionDeniedException( + response.headers(), + errorHandler.handle(response) + ) 404 -> throw NotFoundException(response.headers(), errorHandler.handle(response)) - 422 -> throw UnprocessableEntityException(response.headers(), errorHandler.handle(response)) + 422 -> + throw UnprocessableEntityException( + response.headers(), + errorHandler.handle(response) + ) 429 -> throw RateLimitException(response.headers(), errorHandler.handle(response)) in 500..599 -> throw InternalServerException( @@ -102,25 +119,3 @@ internal fun Handler.withErrorHandler(errorHandler: Handler json( @@ -50,7 +50,10 @@ internal inline fun json( } @JvmSynthetic -internal fun multipartFormData(jsonMapper: JsonMapper, parts: Array?>): HttpRequestBody { +internal fun multipartFormData( + jsonMapper: JsonMapper, + parts: Array?> +): HttpRequestBody { val builder = MultipartEntityBuilder.create() parts.forEach { part -> if (part?.value != null) { @@ -62,16 +65,30 @@ internal fun multipartFormData(jsonMapper: JsonMapper, parts: Array builder.addTextBody (part.name, if (part.value) "true" else "false", part.contentType) + is Boolean -> + builder.addTextBody( + part.name, + if (part.value) "true" else "false", + part.contentType + ) is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) + is ByteArray -> + builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) is String -> builder.addTextBody(part.name, part.value, part.contentType) is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> throw IllegalArgumentException("Unsupported content type: ${part.value::class.java.simpleName}") + else -> + throw IllegalArgumentException( + "Unsupported content type: ${part.value::class.java.simpleName}" + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 82e9fea..4442600 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -4,67 +4,48 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface AclServiceAsync { /** - * Create a new acl. If there is an existing acl with the same contents as the one - * specified in the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one specified in + * the request, will return the existing acl unmodified */ @JvmOverloads - fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: AclCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get an acl object by its id */ @JvmOverloads - fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ @JvmOverloads - fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete an acl object by its id */ @JvmOverloads - fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 481dd2a..00533e0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -2,170 +2,154 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class AclServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : AclServiceAsync { +class AclServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : AclServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new acl. If there is an existing acl with the same contents as the one - * specified in the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one specified in + * the request, will return the existing acl unmodified */ - override fun create(params: AclCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: AclCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get an acl object by its id */ - override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ - override fun list(params: AclListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - AclListPageAsync.of(this, params, it) - } - } + override fun list( + params: AclListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { AclListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete an acl object by its id */ - override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index 0c1117c..ba78510 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyCreateResponse @@ -27,45 +12,41 @@ import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface ApiKeyServiceAsync { /** - * Create a new api_key. It is possible to have multiple API keys with the same - * name. There is no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same name. There is + * no de-duplication */ @JvmOverloads - fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get an api_key object by its id */ @JvmOverloads - fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ @JvmOverloads - fun list(params: ApiKeyListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete an api_key object by its id */ @JvmOverloads - fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index e421b49..ce4661f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyCreateResponse @@ -25,148 +15,142 @@ import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class ApiKeyServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ApiKeyServiceAsync { +class ApiKeyServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ApiKeyServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new api_key. It is possible to have multiple API keys with the same - * name. There is no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same name. There is + * no de-duplication */ - override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get an api_key object by its id */ - override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ - override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ApiKeyListPageAsync.of(this, params, it) - } - } + override fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ApiKeyListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete an api_key object by its id */ - override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index 8f51ec5..eeaf345 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -36,80 +21,93 @@ import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface DatasetServiceAsync { /** - * Create a new dataset. If there is an existing dataset in the project with the - * same name as the one specified in the request, will return the existing dataset - * unmodified + * Create a new dataset. If there is an existing dataset in the project with the same name as + * the one specified in the request, will return the existing dataset unmodified */ @JvmOverloads - fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a dataset object by its id */ @JvmOverloads - fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a dataset object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ @JvmOverloads - fun list(params: DatasetListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: DatasetListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a dataset object by its id */ @JvmOverloads - fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Log feedback for a set of dataset events */ @JvmOverloads - fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but - * with the parameters in the URL query rather than in the request body + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ @JvmOverloads - fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but - * with the parameters in the request body rather than in the URL query + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ @JvmOverloads - fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Insert a set of events into the dataset */ @JvmOverloads - fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Summarize dataset */ @JvmOverloads - fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index e0395b4..f46fe0d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -34,320 +24,326 @@ import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class DatasetServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : DatasetServiceAsync { +class DatasetServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : DatasetServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new dataset. If there is an existing dataset in the project with the - * same name as the one specified in the request, will return the existing dataset - * unmodified + * Create a new dataset. If there is an existing dataset in the project with the same name as + * the one specified in the request, will return the existing dataset unmodified */ - override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a dataset object by its id */ - override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a dataset object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ - override fun list(params: DatasetListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - DatasetListPageAsync.of(this, params, it) - } - } + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { DatasetListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a dataset object by its id */ - override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) + private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Log feedback for a set of dataset events */ - override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - feedbackHandler.handle(it) - } - } + override fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response.use { feedbackHandler.handle(it) } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but - * with the parameters in the URL query rather than in the request body + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ - override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { fetchHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but - * with the parameters in the request body rather than in the URL query + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ - override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { fetchPostHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the dataset */ - override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { insertHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize dataset */ - override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - summarizeHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { summarizeHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index 940f29c..0fdcd09 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -36,80 +21,93 @@ import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface ExperimentServiceAsync { /** - * Create a new experiment. If there is an existing experiment in the project with - * the same name as the one specified in the request, will return the existing - * experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with the same name + * as the one specified in the request, will return the existing experiment unmodified */ @JvmOverloads - fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get an experiment object by its id */ @JvmOverloads - fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update an experiment object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ @JvmOverloads - fun list(params: ExperimentListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ExperimentListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete an experiment object by its id */ @JvmOverloads - fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Log feedback for a set of experiment events */ @JvmOverloads - fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, - * but with the parameters in the URL query rather than in the request body + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ @JvmOverloads - fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ @JvmOverloads - fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Insert a set of events into the experiment */ @JvmOverloads - fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Summarize experiment */ @JvmOverloads - fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index f76396a..851da98 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -34,320 +24,328 @@ import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class ExperimentServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ExperimentServiceAsync { +class ExperimentServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ExperimentServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new experiment. If there is an existing experiment in the project with - * the same name as the one specified in the request, will return the existing - * experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with the same name + * as the one specified in the request, will return the existing experiment unmodified */ - override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get an experiment object by its id */ - override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update an experiment object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ - override fun list(params: ExperimentListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ExperimentListPageAsync.of(this, params, it) - } - } + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ExperimentListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete an experiment object by its id */ - override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) + private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Log feedback for a set of experiment events */ - override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - feedbackHandler.handle(it) - } - } + override fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response.use { feedbackHandler.handle(it) } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, - * but with the parameters in the URL query rather than in the request body + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ - override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { fetchHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ - override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { fetchPostHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ - override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { insertHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize experiment */ - override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - summarizeHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { summarizeHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index f839310..01d96cd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -4,91 +4,72 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams -import com.braintrustdata.api.models.FunctionFeedbackParams import com.braintrustdata.api.models.FunctionListPageAsync import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface FunctionServiceAsync { /** - * Create a new function. If there is an existing function in the project with the - * same slug as the one specified in the request, will return the existing function - * unmodified + * Create a new function. If there is an existing function in the project with the same slug as + * the one specified in the request, will return the existing function unmodified */ @JvmOverloads - fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a function object by its id */ @JvmOverloads - fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a function object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ @JvmOverloads - fun list(params: FunctionListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: FunctionListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a function object by its id */ @JvmOverloads - fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - - /** Log feedback for a set of function events */ - @JvmOverloads - fun feedback(params: FunctionFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Create or replace function. If there is an existing function in the project with - * the same slug as the one specified in the request, will replace the existing - * function with the provided fields + * Create or replace function. If there is an existing function in the project with the same + * slug as the one specified in the request, will replace the existing function with the + * provided fields */ @JvmOverloads - fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 45a2df3..2104610 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -2,261 +2,224 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams -import com.braintrustdata.api.models.FunctionFeedbackParams import com.braintrustdata.api.models.FunctionListPageAsync import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class FunctionServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : FunctionServiceAsync { +class FunctionServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : FunctionServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new function. If there is an existing function in the project with the - * same slug as the one specified in the request, will return the existing function - * unmodified + * Create a new function. If there is an existing function in the project with the same slug as + * the one specified in the request, will return the existing function unmodified */ - override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a function object by its id */ - override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a function object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ - override fun list(params: FunctionListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - FunctionListPageAsync.of(this, params, it) - } - } + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { FunctionListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a function object by its id */ - override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) - - /** Log feedback for a set of function events */ - override fun feedback(params: FunctionFeedbackParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - feedbackHandler.handle(it) - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace function. If there is an existing function in the project with - * the same slug as the one specified in the request, will replace the existing - * function with the provided fields + * Create or replace function. If there is an existing function in the project with the same + * slug as the one specified in the request, will replace the existing function with the + * provided fields */ - override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index a2f4659..62c6f17 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -28,61 +13,62 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface GroupServiceAsync { /** - * Create a new group. If there is an existing group with the same name as the one - * specified in the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one specified in + * the request, will return the existing group unmodified */ @JvmOverloads - fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a group object by its id */ @JvmOverloads - fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a group object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ @JvmOverloads - fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ @JvmOverloads - fun list(params: GroupListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: GroupListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a group object by its id */ @JvmOverloads - fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Create or replace group. If there is an existing group with the same name as the - * one specified in the request, will replace the existing group with the provided - * fields + * Create or replace group. If there is an existing group with the same name as the one + * specified in the request, will replace the existing group with the provided fields */ @JvmOverloads - fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index 13b3f5a..aebfd0a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -26,212 +16,209 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class GroupServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : GroupServiceAsync { +class GroupServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : GroupServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new group. If there is an existing group with the same name as the one - * specified in the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one specified in + * the request, will return the existing group unmodified */ - override fun create(params: GroupCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a group object by its id */ - override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a group object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ - override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ - override fun list(params: GroupListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - GroupListPageAsync.of(this, params, it) - } - } + override fun list( + params: GroupListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { GroupListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a group object by its id */ - override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace group. If there is an existing group with the same name as the - * one specified in the request, will replace the existing group with the provided - * fields + * Create or replace group. If there is an existing group with the same name as the one + * specified in the request, will replace the existing group with the provided fields */ - override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index 14b488e..0f99790 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -4,68 +4,52 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPageAsync import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.services.async.organizations.MemberServiceAsync +import java.util.concurrent.CompletableFuture interface OrganizationServiceAsync { + fun members(): MemberServiceAsync + /** Get a organization object by its id */ @JvmOverloads - fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a organization object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ @JvmOverloads - fun list(params: OrganizationListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: OrganizationListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a organization object by its id */ @JvmOverloads - fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 23616d5..b6bb0c0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -2,171 +2,161 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPageAsync import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.async.organizations.MemberServiceAsync +import com.braintrustdata.api.services.async.organizations.MemberServiceAsyncImpl import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class OrganizationServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : OrganizationServiceAsync { +class OrganizationServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : OrganizationServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } + + override fun members(): MemberServiceAsync = members + private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a organization object by its id */ - override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a organization object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ - override fun list(params: OrganizationListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - OrganizationListPageAsync.of(this, params, it) - } - } + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { OrganizationListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a organization object by its id */ - override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index c7eb867..a5c58d3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -28,62 +13,64 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface ProjectScoreServiceAsync { /** - * Create a new project_score. If there is an existing project_score in the project - * with the same name as the one specified in the request, will return the existing - * project_score unmodified + * Create a new project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will return the existing project_score + * unmodified */ @JvmOverloads - fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a project_score object by its id */ @JvmOverloads - fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a project_score object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ @JvmOverloads - fun list(params: ProjectScoreListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a project_score object by its id */ @JvmOverloads - fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Create or replace project_score. If there is an existing project_score in the - * project with the same name as the one specified in the request, will replace the - * existing project_score with the provided fields + * Create or replace project_score. If there is an existing project_score in the project with + * the same name as the one specified in the request, will replace the existing project_score + * with the provided fields */ @JvmOverloads - fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index 0f6356f..8953beb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -26,213 +16,211 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class ProjectScoreServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ProjectScoreServiceAsync { +class ProjectScoreServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectScoreServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new project_score. If there is an existing project_score in the project - * with the same name as the one specified in the request, will return the existing - * project_score unmodified + * Create a new project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will return the existing project_score + * unmodified */ - override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project_score object by its id */ - override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a project_score object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ - override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ProjectScoreListPageAsync.of(this, params, it) - } - } + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ProjectScoreListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project_score object by its id */ - override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace project_score. If there is an existing project_score in the - * project with the same name as the one specified in the request, will replace the - * existing project_score with the provided fields + * Create or replace project_score. If there is an existing project_score in the project with + * the same name as the one specified in the request, will replace the existing project_score + * with the provided fields */ - override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index 3de9fce..a9b81dd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -27,57 +12,55 @@ import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler import com.braintrustdata.api.services.async.projects.LogServiceAsync -import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl +import java.util.concurrent.CompletableFuture interface ProjectServiceAsync { fun logs(): LogServiceAsync /** - * Create a new project. If there is an existing project with the same name as the - * one specified in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the one specified + * in the request, will return the existing project unmodified */ @JvmOverloads - fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a project object by its id */ @JvmOverloads - fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a project object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ @JvmOverloads - fun list(params: ProjectListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ProjectListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a project object by its id */ @JvmOverloads - fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index da3b70e..02e1fd7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -25,27 +15,18 @@ import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.async.projects.LogServiceAsync +import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -import com.braintrustdata.api.services.async.projects.LogServiceAsync -import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl +import java.util.concurrent.CompletableFuture -class ProjectServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ProjectServiceAsync { +class ProjectServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -54,157 +35,162 @@ class ProjectServiceAsyncImpl constructor(private val clientOptions: ClientOptio override fun logs(): LogServiceAsync = logs private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new project. If there is an existing project with the same name as the - * one specified in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the one specified + * in the request, will return the existing project unmodified */ - override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project object by its id */ - override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a project object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ - override fun list(params: ProjectListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ProjectListPageAsync.of(this, params, it) - } - } + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ProjectListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project object by its id */ - override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index acef761..7c06cd9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -28,62 +13,63 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface ProjectTagServiceAsync { /** - * Create a new project_tag. If there is an existing project_tag in the project - * with the same name as the one specified in the request, will return the existing - * project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will return the existing project_tag unmodified */ @JvmOverloads - fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a project_tag object by its id */ @JvmOverloads - fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a project_tag object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ @JvmOverloads - fun list(params: ProjectTagListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a project_tag object by its id */ @JvmOverloads - fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Create or replace project_tag. If there is an existing project_tag in the - * project with the same name as the one specified in the request, will replace the - * existing project_tag with the provided fields + * Create or replace project_tag. If there is an existing project_tag in the project with the + * same name as the one specified in the request, will replace the existing project_tag with the + * provided fields */ @JvmOverloads - fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index f9d91e8..66372de 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -26,213 +16,210 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class ProjectTagServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ProjectTagServiceAsync { +class ProjectTagServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectTagServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new project_tag. If there is an existing project_tag in the project - * with the same name as the one specified in the request, will return the existing - * project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will return the existing project_tag unmodified */ - override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project_tag object by its id */ - override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a project_tag object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ - override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ProjectTagListPageAsync.of(this, params, it) - } - } + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ProjectTagListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project_tag object by its id */ - override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace project_tag. If there is an existing project_tag in the - * project with the same name as the one specified in the request, will replace the - * existing project_tag with the provided fields + * Create or replace project_tag. If there is an existing project_tag in the project with the + * same name as the one specified in the request, will replace the existing project_tag with the + * provided fields */ - override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index 8cc07ba..2d44475 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -4,91 +4,71 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptFeedbackParams import com.braintrustdata.api.models.PromptListPageAsync import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface PromptServiceAsync { /** - * Create a new prompt. If there is an existing prompt in the project with the same - * slug as the one specified in the request, will return the existing prompt - * unmodified + * Create a new prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will return the existing prompt unmodified */ @JvmOverloads - fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a prompt object by its id */ @JvmOverloads - fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a prompt object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ @JvmOverloads - fun list(params: PromptListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: PromptListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a prompt object by its id */ @JvmOverloads - fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - - /** Log feedback for a set of prompt events */ - @JvmOverloads - fun feedback(params: PromptFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Create or replace prompt. If there is an existing prompt in the project with the - * same slug as the one specified in the request, will replace the existing prompt - * with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the same slug as + * the one specified in the request, will replace the existing prompt with the provided fields */ @JvmOverloads - fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 608b1ef..f892b1f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -2,261 +2,223 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptFeedbackParams import com.braintrustdata.api.models.PromptListPageAsync import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class PromptServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : PromptServiceAsync { +class PromptServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : PromptServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new prompt. If there is an existing prompt in the project with the same - * slug as the one specified in the request, will return the existing prompt - * unmodified + * Create a new prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will return the existing prompt unmodified */ - override fun create(params: PromptCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: PromptCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a prompt object by its id */ - override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a prompt object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ - override fun list(params: PromptListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - PromptListPageAsync.of(this, params, it) - } - } + override fun list( + params: PromptListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { PromptListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a prompt object by its id */ - override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) - - /** Log feedback for a set of prompt events */ - override fun feedback(params: PromptFeedbackParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - feedbackHandler.handle(it) - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace prompt. If there is an existing prompt in the project with the - * same slug as the one specified in the request, will replace the existing prompt - * with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the same slug as + * the one specified in the request, will replace the existing prompt with the provided fields */ - override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index acc2a67..e5b84ab 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -28,61 +13,62 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface RoleServiceAsync { /** - * Create a new role. If there is an existing role with the same name as the one - * specified in the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one specified in + * the request, will return the existing role unmodified */ @JvmOverloads - fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a role object by its id */ @JvmOverloads - fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a role object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ @JvmOverloads - fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first */ @JvmOverloads - fun list(params: RoleListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: RoleListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a role object by its id */ @JvmOverloads - fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Create or replace role. If there is an existing role with the same name as the - * one specified in the request, will replace the existing role with the provided - * fields + * Create or replace role. If there is an existing role with the same name as the one specified + * in the request, will replace the existing role with the provided fields */ @JvmOverloads - fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index c844916..87b3e81 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -26,212 +16,209 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class RoleServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : RoleServiceAsync { +class RoleServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : RoleServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new role. If there is an existing role with the same name as the one - * specified in the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one specified in + * the request, will return the existing role unmodified */ - override fun create(params: RoleCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a role object by its id */ - override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a role object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ - override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first */ - override fun list(params: RoleListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - RoleListPageAsync.of(this, params, it) - } - } + override fun list( + params: RoleListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { RoleListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a role object by its id */ - override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace role. If there is an existing role with the same name as the - * one specified in the request, will replace the existing role with the provided - * fields + * Create or replace role. If there is an existing role with the same name as the one specified + * in the request, will replace the existing role with the provided fields */ - override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index c268c63..14126dd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -4,47 +4,16 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.TopLevelHelloWorldParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.models.TopLevelHelloWorldParams +import java.util.concurrent.CompletableFuture interface TopLevelServiceAsync { - /** - * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not - * required - */ + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ @JvmOverloads - fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index b74f82d..62a8040 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -2,67 +2,44 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.TopLevelHelloWorldParams import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.models.TopLevelHelloWorldParams import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class TopLevelServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : TopLevelServiceAsync { +class TopLevelServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : TopLevelServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = - stringHandler() - .withErrorHandler(errorHandler) + private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) - /** - * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not - * required - */ - override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - helloWorldHandler.handle(it) - } - } + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response.use { helloWorldHandler.handle(it) } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index 896cc94..e7d8350 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -4,54 +4,29 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPageAsync import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface UserServiceAsync { /** Get a user object by its id */ @JvmOverloads - fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first */ @JvmOverloads - fun list(params: UserListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: UserListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 11ec768..3cbcf8e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -2,105 +2,88 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.User -import com.braintrustdata.api.models.UserListPageAsync -import com.braintrustdata.api.models.UserListParams -import com.braintrustdata.api.models.UserRetrieveParams import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.models.User +import com.braintrustdata.api.models.UserListPageAsync +import com.braintrustdata.api.models.UserListParams +import com.braintrustdata.api.models.UserRetrieveParams import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class UserServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : UserServiceAsync { +class UserServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : UserServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a user object by its id */ - override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first */ - override fun list(params: UserListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - UserListPageAsync.of(this, params, it) - } - } + override fun list( + params: UserListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { UserListPageAsync.of(this, params, it) } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index 9b674ca..f8fd649 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -28,62 +13,62 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface ViewServiceAsync { /** - * Create a new view. If there is an existing view in the project with the same - * name as the one specified in the request, will return the existing view - * unmodified + * Create a new view. If there is an existing view in the project with the same name as the one + * specified in the request, will return the existing view unmodified */ @JvmOverloads - fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Get a view object by its id */ @JvmOverloads - fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Partially update a view object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ @JvmOverloads - fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created + * views coming first */ @JvmOverloads - fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Delete a view object by its id */ @JvmOverloads - fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Create or replace view. If there is an existing view in the project with the - * same name as the one specified in the request, will replace the existing view - * with the provided fields + * Create or replace view. If there is an existing view in the project with the same name as the + * one specified in the request, will replace the existing view with the provided fields */ @JvmOverloads - fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index d8fa365..c7a4a62 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -26,209 +16,209 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class ViewServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ViewServiceAsync { +class ViewServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ViewServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new view. If there is an existing view in the project with the same - * name as the one specified in the request, will return the existing view - * unmodified + * Create a new view. If there is an existing view in the project with the same name as the one + * specified in the request, will return the existing view unmodified */ - override fun create(params: ViewCreateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a view object by its id */ - override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a view object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ - override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created + * views coming first */ - override fun list(params: ViewListParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ViewListPageAsync.of(this, params, it) - } - } + override fun list( + params: ViewListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ViewListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a view object by its id */ - override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace view. If there is an existing view in the project with the - * same name as the one specified in the request, will replace the existing view - * with the provided fields + * Create or replace view. If there is an existing view in the project with the same name as the + * one specified in the request, will replace the existing view with the provided fields */ - override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt new file mode 100644 index 0000000..435ede1 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.braintrustdata.api.services.async.organizations + +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import com.braintrustdata.api.models.OrganizationMemberUpdateResponse +import java.util.concurrent.CompletableFuture + +interface MemberServiceAsync { + + /** Modify organization membership */ + @JvmOverloads + fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt new file mode 100644 index 0000000..267cbeb --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async.organizations + +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import com.braintrustdata.api.models.OrganizationMemberUpdateResponse +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture + +class MemberServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : MemberServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Modify organization membership */ + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt deleted file mode 100644 index 23fc4d4..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.async.project - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse -import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler - -interface LogServiceAsync { - - /** Log feedback for a set of project logs events */ - @JvmOverloads - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body - */ - @JvmOverloads - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query - */ - @JvmOverloads - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - - /** Insert a set of events into the project logs */ - @JvmOverloads - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt deleted file mode 100644 index 4af9aea..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.async.project - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse -import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler - -class LogServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : LogServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) - - /** Log feedback for a set of project logs events */ - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - feedbackHandler.handle(it) - } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body - */ - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query - */ - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Insert a set of events into the project logs */ - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index efb5b4f..c719215 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.async.projects -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -27,45 +12,41 @@ import com.braintrustdata.api.models.ProjectLogFetchPostResponse import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture interface LogServiceAsync { /** Log feedback for a set of project logs events */ @JvmOverloads - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with + * the parameters in the URL query rather than in the request body */ @JvmOverloads - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ @JvmOverloads - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture /** Insert a set of events into the project logs */ @JvmOverloads - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index b5d708c..78f67b8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.async.projects -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -25,137 +15,138 @@ import com.braintrustdata.api.models.ProjectLogFetchPostResponse import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture -class LogServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : LogServiceAsync { +class LogServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : LogServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) + private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Log feedback for a set of project logs events */ - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - feedbackHandler.handle(it) - } - } + override fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response.use { feedbackHandler.handle(it) } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with + * the parameters in the URL query rather than in the request body */ - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { fetchHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { fetchPostHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions) - .thenApply { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { insertHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index c748e52..d314e4f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -4,65 +4,39 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface AclService { /** - * Create a new acl. If there is an existing acl with the same contents as the one - * specified in the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one specified in + * the request, will return the existing acl unmodified */ @JvmOverloads fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** Get an acl object by its id */ @JvmOverloads - fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Acl + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Acl /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ @JvmOverloads - fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): AclListPage + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): AclListPage /** Delete an acl object by its id */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index af822d9..bac0ed1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -2,170 +2,136 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class AclServiceImpl constructor(private val clientOptions: ClientOptions, ) : AclService { +class AclServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : AclService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new acl. If there is an existing acl with the same contents as the one - * specified in the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one specified in + * the request, will return the existing acl unmodified */ override fun create(params: AclCreateParams, requestOptions: RequestOptions): Acl { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get an acl object by its id */ override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): Acl { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ override fun list(params: AclListParams, requestOptions: RequestOptions): AclListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - AclListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { AclListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete an acl object by its id */ override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): Acl { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index e1840cf..147576e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyCreateResponse @@ -27,45 +12,40 @@ import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface ApiKeyService { /** - * Create a new api_key. It is possible to have multiple API keys with the same - * name. There is no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same name. There is + * no de-duplication */ @JvmOverloads - fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKeyCreateResponse + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ApiKeyCreateResponse /** Get an api_key object by its id */ @JvmOverloads - fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ApiKey /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ @JvmOverloads - fun list(params: ApiKeyListParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKeyListPage + fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ApiKeyListPage /** Delete an api_key object by its id */ @JvmOverloads - fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ApiKey } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index ae2bb35..f8b088f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyCreateResponse @@ -25,148 +15,128 @@ import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ApiKeyServiceImpl constructor(private val clientOptions: ClientOptions, ) : ApiKeyService { +class ApiKeyServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ApiKeyService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new api_key. It is possible to have multiple API keys with the same - * name. There is no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same name. There is + * no de-duplication */ - override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): ApiKeyCreateResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions + ): ApiKeyCreateResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get an api_key object by its id */ override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): ApiKey { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): ApiKeyListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ApiKeyListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ApiKeyListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete an api_key object by its id */ override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): ApiKey { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 0d5f3a6..ce1e5d9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -36,80 +21,92 @@ import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface DatasetService { /** - * Create a new dataset. If there is an existing dataset in the project with the - * same name as the one specified in the request, will return the existing dataset - * unmodified + * Create a new dataset. If there is an existing dataset in the project with the same name as + * the one specified in the request, will return the existing dataset unmodified */ @JvmOverloads - fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Dataset /** Get a dataset object by its id */ @JvmOverloads - fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Dataset /** - * Partially update a dataset object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Dataset /** * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ @JvmOverloads - fun list(params: DatasetListParams, requestOptions: RequestOptions = RequestOptions.none()): DatasetListPage + fun list( + params: DatasetListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): DatasetListPage /** Delete a dataset object by its id */ @JvmOverloads - fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Dataset /** Log feedback for a set of dataset events */ @JvmOverloads - fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()) + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none() + ) /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but - * with the parameters in the URL query rather than in the request body + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ @JvmOverloads - fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): DatasetFetchResponse + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none() + ): DatasetFetchResponse /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but - * with the parameters in the request body rather than in the URL query + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ @JvmOverloads - fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): DatasetFetchPostResponse + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none() + ): DatasetFetchPostResponse /** Insert a set of events into the dataset */ @JvmOverloads - fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): DatasetInsertResponse + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none() + ): DatasetInsertResponse /** Summarize dataset */ @JvmOverloads - fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): DatasetSummarizeResponse + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none() + ): DatasetSummarizeResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index b0ce9ce..fefb964 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -34,320 +24,297 @@ import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetSummarizeResponse import com.braintrustdata.api.models.DatasetUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class DatasetServiceImpl constructor(private val clientOptions: ClientOptions, ) : DatasetService { +class DatasetServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : DatasetService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new dataset. If there is an existing dataset in the project with the - * same name as the one specified in the request, will return the existing dataset - * unmodified + * Create a new dataset. If there is an existing dataset in the project with the same name as + * the one specified in the request, will return the existing dataset unmodified */ override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): Dataset { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a dataset object by its id */ override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): Dataset { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a dataset object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): Dataset { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ override fun list(params: DatasetListParams, requestOptions: RequestOptions): DatasetListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - DatasetListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { DatasetListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a dataset object by its id */ override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): Dataset { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) + private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Log feedback for a set of dataset events */ override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions) { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - feedbackHandler.handle(it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + clientOptions.httpClient.execute(request, requestOptions).let { response -> + response.use { feedbackHandler.handle(it) } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but - * with the parameters in the URL query rather than in the request body + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ - override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): DatasetFetchResponse { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions + ): DatasetFetchResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { fetchHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but - * with the parameters in the request body rather than in the URL query + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ - override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): DatasetFetchPostResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions + ): DatasetFetchPostResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { fetchPostHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the dataset */ - override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): DatasetInsertResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions + ): DatasetInsertResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { insertHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize dataset */ - override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): DatasetSummarizeResponse { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - summarizeHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions + ): DatasetSummarizeResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { summarizeHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 180c814..3156a0e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -36,80 +21,92 @@ import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface ExperimentService { /** - * Create a new experiment. If there is an existing experiment in the project with - * the same name as the one specified in the request, will return the existing - * experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with the same name + * as the one specified in the request, will return the existing experiment unmodified */ @JvmOverloads - fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Experiment /** Get an experiment object by its id */ @JvmOverloads - fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Experiment /** - * Partially update an experiment object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Experiment /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ @JvmOverloads - fun list(params: ExperimentListParams, requestOptions: RequestOptions = RequestOptions.none()): ExperimentListPage + fun list( + params: ExperimentListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExperimentListPage /** Delete an experiment object by its id */ @JvmOverloads - fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Experiment /** Log feedback for a set of experiment events */ @JvmOverloads - fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()) + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none() + ) /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, - * but with the parameters in the URL query rather than in the request body + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ @JvmOverloads - fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): ExperimentFetchResponse + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExperimentFetchResponse /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ @JvmOverloads - fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): ExperimentFetchPostResponse + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExperimentFetchPostResponse /** Insert a set of events into the experiment */ @JvmOverloads - fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): ExperimentInsertResponse + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExperimentInsertResponse /** Summarize experiment */ @JvmOverloads - fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): ExperimentSummarizeResponse + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExperimentSummarizeResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 753f300..7df45f8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -34,320 +24,314 @@ import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentSummarizeResponse import com.braintrustdata.api.models.ExperimentUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ExperimentServiceImpl constructor(private val clientOptions: ClientOptions, ) : ExperimentService { +class ExperimentServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ExperimentService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new experiment. If there is an existing experiment in the project with - * the same name as the one specified in the request, will return the existing - * experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with the same name + * as the one specified in the request, will return the existing experiment unmodified */ - override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): Experiment { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions + ): Experiment { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get an experiment object by its id */ - override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): Experiment { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions + ): Experiment { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update an experiment object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): Experiment { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions + ): Experiment { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ - override fun list(params: ExperimentListParams, requestOptions: RequestOptions): ExperimentListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ExperimentListPage.of(this, params, it) - } - } + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions + ): ExperimentListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ExperimentListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete an experiment object by its id */ - override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): Experiment { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions + ): Experiment { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) + private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Log feedback for a set of experiment events */ override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions) { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - feedbackHandler.handle(it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + clientOptions.httpClient.execute(request, requestOptions).let { response -> + response.use { feedbackHandler.handle(it) } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, - * but with the parameters in the URL query rather than in the request body + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body */ - override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): ExperimentFetchResponse { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions + ): ExperimentFetchResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { fetchHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ - override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): ExperimentFetchPostResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions + ): ExperimentFetchPostResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { fetchPostHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ - override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): ExperimentInsertResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions + ): ExperimentInsertResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { insertHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize experiment */ - override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): ExperimentSummarizeResponse { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - summarizeHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions + ): ExperimentSummarizeResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { summarizeHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index d318227..1fc7fb2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -4,91 +4,71 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams -import com.braintrustdata.api.models.FunctionFeedbackParams import com.braintrustdata.api.models.FunctionListPage import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface FunctionService { /** - * Create a new function. If there is an existing function in the project with the - * same slug as the one specified in the request, will return the existing function - * unmodified + * Create a new function. If there is an existing function in the project with the same slug as + * the one specified in the request, will return the existing function unmodified */ @JvmOverloads - fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Function /** Get a function object by its id */ @JvmOverloads - fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Function /** - * Partially update a function object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Function /** * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ @JvmOverloads - fun list(params: FunctionListParams, requestOptions: RequestOptions = RequestOptions.none()): FunctionListPage + fun list( + params: FunctionListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): FunctionListPage /** Delete a function object by its id */ @JvmOverloads - fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Function - - /** Log feedback for a set of function events */ - @JvmOverloads - fun feedback(params: FunctionFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()) + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Function /** - * Create or replace function. If there is an existing function in the project with - * the same slug as the one specified in the request, will replace the existing - * function with the provided fields + * Create or replace function. If there is an existing function in the project with the same + * slug as the one specified in the request, will replace the existing function with the + * provided fields */ @JvmOverloads - fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Function } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 5616a7b..18c3be1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -2,261 +2,205 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams -import com.braintrustdata.api.models.FunctionFeedbackParams import com.braintrustdata.api.models.FunctionListPage import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class FunctionServiceImpl constructor(private val clientOptions: ClientOptions, ) : FunctionService { +class FunctionServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : FunctionService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new function. If there is an existing function in the project with the - * same slug as the one specified in the request, will return the existing function - * unmodified + * Create a new function. If there is an existing function in the project with the same slug as + * the one specified in the request, will return the existing function unmodified */ override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): Function { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a function object by its id */ - override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): Function { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions + ): Function { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a function object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): Function { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ - override fun list(params: FunctionListParams, requestOptions: RequestOptions): FunctionListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - FunctionListPage.of(this, params, it) - } - } + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions + ): FunctionListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { FunctionListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a function object by its id */ override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): Function { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) - - /** Log feedback for a set of function events */ - override fun feedback(params: FunctionFeedbackParams, requestOptions: RequestOptions) { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - feedbackHandler.handle(it) - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace function. If there is an existing function in the project with - * the same slug as the one specified in the request, will replace the existing - * function with the provided fields + * Create or replace function. If there is an existing function in the project with the same + * slug as the one specified in the request, will replace the existing function with the + * provided fields */ override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): Function { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index 3208cfa..2b544c2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -28,61 +13,61 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface GroupService { /** - * Create a new group. If there is an existing group with the same name as the one - * specified in the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one specified in + * the request, will return the existing group unmodified */ @JvmOverloads - fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Group /** Get a group object by its id */ @JvmOverloads - fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Group /** - * Partially update a group object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ @JvmOverloads - fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Group /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ @JvmOverloads - fun list(params: GroupListParams, requestOptions: RequestOptions = RequestOptions.none()): GroupListPage + fun list( + params: GroupListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): GroupListPage /** Delete a group object by its id */ @JvmOverloads - fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Group /** - * Create or replace group. If there is an existing group with the same name as the - * one specified in the request, will replace the existing group with the provided - * fields + * Create or replace group. If there is an existing group with the same name as the one + * specified in the request, will replace the existing group with the provided fields */ @JvmOverloads - fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Group } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index b4edfaa..352a97e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -26,212 +16,183 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class GroupServiceImpl constructor(private val clientOptions: ClientOptions, ) : GroupService { +class GroupServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : GroupService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new group. If there is an existing group with the same name as the one - * specified in the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one specified in + * the request, will return the existing group unmodified */ override fun create(params: GroupCreateParams, requestOptions: RequestOptions): Group { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a group object by its id */ override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): Group { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a group object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): Group { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ override fun list(params: GroupListParams, requestOptions: RequestOptions): GroupListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - GroupListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { GroupListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a group object by its id */ override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): Group { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace group. If there is an existing group with the same name as the - * one specified in the request, will replace the existing group with the provided - * fields + * Create or replace group. If there is an existing group with the same name as the one + * specified in the request, will replace the existing group with the provided fields */ override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): Group { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index 43ac3ed..0125f7b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -4,68 +4,51 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.services.blocking.organizations.MemberService interface OrganizationService { + fun members(): MemberService + /** Get a organization object by its id */ @JvmOverloads - fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Organization + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Organization /** - * Partially update a organization object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Organization + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Organization /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ @JvmOverloads - fun list(params: OrganizationListParams, requestOptions: RequestOptions = RequestOptions.none()): OrganizationListPage + fun list( + params: OrganizationListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): OrganizationListPage /** Delete a organization object by its id */ @JvmOverloads - fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Organization + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Organization } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 8371b5e..978487c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -2,171 +2,156 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.blocking.organizations.MemberService +import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class OrganizationServiceImpl constructor(private val clientOptions: ClientOptions, ) : OrganizationService { +class OrganizationServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : OrganizationService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } + + override fun members(): MemberService = members + private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a organization object by its id */ - override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): Organization { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions + ): Organization { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a organization object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): Organization { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions + ): Organization { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ - override fun list(params: OrganizationListParams, requestOptions: RequestOptions): OrganizationListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - OrganizationListPage.of(this, params, it) - } - } + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions + ): OrganizationListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { OrganizationListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a organization object by its id */ - override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): Organization { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions + ): Organization { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index 7590d01..d440a9a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -28,62 +13,63 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface ProjectScoreService { /** - * Create a new project_score. If there is an existing project_score in the project - * with the same name as the one specified in the request, will return the existing - * project_score unmodified + * Create a new project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will return the existing project_score + * unmodified */ @JvmOverloads - fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectScore /** Get a project_score object by its id */ @JvmOverloads - fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectScore /** - * Partially update a project_score object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectScore /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ @JvmOverloads - fun list(params: ProjectScoreListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScoreListPage + fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectScoreListPage /** Delete a project_score object by its id */ @JvmOverloads - fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectScore /** - * Create or replace project_score. If there is an existing project_score in the - * project with the same name as the one specified in the request, will replace the - * existing project_score with the provided fields + * Create or replace project_score. If there is an existing project_score in the project with + * the same name as the one specified in the request, will replace the existing project_score + * with the provided fields */ @JvmOverloads - fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectScore } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index 5879dd1..8adb60b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -26,213 +16,204 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ProjectScoreServiceImpl constructor(private val clientOptions: ClientOptions, ) : ProjectScoreService { +class ProjectScoreServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectScoreService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new project_score. If there is an existing project_score in the project - * with the same name as the one specified in the request, will return the existing - * project_score unmodified + * Create a new project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will return the existing project_score + * unmodified */ - override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): ProjectScore { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions + ): ProjectScore { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project_score object by its id */ - override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): ProjectScore { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions + ): ProjectScore { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a project_score object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): ProjectScore { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions + ): ProjectScore { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ - override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): ProjectScoreListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ProjectScoreListPage.of(this, params, it) - } - } + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions + ): ProjectScoreListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ProjectScoreListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project_score object by its id */ - override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): ProjectScore { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions + ): ProjectScore { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace project_score. If there is an existing project_score in the - * project with the same name as the one specified in the request, will replace the - * existing project_score with the provided fields + * Create or replace project_score. If there is an existing project_score in the project with + * the same name as the one specified in the request, will replace the existing project_score + * with the provided fields */ - override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): ProjectScore { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions + ): ProjectScore { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index 0ada962..3c46992 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -27,57 +12,54 @@ import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler import com.braintrustdata.api.services.blocking.projects.LogService -import com.braintrustdata.api.services.blocking.projects.LogServiceImpl interface ProjectService { fun logs(): LogService /** - * Create a new project. If there is an existing project with the same name as the - * one specified in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the one specified + * in the request, will return the existing project unmodified */ @JvmOverloads - fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Project /** Get a project object by its id */ @JvmOverloads - fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Project /** - * Partially update a project object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Project /** * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ @JvmOverloads - fun list(params: ProjectListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectListPage + fun list( + params: ProjectListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectListPage /** Delete a project object by its id */ @JvmOverloads - fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Project } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 26e79dd..9a16636 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -25,27 +15,17 @@ import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.blocking.projects.LogService +import com.braintrustdata.api.services.blocking.projects.LogServiceImpl import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -import com.braintrustdata.api.services.blocking.projects.LogService -import com.braintrustdata.api.services.blocking.projects.LogServiceImpl -class ProjectServiceImpl constructor(private val clientOptions: ClientOptions, ) : ProjectService { +class ProjectServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -54,157 +34,142 @@ class ProjectServiceImpl constructor(private val clientOptions: ClientOptions, ) override fun logs(): LogService = logs private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new project. If there is an existing project with the same name as the - * one specified in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the one specified + * in the request, will return the existing project unmodified */ override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): Project { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project object by its id */ override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): Project { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a project object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): Project { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ override fun list(params: ProjectListParams, requestOptions: RequestOptions): ProjectListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ProjectListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ProjectListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project object by its id */ override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): Project { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index 45c010a..e240afd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -28,62 +13,62 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface ProjectTagService { /** - * Create a new project_tag. If there is an existing project_tag in the project - * with the same name as the one specified in the request, will return the existing - * project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will return the existing project_tag unmodified */ @JvmOverloads - fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectTag /** Get a project_tag object by its id */ @JvmOverloads - fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectTag /** - * Partially update a project_tag object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectTag /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ @JvmOverloads - fun list(params: ProjectTagListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTagListPage + fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectTagListPage /** Delete a project_tag object by its id */ @JvmOverloads - fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectTag /** - * Create or replace project_tag. If there is an existing project_tag in the - * project with the same name as the one specified in the request, will replace the - * existing project_tag with the provided fields + * Create or replace project_tag. If there is an existing project_tag in the project with the + * same name as the one specified in the request, will replace the existing project_tag with the + * provided fields */ @JvmOverloads - fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectTag } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 91ccd8b..79ec9e7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -26,213 +16,203 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ProjectTagServiceImpl constructor(private val clientOptions: ClientOptions, ) : ProjectTagService { +class ProjectTagServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectTagService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new project_tag. If there is an existing project_tag in the project - * with the same name as the one specified in the request, will return the existing - * project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will return the existing project_tag unmodified */ - override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): ProjectTag { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions + ): ProjectTag { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project_tag object by its id */ - override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): ProjectTag { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions + ): ProjectTag { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a project_tag object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): ProjectTag { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions + ): ProjectTag { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ - override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): ProjectTagListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ProjectTagListPage.of(this, params, it) - } - } + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions + ): ProjectTagListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ProjectTagListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project_tag object by its id */ - override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): ProjectTag { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions + ): ProjectTag { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace project_tag. If there is an existing project_tag in the - * project with the same name as the one specified in the request, will replace the - * existing project_tag with the provided fields + * Create or replace project_tag. If there is an existing project_tag in the project with the + * same name as the one specified in the request, will replace the existing project_tag with the + * provided fields */ - override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): ProjectTag { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions + ): ProjectTag { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index 62fa126..7831606 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -4,91 +4,70 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptFeedbackParams import com.braintrustdata.api.models.PromptListPage import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface PromptService { /** - * Create a new prompt. If there is an existing prompt in the project with the same - * slug as the one specified in the request, will return the existing prompt - * unmodified + * Create a new prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will return the existing prompt unmodified */ @JvmOverloads - fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Prompt /** Get a prompt object by its id */ @JvmOverloads - fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Prompt /** - * Partially update a prompt object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ @JvmOverloads - fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Prompt /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ @JvmOverloads - fun list(params: PromptListParams, requestOptions: RequestOptions = RequestOptions.none()): PromptListPage + fun list( + params: PromptListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): PromptListPage /** Delete a prompt object by its id */ @JvmOverloads - fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt - - /** Log feedback for a set of prompt events */ - @JvmOverloads - fun feedback(params: PromptFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()) + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Prompt /** - * Create or replace prompt. If there is an existing prompt in the project with the - * same slug as the one specified in the request, will replace the existing prompt - * with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the same slug as + * the one specified in the request, will replace the existing prompt with the provided fields */ @JvmOverloads - fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Prompt } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 28b7692..25e6d6b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -2,261 +2,198 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptFeedbackParams import com.braintrustdata.api.models.PromptListPage import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class PromptServiceImpl constructor(private val clientOptions: ClientOptions, ) : PromptService { +class PromptServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : PromptService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new prompt. If there is an existing prompt in the project with the same - * slug as the one specified in the request, will return the existing prompt - * unmodified + * Create a new prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will return the existing prompt unmodified */ override fun create(params: PromptCreateParams, requestOptions: RequestOptions): Prompt { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a prompt object by its id */ override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): Prompt { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a prompt object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): Prompt { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ override fun list(params: PromptListParams, requestOptions: RequestOptions): PromptListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - PromptListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { PromptListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a prompt object by its id */ override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): Prompt { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) - - /** Log feedback for a set of prompt events */ - override fun feedback(params: PromptFeedbackParams, requestOptions: RequestOptions) { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - feedbackHandler.handle(it) - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace prompt. If there is an existing prompt in the project with the - * same slug as the one specified in the request, will replace the existing prompt - * with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the same slug as + * the one specified in the request, will replace the existing prompt with the provided fields */ override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): Prompt { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index c4c7163..6ae7e70 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -28,61 +13,61 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface RoleService { /** - * Create a new role. If there is an existing role with the same name as the one - * specified in the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one specified in + * the request, will return the existing role unmodified */ @JvmOverloads - fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Role /** Get a role object by its id */ @JvmOverloads - fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Role /** - * Partially update a role object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ @JvmOverloads - fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Role /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first */ @JvmOverloads - fun list(params: RoleListParams, requestOptions: RequestOptions = RequestOptions.none()): RoleListPage + fun list( + params: RoleListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): RoleListPage /** Delete a role object by its id */ @JvmOverloads - fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Role /** - * Create or replace role. If there is an existing role with the same name as the - * one specified in the request, will replace the existing role with the provided - * fields + * Create or replace role. If there is an existing role with the same name as the one specified + * in the request, will replace the existing role with the provided fields */ @JvmOverloads - fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Role } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 8802b78..5f49a6b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -26,212 +16,183 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class RoleServiceImpl constructor(private val clientOptions: ClientOptions, ) : RoleService { +class RoleServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : RoleService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new role. If there is an existing role with the same name as the one - * specified in the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one specified in + * the request, will return the existing role unmodified */ override fun create(params: RoleCreateParams, requestOptions: RequestOptions): Role { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a role object by its id */ override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): Role { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a role object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): Role { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first */ override fun list(params: RoleListParams, requestOptions: RequestOptions): RoleListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - RoleListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { RoleListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a role object by its id */ override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): Role { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { - params.getBody().ifPresent { - body(json(clientOptions.jsonMapper, it)) - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } } - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace role. If there is an existing role with the same name as the - * one specified in the request, will replace the existing role with the provided - * fields + * Create or replace role. If there is an existing role with the same name as the one specified + * in the request, will replace the existing role with the provided fields */ override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): Role { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index f3f4e4e..5aba74f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -4,47 +4,15 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.TopLevelHelloWorldParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.models.TopLevelHelloWorldParams interface TopLevelService { - /** - * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not - * required - */ + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ @JvmOverloads - fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions = RequestOptions.none()): String + fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions = RequestOptions.none() + ): String } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 051a7f2..631eac9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -2,67 +2,42 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.TopLevelHelloWorldParams import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.models.TopLevelHelloWorldParams import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class TopLevelServiceImpl constructor(private val clientOptions: ClientOptions, ) : TopLevelService { +class TopLevelServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : TopLevelService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = - stringHandler() - .withErrorHandler(errorHandler) + private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) - /** - * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not - * required - */ - override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): String { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - helloWorldHandler.handle(it) - } - } + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions + ): String { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response.use { helloWorldHandler.handle(it) } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index ef4b720..53e07dc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -4,54 +4,28 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface UserService { /** Get a user object by its id */ @JvmOverloads - fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): User + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): User /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first */ @JvmOverloads - fun list(params: UserListParams, requestOptions: RequestOptions = RequestOptions.none()): UserListPage + fun list( + params: UserListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): UserListPage } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 0f20d0e..28ff5d7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -2,105 +2,78 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.User -import com.braintrustdata.api.models.UserListPage -import com.braintrustdata.api.models.UserListParams -import com.braintrustdata.api.models.UserRetrieveParams import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.models.User +import com.braintrustdata.api.models.UserListPage +import com.braintrustdata.api.models.UserListParams +import com.braintrustdata.api.models.UserRetrieveParams import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class UserServiceImpl constructor(private val clientOptions: ClientOptions, ) : UserService { +class UserServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : UserService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a user object by its id */ override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): User { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first */ override fun list(params: UserListParams, requestOptions: RequestOptions): UserListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - UserListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { UserListPage.of(this, params, it) } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index 70b1b24..c9b1648 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -28,62 +13,61 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface ViewService { /** - * Create a new view. If there is an existing view in the project with the same - * name as the one specified in the request, will return the existing view - * unmodified + * Create a new view. If there is an existing view in the project with the same name as the one + * specified in the request, will return the existing view unmodified */ @JvmOverloads - fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): View /** Get a view object by its id */ @JvmOverloads - fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): View /** - * Partially update a view object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ @JvmOverloads - fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): View /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created + * views coming first */ @JvmOverloads - fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): ViewListPage + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ViewListPage /** Delete a view object by its id */ @JvmOverloads - fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): View /** - * Create or replace view. If there is an existing view in the project with the - * same name as the one specified in the request, will replace the existing view - * with the provided fields + * Create or replace view. If there is an existing view in the project with the same name as the + * one specified in the request, will replace the existing view with the provided fields */ @JvmOverloads - fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): View } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 357fd00..fc8dd34 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -26,209 +16,183 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ViewServiceImpl constructor(private val clientOptions: ClientOptions, ) : ViewService { +class ViewServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ViewService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create a new view. If there is an existing view in the project with the same - * name as the one specified in the request, will return the existing view - * unmodified + * Create a new view. If there is an existing view in the project with the same name as the one + * specified in the request, will return the existing view unmodified */ override fun create(params: ViewCreateParams, requestOptions: RequestOptions): View { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - createHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a view object by its id */ override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): View { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - retrieveHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Partially update a view object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): View { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - updateHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created + * views coming first */ override fun list(params: ViewListParams, requestOptions: RequestOptions): ViewListPage { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - listHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { - ViewListPage.of(this, params, it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ViewListPage.of(this, params, it) } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a view object by its id */ override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): View { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - deleteHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** - * Create or replace view. If there is an existing view in the project with the - * same name as the one specified in the request, will replace the existing view - * with the provided fields + * Create or replace view. If there is an existing view in the project with the same name as the + * one specified in the request, will replace the existing view with the provided fields */ override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): View { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - replaceHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt new file mode 100644 index 0000000..29561e1 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.braintrustdata.api.services.blocking.organizations + +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import com.braintrustdata.api.models.OrganizationMemberUpdateResponse + +interface MemberService { + + /** Modify organization membership */ + @JvmOverloads + fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): OrganizationMemberUpdateResponse +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt new file mode 100644 index 0000000..b8126ca --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking.organizations + +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import com.braintrustdata.api.models.OrganizationMemberUpdateResponse +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.withErrorHandler + +class MemberServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : MemberService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Modify organization membership */ + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions + ): OrganizationMemberUpdateResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt deleted file mode 100644 index 4265a09..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.blocking.project - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse -import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler - -interface LogService { - - /** Log feedback for a set of project logs events */ - @JvmOverloads - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body - */ - @JvmOverloads - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectLogFetchResponse - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query - */ - @JvmOverloads - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectLogFetchPostResponse - - /** Insert a set of events into the project logs */ - @JvmOverloads - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectLogInsertResponse -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt deleted file mode 100644 index f2c82e7..0000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.blocking.project - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostResponse -import com.braintrustdata.api.models.ProjectLogFetchResponse -import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler - -class LogServiceImpl constructor(private val clientOptions: ClientOptions, ) : LogService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) - - /** Log feedback for a set of project logs events */ - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions) { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - feedbackHandler.handle(it) - } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body - */ - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): ProjectLogFetchResponse { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query - */ - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): ProjectLogFetchPostResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Insert a set of events into the project logs */ - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): ProjectLogInsertResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index a95f8ea..1ce6166 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -4,22 +4,7 @@ package com.braintrustdata.api.services.blocking.projects -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -27,45 +12,40 @@ import com.braintrustdata.api.models.ProjectLogFetchPostResponse import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler -import com.braintrustdata.api.services.withErrorHandler interface LogService { /** Log feedback for a set of project logs events */ @JvmOverloads - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()) + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none() + ) /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with + * the parameters in the URL query rather than in the request body */ @JvmOverloads - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectLogFetchResponse + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectLogFetchResponse /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ @JvmOverloads - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectLogFetchPostResponse + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectLogFetchPostResponse /** Insert a set of events into the project logs */ @JvmOverloads - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectLogInsertResponse + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectLogInsertResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 76ffea3..d8d6192 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -2,22 +2,12 @@ package com.braintrustdata.api.services.blocking.projects -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import kotlin.LazyThreadSafetyMode.PUBLICATION -import java.time.LocalDate -import java.time.Duration -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Base64 -import java.util.Optional -import java.util.UUID -import java.util.concurrent.CompletableFuture -import java.util.stream.Stream -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -25,137 +15,130 @@ import com.braintrustdata.api.models.ProjectLogFetchPostResponse import com.braintrustdata.api.models.ProjectLogFetchResponse import com.braintrustdata.api.models.ProjectLogInsertParams import com.braintrustdata.api.models.ProjectLogInsertResponse -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.multipartFormData -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class LogServiceImpl constructor(private val clientOptions: ClientOptions, ) : LogService { +class LogServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : LogService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = - emptyHandler() - .withErrorHandler(errorHandler) + private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Log feedback for a set of project logs events */ override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions) { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - feedbackHandler.handle(it) - } - } + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + clientOptions.httpClient.execute(request, requestOptions).let { response -> + response.use { feedbackHandler.handle(it) } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with + * the parameters in the URL query rather than in the request body */ - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): ProjectLogFetchResponse { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions + ): ProjectLogFetchResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { fetchHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query */ - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): ProjectLogFetchPostResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - fetchPostHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions + ): ProjectLogFetchPostResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { fetchPostHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): ProjectLogInsertResponse { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions) - .let { response -> - response.use { - insertHandler.handle(it) - } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions + ): ProjectLogInsertResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { insertHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt index bfb1777..d79a0c5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt @@ -43,9 +43,13 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { - ConditionEvaluationResult.disabled("Environment variable $SKIP_TESTS_ENV is set to true") + ConditionEvaluationResult.disabled( + "Environment variable $SKIP_TESTS_ENV is set to true" + ) } else { - ConditionEvaluationResult.enabled("Environment variable $SKIP_TESTS_ENV is not set to true") + ConditionEvaluationResult.enabled( + "Environment variable $SKIP_TESTS_ENV is not set to true" + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/client/BraintrustClientTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/client/BraintrustClientTest.kt deleted file mode 100644 index 68d59a3..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/client/BraintrustClientTest.kt +++ /dev/null @@ -1,5 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.client - -class BraintrustClientTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt index 79c4a82..8c93792 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt @@ -1,20 +1,22 @@ package com.braintrustdata.api.core.http -import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test internal class HttpRequestTest { @Test fun caseInsensitiveHeadersAccessors() { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .putHeader("something_lowercase", "lowercase") - .putHeader("Something_Capitalized", "Capitalized") - .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") - .build() + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .putHeader("something_lowercase", "lowercase") + .putHeader("Something_Capitalized", "Capitalized") + .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") + .build() assertThat(request.headers.get("SOMETHING_LOWERCASE").getOrNull(0)).isEqualTo("lowercase") - assertThat(request.headers.get("something_capitalized").getOrNull(0)).isEqualTo("Capitalized") + assertThat(request.headers.get("something_capitalized").getOrNull(0)) + .isEqualTo("Capitalized") assertThat(request.headers.get("Something_Uppercase").getOrNull(0)).isEqualTo("UPPERCASE") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt index 74095ee..16ddf16 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt @@ -1,14 +1,13 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.client.okhttp.OkHttpClient +import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.braintrustdata.api.client.okhttp.OkHttpClient +import com.github.tomakehurst.wiremock.stubbing.Scenario +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy -import com.github.tomakehurst.wiremock.stubbing.Scenario -import com.github.tomakehurst.wiremock.client.WireMock.* @WireMockTest internal class RetryingHttpClientTest { @@ -17,25 +16,16 @@ internal class RetryingHttpClientTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - httpClient = OkHttpClient.builder() - .baseUrl(wmRuntimeInfo.httpBaseUrl) - .build() + httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() resetAllScenarios() } @Test fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .build() - stubFor( - post(urlPathEqualTo("/something")) - .willReturn(ok()) - ) - val retryingClient = RetryingHttpClient.builder() - .httpClient(httpClient) - .build() + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) @@ -43,19 +33,18 @@ internal class RetryingHttpClientTest { @Test fun whenProvidedShouldAddIdempotencyHeaderToRequest() { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .build() + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() stubFor( post(urlPathEqualTo("/something")) .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) - val retryingClient = RetryingHttpClient.builder() - .httpClient(httpClient) - .idempotencyHeader("X-Some-Header") - .build() + val retryingClient = + RetryingHttpClient.builder() + .httpClient(httpClient) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) @@ -63,15 +52,15 @@ internal class RetryingHttpClientTest { @Test fun retryAfterHeader() { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .build() + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn(serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT")) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -88,10 +77,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = RetryingHttpClient.builder() - .httpClient(httpClient) - .maxRetries(2) - .build() + val retryingClient = + RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(3, postRequestedFor(urlPathEqualTo("/something"))) @@ -99,10 +86,8 @@ internal class RetryingHttpClientTest { @Test fun retryAfterMsHeader() { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .build() + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") @@ -117,10 +102,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = RetryingHttpClient.builder() - .httpClient(httpClient) - .maxRetries(1) - .build() + val retryingClient = + RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index eb6a334..f1c1f96 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt @@ -1,13 +1,13 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.core.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.braintrustdata.api.core.* +import java.util.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import java.util.* internal class SerializerTest { @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) @@ -23,9 +23,7 @@ internal class SerializerTest { fun isActive(): Boolean? = isActive.getNullable("is_active") - @JsonProperty("is_active") - @ExcludeMissing - fun _isActive() = isActive + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive @JsonAnyGetter @ExcludeMissing @@ -44,28 +42,30 @@ internal class SerializerTest { } return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties + isActive == other.isActive && + additionalProperties == other.additionalProperties } override fun hashCode(): Int { if (hashCode == 0) { - hashCode = Objects.hash( - isActive, - additionalProperties, - ) + hashCode = + Objects.hash( + isActive, + additionalProperties, + ) } return hashCode } - override fun toString() = "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" + override fun toString() = + "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" companion object { fun builder() = Builder() } @NoAutoDetect - class Builder{ + class Builder { private var isActive: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -73,9 +73,7 @@ internal class SerializerTest { @JsonProperty("is_active") @ExcludeMissing - fun isActive(isActive: JsonField) = apply { - this.isActive = isActive - } + fun isActive(isActive: JsonField) = apply { this.isActive = isActive } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -91,14 +89,14 @@ internal class SerializerTest { this.additionalProperties.putAll(additionalProperties) } - fun build(): ClassWithBooleanFieldPrefixedWithIs = ClassWithBooleanFieldPrefixedWithIs( - isActive, - additionalProperties.toUnmodifiable(), - ) + fun build(): ClassWithBooleanFieldPrefixedWithIs = + ClassWithBooleanFieldPrefixedWithIs( + isActive, + additionalProperties.toUnmodifiable(), + ) } } - @Test fun serializeBooleanPrefixedWithIs() { val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt index a40d556..87112c2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt @@ -2,66 +2,55 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.AclCreateParams -import com.braintrustdata.api.models.AclCreateParams.AclCreateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class AclCreateParamsTest { @Test fun createAclCreateParams() { - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getBody() { - val params = AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) - assertThat(body.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).isEqualTo(AclCreateParams.Permission.CREATE) - assertThat(body.restrictObjectType()).isEqualTo(AclCreateParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertThat(body.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).isEqualTo(AclCreateParams.Permission.CREATE) + assertThat(body.restrictObjectType()) + .isEqualTo(AclCreateParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun getBodyWithoutOptionalFields() { - val params = AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = + AclCreateParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt index 4dc708a..5b65f5d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt @@ -2,39 +2,24 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.AclDeleteParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class AclDeleteParamsTest { @Test fun createAclDeleteParams() { - AclDeleteParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = AclDeleteParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt index c78aaf5..aa22dbb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt @@ -2,62 +2,54 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.AclListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class AclListParamsTest { @Test fun createAclListParams() { - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(AclListParams.ObjectType.ORGANIZATION.toString())) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("ids", listOf(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("object_type", listOf(AclListParams.ObjectType.ORGANIZATION.toString())) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ) + expected.put("limit", listOf("123")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + AclListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclReplaceParamsTest.kt deleted file mode 100644 index ada5069..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclReplaceParamsTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class AclReplaceParamsTest { - - @Test - fun createAclReplaceParams() { - AclReplaceParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclReplaceParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclReplaceParams.Permission.CREATE) - .restrictObjectType(AclReplaceParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - } - - @Test - fun getBody() { - val params = - AclReplaceParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclReplaceParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclReplaceParams.Permission.CREATE) - .restrictObjectType(AclReplaceParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).isEqualTo(AclReplaceParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .isEqualTo(AclReplaceParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = - AclReplaceParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt index 5b77b91..ed334cc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.AclRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class AclRetrieveParamsTest { @Test fun createAclRetrieveParams() { - AclRetrieveParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = AclRetrieveParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt new file mode 100644 index 0000000..8c337a4 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ApiKeyCreateParamsTest { + + @Test + fun createApiKeyCreateParams() { + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + } + + @Test + fun getBody() { + val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).isEqualTo("org_name") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = ApiKeyCreateParams.builder().name("name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt new file mode 100644 index 0000000..19d81b4 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ApiKeyCreateResponseTest { + + @Test + fun createApiKeyCreateResponse() { + val apiKeyCreateResponse = + ApiKeyCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .key("key") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(apiKeyCreateResponse).isNotNull + assertThat(apiKeyCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyCreateResponse.key()).isEqualTo("key") + assertThat(apiKeyCreateResponse.name()).isEqualTo("name") + assertThat(apiKeyCreateResponse.previewName()).isEqualTo("preview_name") + assertThat(apiKeyCreateResponse.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateResponse.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyCreateResponse.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt new file mode 100644 index 0000000..bbcd063 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ApiKeyDeleteParamsTest { + + @Test + fun createApiKeyDeleteParams() { + ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun getPathParam() { + val params = + ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt new file mode 100644 index 0000000..e749c8e --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ApiKeyListParamsTest { + + @Test + fun createApiKeyListParams() { + ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getQueryParams() { + val params = + ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("api_key_name", listOf("api_key_name")) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = ApiKeyListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt new file mode 100644 index 0000000..48a5016 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ApiKeyRetrieveParamsTest { + + @Test + fun createApiKeyRetrieveParams() { + ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun getPathParam() { + val params = + ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt new file mode 100644 index 0000000..5d9ab3b --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ApiKeyTest { + + @Test + fun createApiKey() { + val apiKey = + ApiKey.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(apiKey).isNotNull + assertThat(apiKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.name()).isEqualTo("name") + assertThat(apiKey.previewName()).isEqualTo("preview_name") + assertThat(apiKey.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKey.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index 5cf91a8..1c64aaa 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -2,54 +2,41 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetCreateParams -import com.braintrustdata.api.models.DatasetCreateParams.DatasetCreateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetCreateParamsTest { @Test fun createDatasetCreateParams() { - DatasetCreateParams.builder() - .name("name") - .description("description") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetCreateParams.builder() + .name("name") + .description("description") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getBody() { - val params = DatasetCreateParams.builder() - .name("name") - .description("description") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = + DatasetCreateParams.builder() + .name("name") + .description("description") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun getBodyWithoutOptionalFields() { - val params = DatasetCreateParams.builder() - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = DatasetCreateParams.builder().name("name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt index 513b781..bb20923 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetDeleteParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetDeleteParamsTest { @Test fun createDatasetDeleteParams() { - DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index ec72004..a91ce93 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -2,85 +2,84 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetFeedbackParams -import com.braintrustdata.api.models.DatasetFeedbackParams.DatasetFeedbackBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetFeedbackParamsTest { @Test fun createDatasetFeedbackParams() { - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(DatasetFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) - .source(DatasetFeedbackParams.Feedback.Source.APP) - .build())) - .build() + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback( + listOf( + DatasetFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) + .source(DatasetFeedbackParams.Feedback.Source.APP) + .build() + ) + ) + .build() } @Test fun getBody() { - val params = DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(DatasetFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) - .source(DatasetFeedbackParams.Feedback.Source.APP) - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(DatasetFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) - .source(DatasetFeedbackParams.Feedback.Source.APP) - .build())) + val params = + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback( + listOf( + DatasetFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) + .source(DatasetFeedbackParams.Feedback.Source.APP) + .build() + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()) + .isEqualTo( + listOf( + DatasetFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) + .source(DatasetFeedbackParams.Feedback.Source.APP) + .build() + ) + ) } @Test fun getBodyWithoutOptionalFields() { - val params = DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(DatasetFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(DatasetFeedbackParams.Feedback.builder() - .id("id") - .build())) + val params = + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(DatasetFeedbackParams.Feedback.builder().id("id").build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()) + .isEqualTo(listOf(DatasetFeedbackParams.Feedback.builder().id("id").build())) } @Test fun getPathParam() { - val params = DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(DatasetFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(DatasetFeedbackParams.Feedback.builder().id("id").build())) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 6be62e7..260bb3b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -2,69 +2,57 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetFetchParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetFetchParamsTest { @Test fun createDatasetFetchParams() { - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getQueryParams() { - val params = DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("limit", listOf("123")) + expected.put("max_root_span_id", listOf("max_root_span_id")) + expected.put("max_xact_id", listOf("max_xact_id")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getPathParam() { - val params = DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index 924f1dd..e4188df 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -2,88 +2,93 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetFetchPostParams -import com.braintrustdata.api.models.DatasetFetchPostParams.DatasetFetchPostBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetFetchPostParamsTest { @Test fun createDatasetFetchPostParams() { - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters(listOf(DatasetFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters( + listOf( + DatasetFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getBody() { - val params = DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters(listOf(DatasetFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()).isEqualTo(listOf(DatasetFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + val params = + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters( + listOf( + DatasetFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()) + .isEqualTo( + listOf( + DatasetFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(DatasetFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + assertThat(body.limit()).isEqualTo(123L) + assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") + assertThat(body.maxXactId()).isEqualTo("max_xact_id") + assertThat(body.version()).isEqualTo("version") } @Test fun getBodyWithoutOptionalFields() { - val params = DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt index c96d521..812135a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt @@ -16,12 +16,12 @@ class DatasetFetchPostResponseTest { .events( listOf( DatasetFetchPostResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(DatasetFetchPostResponse.Event.Metadata.builder().build()) @@ -30,18 +30,18 @@ class DatasetFetchPostResponseTest { .build() ) ) - .cursor("string") + .cursor("cursor") .build() assertThat(datasetFetchPostResponse).isNotNull assertThat(datasetFetchPostResponse.events()) .containsExactly( DatasetFetchPostResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(DatasetFetchPostResponse.Event.Metadata.builder().build()) @@ -49,6 +49,6 @@ class DatasetFetchPostResponseTest { .tags(listOf("string")) .build() ) - assertThat(datasetFetchPostResponse.cursor()).contains("string") + assertThat(datasetFetchPostResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt index 479680b..d8a40e8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt @@ -16,12 +16,12 @@ class DatasetFetchResponseTest { .events( listOf( DatasetFetchResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(DatasetFetchResponse.Event.Metadata.builder().build()) @@ -30,18 +30,18 @@ class DatasetFetchResponseTest { .build() ) ) - .cursor("string") + .cursor("cursor") .build() assertThat(datasetFetchResponse).isNotNull assertThat(datasetFetchResponse.events()) .containsExactly( DatasetFetchResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(DatasetFetchResponse.Event.Metadata.builder().build()) @@ -49,6 +49,6 @@ class DatasetFetchResponseTest { .tags(listOf("string")) .build() ) - assertThat(datasetFetchResponse.cursor()).contains("string") + assertThat(datasetFetchResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 95af386..209f3ae 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -2,94 +2,137 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetInsertParams.DatasetInsertBody +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetInsertParamsTest { @Test fun createDatasetInsertParams() { - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(DatasetInsertParams.Event.InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build()))) - .build() + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + DatasetInsertParams.Event.ofInsertDatasetEventReplace( + DatasetInsertParams.Event.InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata + .builder() + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() } @Test fun getBody() { - val params = DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(DatasetInsertParams.Event.InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build()))) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()).isEqualTo(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(DatasetInsertParams.Event.InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build()))) + val params = + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + DatasetInsertParams.Event.ofInsertDatasetEventReplace( + DatasetInsertParams.Event.InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata + .builder() + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + DatasetInsertParams.Event.ofInsertDatasetEventReplace( + DatasetInsertParams.Event.InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + DatasetInsertParams.Event.InsertDatasetEventReplace.Metadata + .builder() + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) } @Test fun getBodyWithoutOptionalFields() { - val params = DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build()))) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()).isEqualTo(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build()))) + val params = + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + DatasetInsertParams.Event.ofInsertDatasetEventReplace( + DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build() + ) + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + DatasetInsertParams.Event.ofInsertDatasetEventReplace( + DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build() + ) + ) + ) } @Test fun getPathParam() { - val params = DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build()))) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + DatasetInsertParams.Event.ofInsertDatasetEventReplace( + DatasetInsertParams.Event.InsertDatasetEventReplace.builder().build() + ) + ) + ) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index ac1e6c7..66937ca 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -2,62 +2,57 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetListParamsTest { @Test fun createDatasetListParams() { - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("dataset_name", listOf("dataset_name")) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("ids", listOf(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("dataset_name", listOf("dataset_name")) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf( + DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = DatasetListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = DatasetListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetReplaceParamsTest.kt deleted file mode 100644 index 953731b..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetReplaceParamsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class DatasetReplaceParamsTest { - - @Test - fun createDatasetReplaceParams() { - DatasetReplaceParams.builder() - .name("string") - .description("string") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - } - - @Test - fun getBody() { - val params = - DatasetReplaceParams.builder() - .name("string") - .description("string") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("string") - assertThat(body.description()).isEqualTo("string") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = DatasetReplaceParams.builder().name("string").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt index f949540..776cce3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt @@ -2,39 +2,27 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetRetrieveParamsTest { @Test fun createDatasetRetrieveParams() { - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetRetrieveParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index 6bc204d..db5cbef 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -2,60 +2,52 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetSummarizeParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetSummarizeParamsTest { @Test fun createDatasetSummarizeParams() { - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() } @Test fun getQueryParams() { - val params = DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - val expected = mutableMapOf>() - expected.put("summarize_data", listOf("true")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + val expected = mutableMapOf>() + expected.put("summarize_data", listOf("true")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getPathParam() { - val params = DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt index 5a85884..fdb7b91 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt @@ -11,18 +11,18 @@ class DatasetSummarizeResponseTest { fun createDatasetSummarizeResponse() { val datasetSummarizeResponse = DatasetSummarizeResponse.builder() - .datasetName("string") + .datasetName("dataset_name") .datasetUrl("https://example.com") - .projectName("string") + .projectName("project_name") .projectUrl("https://example.com") .dataSummary( DatasetSummarizeResponse.DataSummary.builder().totalRecords(123L).build() ) .build() assertThat(datasetSummarizeResponse).isNotNull - assertThat(datasetSummarizeResponse.datasetName()).isEqualTo("string") + assertThat(datasetSummarizeResponse.datasetName()).isEqualTo("dataset_name") assertThat(datasetSummarizeResponse.datasetUrl()).isEqualTo("https://example.com") - assertThat(datasetSummarizeResponse.projectName()).isEqualTo("string") + assertThat(datasetSummarizeResponse.projectName()).isEqualTo("project_name") assertThat(datasetSummarizeResponse.projectUrl()).isEqualTo("https://example.com") assertThat(datasetSummarizeResponse.dataSummary()) .contains(DatasetSummarizeResponse.DataSummary.builder().totalRecords(123L).build()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt index bd1eebe..af6226f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt @@ -13,19 +13,21 @@ class DatasetTest { val dataset = Dataset.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") + .description("description") + .metadata(Dataset.Metadata.builder().build()) .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(dataset).isNotNull assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.name()).isEqualTo("string") + assertThat(dataset.name()).isEqualTo("name") assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.description()).contains("string") + assertThat(dataset.description()).contains("description") + assertThat(dataset.metadata()).contains(Dataset.Metadata.builder().build()) assertThat(dataset.projectId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index 4754f3e..e8dfdbe 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -2,67 +2,54 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.DatasetUpdateParams -import com.braintrustdata.api.models.DatasetUpdateParams.DatasetUpdateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class DatasetUpdateParamsTest { @Test fun createDatasetUpdateParams() { - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) - .name("name") - .build() + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder().build()) + .name("name") + .build() } @Test fun getBody() { - val params = DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") - assertThat(body.metadata()).isEqualTo(DatasetUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") + val params = + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder().build()) + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.description()).isEqualTo("description") + assertThat(body.metadata()).isEqualTo(DatasetUpdateParams.Metadata.builder().build()) + assertThat(body.name()).isEqualTo("name") } @Test fun getBodyWithoutOptionalFields() { - val params = DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index d5481db..3bbab60 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -2,105 +2,102 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentCreateParams -import com.braintrustdata.api.models.ExperimentCreateParams.ExperimentCreateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentCreateParamsTest { @Test fun createExperimentCreateParams() { - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder().build()) - .name("name") - .public_(true) - .repoInfo(ExperimentCreateParams.RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder().build()) + .name("name") + .public_(true) + .repoInfo( + ExperimentCreateParams.RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() } @Test fun getBody() { - val params = ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder().build()) - .name("name") - .public_(true) - .repoInfo(ExperimentCreateParams.RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).isEqualTo("dataset_version") - assertThat(body.description()).isEqualTo("description") - assertThat(body.ensureNew()).isEqualTo(true) - assertThat(body.metadata()).isEqualTo(ExperimentCreateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") - assertThat(body.public_()).isEqualTo(true) - assertThat(body.repoInfo()).isEqualTo(ExperimentCreateParams.RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) + val params = + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder().build()) + .name("name") + .public_(true) + .repoInfo( + ExperimentCreateParams.RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).isEqualTo("dataset_version") + assertThat(body.description()).isEqualTo("description") + assertThat(body.ensureNew()).isEqualTo(true) + assertThat(body.metadata()).isEqualTo(ExperimentCreateParams.Metadata.builder().build()) + assertThat(body.name()).isEqualTo("name") + assertThat(body.public_()).isEqualTo(true) + assertThat(body.repoInfo()) + .isEqualTo( + ExperimentCreateParams.RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) } @Test fun getBodyWithoutOptionalFields() { - val params = ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt index 3168b8d..4577db5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt @@ -2,39 +2,29 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentDeleteParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentDeleteParamsTest { @Test fun createExperimentDeleteParams() { - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index 1a4dd6d..852f6f6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -2,91 +2,91 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentFeedbackParams -import com.braintrustdata.api.models.ExperimentFeedbackParams.ExperimentFeedbackBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentFeedbackParamsTest { @Test fun createExperimentFeedbackParams() { - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ExperimentFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) - .source(ExperimentFeedbackParams.Feedback.Source.APP) - .build())) - .build() + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback( + listOf( + ExperimentFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) + .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) + .source(ExperimentFeedbackParams.Feedback.Source.APP) + .build() + ) + ) + .build() } @Test fun getBody() { - val params = ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ExperimentFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) - .source(ExperimentFeedbackParams.Feedback.Source.APP) - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(ExperimentFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) - .source(ExperimentFeedbackParams.Feedback.Source.APP) - .build())) + val params = + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback( + listOf( + ExperimentFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) + .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) + .source(ExperimentFeedbackParams.Feedback.Source.APP) + .build() + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()) + .isEqualTo( + listOf( + ExperimentFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) + .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) + .source(ExperimentFeedbackParams.Feedback.Source.APP) + .build() + ) + ) } @Test fun getBodyWithoutOptionalFields() { - val params = ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ExperimentFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(ExperimentFeedbackParams.Feedback.builder() - .id("id") - .build())) + val params = + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(ExperimentFeedbackParams.Feedback.builder().id("id").build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()) + .isEqualTo(listOf(ExperimentFeedbackParams.Feedback.builder().id("id").build())) } @Test fun getPathParam() { - val params = ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ExperimentFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(ExperimentFeedbackParams.Feedback.builder().id("id").build())) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index 7df38c2..138cbb6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -2,69 +2,61 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentFetchParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentFetchParamsTest { @Test fun createExperimentFetchParams() { - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getQueryParams() { - val params = ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("limit", listOf("123")) + expected.put("max_root_span_id", listOf("max_root_span_id")) + expected.put("max_xact_id", listOf("max_xact_id")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getPathParam() { - val params = ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index ad62480..990e491 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -2,88 +2,93 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentFetchPostParams -import com.braintrustdata.api.models.ExperimentFetchPostParams.ExperimentFetchPostBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentFetchPostParamsTest { @Test fun createExperimentFetchPostParams() { - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters(listOf(ExperimentFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters( + listOf( + ExperimentFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getBody() { - val params = ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters(listOf(ExperimentFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()).isEqualTo(listOf(ExperimentFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + val params = + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters( + listOf( + ExperimentFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()) + .isEqualTo( + listOf( + ExperimentFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(ExperimentFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + assertThat(body.limit()).isEqualTo(123L) + assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") + assertThat(body.maxXactId()).isEqualTo("max_xact_id") + assertThat(body.version()).isEqualTo("version") } @Test fun getBodyWithoutOptionalFields() { - val params = ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt index 7b11804..fc263cc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt @@ -16,21 +16,21 @@ class ExperimentFetchPostResponseTest { .events( listOf( ExperimentFetchPostResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ExperimentFetchPostResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) - .datasetRecordId("string") + .datasetRecordId("dataset_record_id") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(ExperimentFetchPostResponse.Event.Metadata.builder().build()) @@ -47,7 +47,7 @@ class ExperimentFetchPostResponseTest { .scores(ExperimentFetchPostResponse.Event.Scores.builder().build()) .spanAttributes( ExperimentFetchPostResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ExperimentFetchPostResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -56,27 +56,27 @@ class ExperimentFetchPostResponseTest { .build() ) ) - .cursor("string") + .cursor("cursor") .build() assertThat(experimentFetchPostResponse).isNotNull assertThat(experimentFetchPostResponse.events()) .containsExactly( ExperimentFetchPostResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ExperimentFetchPostResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) - .datasetRecordId("string") + .datasetRecordId("dataset_record_id") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(ExperimentFetchPostResponse.Event.Metadata.builder().build()) @@ -93,7 +93,7 @@ class ExperimentFetchPostResponseTest { .scores(ExperimentFetchPostResponse.Event.Scores.builder().build()) .spanAttributes( ExperimentFetchPostResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ExperimentFetchPostResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -101,6 +101,6 @@ class ExperimentFetchPostResponseTest { .tags(listOf("string")) .build() ) - assertThat(experimentFetchPostResponse.cursor()).contains("string") + assertThat(experimentFetchPostResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt index 2b34bb0..396bf20 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt @@ -16,21 +16,21 @@ class ExperimentFetchResponseTest { .events( listOf( ExperimentFetchResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ExperimentFetchResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) - .datasetRecordId("string") + .datasetRecordId("dataset_record_id") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(ExperimentFetchResponse.Event.Metadata.builder().build()) @@ -47,7 +47,7 @@ class ExperimentFetchResponseTest { .scores(ExperimentFetchResponse.Event.Scores.builder().build()) .spanAttributes( ExperimentFetchResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ExperimentFetchResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -56,27 +56,27 @@ class ExperimentFetchResponseTest { .build() ) ) - .cursor("string") + .cursor("cursor") .build() assertThat(experimentFetchResponse).isNotNull assertThat(experimentFetchResponse.events()) .containsExactly( ExperimentFetchResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ExperimentFetchResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) - .datasetRecordId("string") + .datasetRecordId("dataset_record_id") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata(ExperimentFetchResponse.Event.Metadata.builder().build()) @@ -93,7 +93,7 @@ class ExperimentFetchResponseTest { .scores(ExperimentFetchResponse.Event.Scores.builder().build()) .spanAttributes( ExperimentFetchResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ExperimentFetchResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -101,6 +101,6 @@ class ExperimentFetchResponseTest { .tags(listOf("string")) .build() ) - assertThat(experimentFetchResponse.cursor()).contains("string") + assertThat(experimentFetchResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt index 904eeb1..1d1da8c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt @@ -2,151 +2,257 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertParams.ExperimentInsertBody +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentInsertParamsTest { @Test fun createExperimentInsertParams() { - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context(ExperimentInsertParams.Event.InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentInsertParams.Event.InsertExperimentEventReplace.Metadata.builder().build()) - .metrics(ExperimentInsertParams.Event.InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes(ExperimentInsertParams.Event.InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(ExperimentInsertParams.Event.InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build()) - .tags(listOf("string")) - .build()))) - .build() + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ExperimentInsertParams.Event.ofInsertExperimentEventReplace( + ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Context + .builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Metadata + .builder() + .build() + ) + .metrics( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Metrics + .builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores + .builder() + .build() + ) + .spanAttributes( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .SpanAttributes + .builder() + .name("name") + .type( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .SpanAttributes + .Type + .LLM + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() } @Test fun getBody() { - val params = ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context(ExperimentInsertParams.Event.InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentInsertParams.Event.InsertExperimentEventReplace.Metadata.builder().build()) - .metrics(ExperimentInsertParams.Event.InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes(ExperimentInsertParams.Event.InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(ExperimentInsertParams.Event.InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build()) - .tags(listOf("string")) - .build()))) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()).isEqualTo(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context(ExperimentInsertParams.Event.InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentInsertParams.Event.InsertExperimentEventReplace.Metadata.builder().build()) - .metrics(ExperimentInsertParams.Event.InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes(ExperimentInsertParams.Event.InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(ExperimentInsertParams.Event.InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build()) - .tags(listOf("string")) - .build()))) + val params = + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ExperimentInsertParams.Event.ofInsertExperimentEventReplace( + ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .Context + .builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .Metadata + .builder() + .build() + ) + .metrics( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .Metrics + .builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores + .builder() + .build() + ) + .spanAttributes( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .SpanAttributes + .builder() + .name("name") + .type( + ExperimentInsertParams.Event + .InsertExperimentEventReplace + .SpanAttributes + .Type + .LLM + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + ExperimentInsertParams.Event.ofInsertExperimentEventReplace( + ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Context + .builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Metadata + .builder() + .build() + ) + .metrics( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Metrics + .builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentInsertParams.Event.InsertExperimentEventReplace.Scores + .builder() + .build() + ) + .spanAttributes( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .SpanAttributes + .builder() + .name("name") + .type( + ExperimentInsertParams.Event.InsertExperimentEventReplace + .SpanAttributes + .Type + .LLM + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) } @Test fun getBodyWithoutOptionalFields() { - val params = ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(ExperimentInsertParams.Event.InsertExperimentEventReplace.builder().build()))) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()).isEqualTo(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(ExperimentInsertParams.Event.InsertExperimentEventReplace.builder().build()))) + val params = + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ExperimentInsertParams.Event.ofInsertExperimentEventReplace( + ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + .build() + ) + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + ExperimentInsertParams.Event.ofInsertExperimentEventReplace( + ExperimentInsertParams.Event.InsertExperimentEventReplace.builder().build() + ) + ) + ) } @Test fun getPathParam() { - val params = ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(ExperimentInsertParams.Event.InsertExperimentEventReplace.builder().build()))) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ExperimentInsertParams.Event.ofInsertExperimentEventReplace( + ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() + .build() + ) + ) + ) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 3f4300e..266edf8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -2,62 +2,57 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentListParamsTest { @Test fun createExperimentListParams() { - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("experiment_name", listOf("experiment_name")) - expected.put("ids", listOf(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("experiment_name", listOf("experiment_name")) + expected.put( + "ids", + listOf( + ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ExperimentListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ExperimentListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentReplaceParamsTest.kt deleted file mode 100644 index 3db07fb..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentReplaceParamsTest.kt +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ExperimentReplaceParamsTest { - - @Test - fun createExperimentReplaceParams() { - ExperimentReplaceParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("string") - .description("string") - .ensureNew(true) - .metadata(ExperimentReplaceParams.Metadata.builder().build()) - .name("string") - .public_(true) - .repoInfo( - ExperimentReplaceParams.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") - .dirty(true) - .gitDiff("string") - .tag("string") - .build() - ) - .build() - } - - @Test - fun getBody() { - val params = - ExperimentReplaceParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("string") - .description("string") - .ensureNew(true) - .metadata(ExperimentReplaceParams.Metadata.builder().build()) - .name("string") - .public_(true) - .repoInfo( - ExperimentReplaceParams.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") - .dirty(true) - .gitDiff("string") - .tag("string") - .build() - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).isEqualTo("string") - assertThat(body.description()).isEqualTo("string") - assertThat(body.ensureNew()).isEqualTo(true) - assertThat(body.metadata()).isEqualTo(ExperimentReplaceParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("string") - assertThat(body.public_()).isEqualTo(true) - assertThat(body.repoInfo()) - .isEqualTo( - ExperimentReplaceParams.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") - .dirty(true) - .gitDiff("string") - .tag("string") - .build() - ) - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = - ExperimentReplaceParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt index ae100b9..5efe062 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt @@ -2,39 +2,29 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentRetrieveParamsTest { @Test fun createExperimentRetrieveParams() { - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index 748691b..d813806 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -2,63 +2,55 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentSummarizeParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentSummarizeParamsTest { @Test fun createExperimentSummarizeParams() { - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() } @Test fun getQueryParams() { - val params = ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - val expected = mutableMapOf>() - expected.put("comparison_experiment_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("summarize_scores", listOf("true")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + val expected = mutableMapOf>() + expected.put("comparison_experiment_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("summarize_scores", listOf("true")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getPathParam() { - val params = ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt index 13f83cf..cdac2a6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt @@ -11,20 +11,21 @@ class ExperimentSummarizeResponseTest { fun createExperimentSummarizeResponse() { val experimentSummarizeResponse = ExperimentSummarizeResponse.builder() - .experimentName("string") + .experimentName("experiment_name") .experimentUrl("https://example.com") - .projectName("string") + .projectName("project_name") .projectUrl("https://example.com") - .comparisonExperimentName("string") + .comparisonExperimentName("comparison_experiment_name") .metrics(ExperimentSummarizeResponse.Metrics.builder().build()) .scores(ExperimentSummarizeResponse.Scores.builder().build()) .build() assertThat(experimentSummarizeResponse).isNotNull - assertThat(experimentSummarizeResponse.experimentName()).isEqualTo("string") + assertThat(experimentSummarizeResponse.experimentName()).isEqualTo("experiment_name") assertThat(experimentSummarizeResponse.experimentUrl()).isEqualTo("https://example.com") - assertThat(experimentSummarizeResponse.projectName()).isEqualTo("string") + assertThat(experimentSummarizeResponse.projectName()).isEqualTo("project_name") assertThat(experimentSummarizeResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(experimentSummarizeResponse.comparisonExperimentName()).contains("string") + assertThat(experimentSummarizeResponse.comparisonExperimentName()) + .contains("comparison_experiment_name") assertThat(experimentSummarizeResponse.metrics()) .contains(ExperimentSummarizeResponse.Metrics.builder().build()) assertThat(experimentSummarizeResponse.scores()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt index b4233ec..af792c9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt @@ -13,58 +13,58 @@ class ExperimentTest { val experiment = Experiment.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .public_(true) .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit("string") + .commit("commit") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("string") + .datasetVersion("dataset_version") .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") + .description("description") .metadata(Experiment.Metadata.builder().build()) .repoInfo( Experiment.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") .dirty(true) - .gitDiff("string") - .tag("string") + .gitDiff("git_diff") + .tag("tag") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(experiment).isNotNull assertThat(experiment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.name()).isEqualTo("string") + assertThat(experiment.name()).isEqualTo("name") assertThat(experiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(experiment.public_()).isEqualTo(true) assertThat(experiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.commit()).contains("string") + assertThat(experiment.commit()).contains("commit") assertThat(experiment.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(experiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.datasetVersion()).contains("string") + assertThat(experiment.datasetVersion()).contains("dataset_version") assertThat(experiment.deletedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.description()).contains("string") + assertThat(experiment.description()).contains("description") assertThat(experiment.metadata()).contains(Experiment.Metadata.builder().build()) assertThat(experiment.repoInfo()) .contains( Experiment.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") .dirty(true) - .gitDiff("string") - .tag("string") + .gitDiff("git_diff") + .tag("tag") .build() ) assertThat(experiment.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index 0b2710a..2ade06a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -2,112 +2,110 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ExperimentUpdateParams -import com.braintrustdata.api.models.ExperimentUpdateParams.ExperimentUpdateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ExperimentUpdateParamsTest { @Test fun createExperimentUpdateParams() { - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder().build()) - .name("name") - .public_(true) - .repoInfo(ExperimentUpdateParams.RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder().build()) + .name("name") + .public_(true) + .repoInfo( + ExperimentUpdateParams.RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() } @Test fun getBody() { - val params = ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder().build()) - .name("name") - .public_(true) - .repoInfo(ExperimentUpdateParams.RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).isEqualTo("dataset_version") - assertThat(body.description()).isEqualTo("description") - assertThat(body.metadata()).isEqualTo(ExperimentUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") - assertThat(body.public_()).isEqualTo(true) - assertThat(body.repoInfo()).isEqualTo(ExperimentUpdateParams.RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) + val params = + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder().build()) + .name("name") + .public_(true) + .repoInfo( + ExperimentUpdateParams.RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).isEqualTo("dataset_version") + assertThat(body.description()).isEqualTo("description") + assertThat(body.metadata()).isEqualTo(ExperimentUpdateParams.Metadata.builder().build()) + assertThat(body.name()).isEqualTo("name") + assertThat(body.public_()).isEqualTo(true) + assertThat(body.repoInfo()) + .isEqualTo( + ExperimentUpdateParams.RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) } @Test fun getBodyWithoutOptionalFields() { - val params = ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt new file mode 100644 index 0000000..6672164 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt @@ -0,0 +1,341 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionCreateParamsTest { + + @Test + fun createFunctionCreateParams() { + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + FunctionCreateParams.PromptData.builder() + .options( + FunctionCreateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionCreateParams.PromptData.Options.Params.ofOpenAIModelParams( + FunctionCreateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionCreateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionCreateParams.PromptData.Prompt.ofCompletion( + FunctionCreateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionCreateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + } + + @Test + fun getBody() { + val params = + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + FunctionCreateParams.PromptData.builder() + .options( + FunctionCreateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionCreateParams.PromptData.Options.Params + .ofOpenAIModelParams( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionCreateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionCreateParams.PromptData.Prompt.ofCompletion( + FunctionCreateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionCreateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()) + .isEqualTo( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.promptData()) + .isEqualTo( + FunctionCreateParams.PromptData.builder() + .options( + FunctionCreateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionCreateParams.PromptData.Options.Params.ofOpenAIModelParams( + FunctionCreateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionCreateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionCreateParams.PromptData.Prompt.ofCompletion( + FunctionCreateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionCreateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + assertThat(body.tags()).isEqualTo(listOf("string")) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()) + .isEqualTo( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt new file mode 100644 index 0000000..b6a1f5f --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionDeleteParamsTest { + + @Test + fun createFunctionDeleteParams() { + FunctionDeleteParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun getPathParam() { + val params = + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt new file mode 100644 index 0000000..d34d684 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionListParamsTest { + + @Test + fun createFunctionListParams() { + FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + } + + @Test + fun getQueryParams() { + val params = + FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("function_name", listOf("function_name")) + expected.put( + "ids", + listOf( + FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("slug", listOf("slug")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = FunctionListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt new file mode 100644 index 0000000..92d010d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt @@ -0,0 +1,343 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionReplaceParamsTest { + + @Test + fun createFunctionReplaceParams() { + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + FunctionReplaceParams.PromptData.builder() + .options( + FunctionReplaceParams.PromptData.Options.builder() + .model("model") + .params( + FunctionReplaceParams.PromptData.Options.Params.ofOpenAIModelParams( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionReplaceParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionReplaceParams.PromptData.Prompt.ofCompletion( + FunctionReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionReplaceParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + } + + @Test + fun getBody() { + val params = + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + FunctionReplaceParams.PromptData.builder() + .options( + FunctionReplaceParams.PromptData.Options.builder() + .model("model") + .params( + FunctionReplaceParams.PromptData.Options.Params + .ofOpenAIModelParams( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionReplaceParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionReplaceParams.PromptData.Prompt.ofCompletion( + FunctionReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionReplaceParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()) + .isEqualTo( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.promptData()) + .isEqualTo( + FunctionReplaceParams.PromptData.builder() + .options( + FunctionReplaceParams.PromptData.Options.builder() + .model("model") + .params( + FunctionReplaceParams.PromptData.Options.Params.ofOpenAIModelParams( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionReplaceParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionReplaceParams.PromptData.Prompt.ofCompletion( + FunctionReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionReplaceParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + assertThat(body.tags()).isEqualTo(listOf("string")) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()) + .isEqualTo( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt new file mode 100644 index 0000000..e67f96c --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionRetrieveParamsTest { + + @Test + fun createFunctionRetrieveParams() { + FunctionRetrieveParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun getPathParam() { + val params = + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt new file mode 100644 index 0000000..860deb9 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionTest { + + @Test + fun createFunction() { + val function = + Function.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .functionData( + Function.FunctionData.ofPrompt( + Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .logId(Function.LogId.P) + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .metadata(Function.Metadata.builder().build()) + .promptData( + Function.PromptData.builder() + .options( + Function.PromptData.Options.builder() + .model("model") + .params( + Function.PromptData.Options.Params.ofOpenAIModelParams( + Function.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + Function.PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .ofAuto( + Function.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + Function.PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + Function.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + Function.PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + Function.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + Function.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + Function.PromptData.Prompt.ofCompletion( + Function.PromptData.Prompt.Completion.builder() + .content("content") + .type(Function.PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + assertThat(function).isNotNull + assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function._xactId()).isEqualTo("_xact_id") + assertThat(function.functionData()) + .isEqualTo( + Function.FunctionData.ofPrompt( + Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(function.logId()).isEqualTo(Function.LogId.P) + assertThat(function.name()).isEqualTo("name") + assertThat(function.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.slug()).isEqualTo("slug") + assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(function.description()).contains("description") + assertThat(function.metadata()).contains(Function.Metadata.builder().build()) + assertThat(function.promptData()) + .contains( + Function.PromptData.builder() + .options( + Function.PromptData.Options.builder() + .model("model") + .params( + Function.PromptData.Options.Params.ofOpenAIModelParams( + Function.PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + Function.PromptData.Options.Params.OpenAIModelParams + .FunctionCall + .ofAuto( + Function.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + Function.PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .builder() + .type( + Function.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + Function.PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + Function.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + Function.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + Function.PromptData.Prompt.ofCompletion( + Function.PromptData.Prompt.Completion.builder() + .content("content") + .type(Function.PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + .build() + ) + assertThat(function.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt new file mode 100644 index 0000000..79b01a8 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -0,0 +1,330 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FunctionUpdateParamsTest { + + @Test + fun createFunctionUpdateParams() { + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.ofPrompt( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .promptData( + FunctionUpdateParams.PromptData.builder() + .options( + FunctionUpdateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionUpdateParams.PromptData.Options.Params.ofOpenAIModelParams( + FunctionUpdateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionUpdateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionUpdateParams.PromptData.Prompt.ofCompletion( + FunctionUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionUpdateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + } + + @Test + fun getBody() { + val params = + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.ofPrompt( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .promptData( + FunctionUpdateParams.PromptData.builder() + .options( + FunctionUpdateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionUpdateParams.PromptData.Options.Params + .ofOpenAIModelParams( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionUpdateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionUpdateParams.PromptData.Prompt.ofCompletion( + FunctionUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionUpdateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.description()).isEqualTo("description") + assertThat(body.functionData()) + .isEqualTo( + FunctionUpdateParams.FunctionData.ofPrompt( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptData()) + .isEqualTo( + FunctionUpdateParams.PromptData.builder() + .options( + FunctionUpdateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionUpdateParams.PromptData.Options.Params.ofOpenAIModelParams( + FunctionUpdateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionUpdateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionUpdateParams.PromptData.Prompt.ofCompletion( + FunctionUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionUpdateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + assertThat(body.tags()).isEqualTo(listOf("string")) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index 501aab9..b7b98eb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -2,60 +2,47 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.GroupCreateParams -import com.braintrustdata.api.models.GroupCreateParams.GroupCreateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class GroupCreateParamsTest { @Test fun createGroupCreateParams() { - GroupCreateParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + GroupCreateParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = GroupCreateParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = + GroupCreateParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = GroupCreateParams.builder() - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = GroupCreateParams.builder().name("name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt index 1d72eeb..dd8a03f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.GroupDeleteParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class GroupDeleteParamsTest { @Test fun createGroupDeleteParams() { - GroupDeleteParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = GroupDeleteParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index aad7f0d..33587c1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -2,59 +2,52 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.GroupListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class GroupListParamsTest { @Test fun createGroupListParams() { - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("group_name", listOf("group_name")) - expected.put("ids", listOf(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("group_name", listOf("group_name")) + expected.put( + "ids", + listOf(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = GroupListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = GroupListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index e11a015..4bc2570 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -2,60 +2,47 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.GroupReplaceParams -import com.braintrustdata.api.models.GroupReplaceParams.GroupReplaceBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class GroupReplaceParamsTest { @Test fun createGroupReplaceParams() { - GroupReplaceParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + GroupReplaceParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = GroupReplaceParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = + GroupReplaceParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = GroupReplaceParams.builder() - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = GroupReplaceParams.builder().name("name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt index c4ea0a1..40cb190 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.GroupRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class GroupRetrieveParamsTest { @Test fun createGroupRetrieveParams() { - GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt index f878e53..4b8a9f6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt @@ -13,22 +13,22 @@ class GroupTest { val group = Group.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") + .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(group).isNotNull assertThat(group.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.name()).isEqualTo("string") + assertThat(group.name()).isEqualTo("name") assertThat(group.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(group.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(group.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.description()).contains("string") + assertThat(group.description()).contains("description") assertThat(group.memberGroups().get()) .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(group.memberUsers().get()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index 217d940..f84d719 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -2,76 +2,65 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.GroupUpdateParams -import com.braintrustdata.api.models.GroupUpdateParams.GroupUpdateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class GroupUpdateParamsTest { @Test fun createGroupUpdateParams() { - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() } @Test fun getBody() { - val params = GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.addMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.addMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.removeMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.removeMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val params = + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.addMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.addMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.removeMemberGroups()) + .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.removeMemberUsers()) + .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun getBodyWithoutOptionalFields() { - val params = GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt new file mode 100644 index 0000000..1c6fe6a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class OrganizationDeleteParamsTest { + + @Test + fun createOrganizationDeleteParams() { + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt new file mode 100644 index 0000000..c0ddb5b --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class OrganizationListParamsTest { + + @Test + fun createOrganizationListParams() { + OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .organizationName("organization_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getQueryParams() { + val params = + OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .organizationName("organization_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf( + OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .toString() + ) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("organization_name", listOf("organization_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = OrganizationListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt new file mode 100644 index 0000000..d8a9fd4 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class OrganizationMemberUpdateParamsTest { + + @Test + fun createOrganizationMemberUpdateParams() { + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + .build() + } + + @Test + fun getBody() { + val params = + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.inviteUsers()) + .isEqualTo( + OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build() + ) + assertThat(body.orgId()).isEqualTo("org_id") + assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.removeUsers()) + .isEqualTo( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = OrganizationMemberUpdateParams.builder().build() + val body = params.getBody() + assertThat(body).isNotNull + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt new file mode 100644 index 0000000..8d58b82 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class OrganizationMemberUpdateResponseTest { + + @Test + fun createOrganizationMemberUpdateResponse() { + val organizationMemberUpdateResponse = + OrganizationMemberUpdateResponse.builder() + .status(OrganizationMemberUpdateResponse.Status.SUCCESS) + .sendEmailError("send_email_error") + .build() + assertThat(organizationMemberUpdateResponse).isNotNull + assertThat(organizationMemberUpdateResponse.status()) + .isEqualTo(OrganizationMemberUpdateResponse.Status.SUCCESS) + assertThat(organizationMemberUpdateResponse.sendEmailError()).contains("send_email_error") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt new file mode 100644 index 0000000..4ccbda0 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class OrganizationRetrieveParamsTest { + + @Test + fun createOrganizationRetrieveParams() { + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt new file mode 100644 index 0000000..d458dc1 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class OrganizationTest { + + @Test + fun createOrganization() { + val organization = + Organization.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .apiUrl("api_url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isUniversalApi(true) + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + assertThat(organization).isNotNull + assertThat(organization.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organization.name()).isEqualTo("name") + assertThat(organization.apiUrl()).contains("api_url") + assertThat(organization.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(organization.isUniversalApi()).contains(true) + assertThat(organization.proxyUrl()).contains("proxy_url") + assertThat(organization.realtimeUrl()).contains("realtime_url") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt new file mode 100644 index 0000000..cc38ee3 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class OrganizationUpdateParamsTest { + + @Test + fun createOrganizationUpdateParams() { + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + } + + @Test + fun getBody() { + val params = + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.apiUrl()).isEqualTo("api_url") + assertThat(body.isUniversalApi()).isEqualTo(true) + assertThat(body.name()).isEqualTo("name") + assertThat(body.proxyUrl()).isEqualTo("proxy_url") + assertThat(body.realtimeUrl()).isEqualTo("realtime_url") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 4181ba3..10928d7 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -2,51 +2,31 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectCreateParams -import com.braintrustdata.api.models.ProjectCreateParams.ProjectCreateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectCreateParamsTest { @Test fun createProjectCreateParams() { - ProjectCreateParams.builder() - .name("name") - .orgName("org_name") - .build() + ProjectCreateParams.builder().name("name").orgName("org_name").build() } @Test fun getBody() { - val params = ProjectCreateParams.builder() - .name("name") - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).isEqualTo("org_name") + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = ProjectCreateParams.builder() - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = ProjectCreateParams.builder().name("name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt index 6011973..caa2ac8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectDeleteParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectDeleteParamsTest { @Test fun createProjectDeleteParams() { - ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index fbc80cc..233ceaa 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -2,59 +2,54 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectListParamsTest { @Test fun createProjectListParams() { - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("ids", listOf(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf( + ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ProjectListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index 52b4bac..038fe4a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -2,91 +2,91 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFeedbackParams.ProjectLogFeedbackBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectLogFeedbackParamsTest { @Test fun createProjectLogFeedbackParams() { - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) - .source(ProjectLogFeedbackParams.Feedback.Source.APP) - .build())) - .build() + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback( + listOf( + ProjectLogFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) + .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) + .source(ProjectLogFeedbackParams.Feedback.Source.APP) + .build() + ) + ) + .build() } @Test fun getBody() { - val params = ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) - .source(ProjectLogFeedbackParams.Feedback.Source.APP) - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(ProjectLogFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) - .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) - .source(ProjectLogFeedbackParams.Feedback.Source.APP) - .build())) + val params = + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback( + listOf( + ProjectLogFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) + .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) + .source(ProjectLogFeedbackParams.Feedback.Source.APP) + .build() + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()) + .isEqualTo( + listOf( + ProjectLogFeedbackParams.Feedback.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) + .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) + .source(ProjectLogFeedbackParams.Feedback.Source.APP) + .build() + ) + ) } @Test fun getBodyWithoutOptionalFields() { - val params = ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(ProjectLogFeedbackParams.Feedback.builder() - .id("id") - .build())) + val params = + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder().id("id").build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()) + .isEqualTo(listOf(ProjectLogFeedbackParams.Feedback.builder().id("id").build())) } @Test fun getPathParam() { - val params = ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(ProjectLogFeedbackParams.Feedback.builder().id("id").build())) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index 02d7615..c84026c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -2,69 +2,61 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectLogFetchParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectLogFetchParamsTest { @Test fun createProjectLogFetchParams() { - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getQueryParams() { - val params = ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("limit", listOf("123")) + expected.put("max_root_span_id", listOf("max_root_span_id")) + expected.put("max_xact_id", listOf("max_xact_id")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getPathParam() { - val params = ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 2ad54a5..fbd4551 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -2,88 +2,93 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams.ProjectLogFetchPostBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectLogFetchPostParamsTest { @Test fun createProjectLogFetchPostParams() { - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters(listOf(ProjectLogFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters( + listOf( + ProjectLogFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getBody() { - val params = ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters(listOf(ProjectLogFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()).isEqualTo(listOf(ProjectLogFetchPostParams.Filter.builder() - .path(listOf("string")) - .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build())) - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + val params = + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters( + listOf( + ProjectLogFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()) + .isEqualTo( + listOf( + ProjectLogFetchPostParams.Filter.builder() + .path(listOf("string")) + .type(ProjectLogFetchPostParams.Filter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + ) + ) + assertThat(body.limit()).isEqualTo(123L) + assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") + assertThat(body.maxXactId()).isEqualTo("max_xact_id") + assertThat(body.version()).isEqualTo("version") } @Test fun getBodyWithoutOptionalFields() { - val params = ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt index 677d092..1fd24cf 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt @@ -16,18 +16,18 @@ class ProjectLogFetchPostResponseTest { .events( listOf( ProjectLogFetchPostResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .logId(ProjectLogFetchPostResponse.Event.LogId.G) .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ProjectLogFetchPostResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) @@ -47,7 +47,7 @@ class ProjectLogFetchPostResponseTest { .scores(ProjectLogFetchPostResponse.Event.Scores.builder().build()) .spanAttributes( ProjectLogFetchPostResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ProjectLogFetchPostResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -56,24 +56,24 @@ class ProjectLogFetchPostResponseTest { .build() ) ) - .cursor("string") + .cursor("cursor") .build() assertThat(projectLogFetchPostResponse).isNotNull assertThat(projectLogFetchPostResponse.events()) .containsExactly( ProjectLogFetchPostResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .logId(ProjectLogFetchPostResponse.Event.LogId.G) .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ProjectLogFetchPostResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) @@ -93,7 +93,7 @@ class ProjectLogFetchPostResponseTest { .scores(ProjectLogFetchPostResponse.Event.Scores.builder().build()) .spanAttributes( ProjectLogFetchPostResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ProjectLogFetchPostResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -101,6 +101,6 @@ class ProjectLogFetchPostResponseTest { .tags(listOf("string")) .build() ) - assertThat(projectLogFetchPostResponse.cursor()).contains("string") + assertThat(projectLogFetchPostResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt index bc59d46..52c4bd2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt @@ -16,18 +16,18 @@ class ProjectLogFetchResponseTest { .events( listOf( ProjectLogFetchResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .logId(ProjectLogFetchResponse.Event.LogId.G) .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ProjectLogFetchResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) @@ -47,7 +47,7 @@ class ProjectLogFetchResponseTest { .scores(ProjectLogFetchResponse.Event.Scores.builder().build()) .spanAttributes( ProjectLogFetchResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ProjectLogFetchResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -56,24 +56,24 @@ class ProjectLogFetchResponseTest { .build() ) ) - .cursor("string") + .cursor("cursor") .build() assertThat(projectLogFetchResponse).isNotNull assertThat(projectLogFetchResponse.events()) .containsExactly( ProjectLogFetchResponse.Event.builder() - .id("string") - ._xactId("string") + .id("id") + ._xactId("_xact_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .logId(ProjectLogFetchResponse.Event.LogId.G) .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("string") - .spanId("string") + .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .context( ProjectLogFetchResponse.Event.Context.builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) @@ -93,7 +93,7 @@ class ProjectLogFetchResponseTest { .scores(ProjectLogFetchResponse.Event.Scores.builder().build()) .spanAttributes( ProjectLogFetchResponse.Event.SpanAttributes.builder() - .name("string") + .name("name") .type(ProjectLogFetchResponse.Event.SpanAttributes.Type.LLM) .build() ) @@ -101,6 +101,6 @@ class ProjectLogFetchResponseTest { .tags(listOf("string")) .build() ) - assertThat(projectLogFetchResponse.cursor()).contains("string") + assertThat(projectLogFetchResponse.cursor()).contains("cursor") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt index 283335a..e5d7104 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt @@ -2,148 +2,255 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertParams.ProjectLogInsertBody +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectLogInsertParamsTest { @Test fun createProjectLogInsertParams() { - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build()) - .tags(listOf("string")) - .build()))) - .build() + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Context + .builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metadata + .builder() + .build() + ) + .metrics( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metrics + .builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Scores + .builder() + .build() + ) + .spanAttributes( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .SpanAttributes + .builder() + .name("name") + .type( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .SpanAttributes + .Type + .LLM + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() } @Test fun getBody() { - val params = ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build()) - .tags(listOf("string")) - .build()))) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()).isEqualTo(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build()) - .tags(listOf("string")) - .build()))) + val params = + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .Context + .builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .Metadata + .builder() + .build() + ) + .metrics( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .Metrics + .builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .Scores + .builder() + .build() + ) + .spanAttributes( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .SpanAttributes + .builder() + .name("name") + .type( + ProjectLogInsertParams.Event + .InsertProjectLogsEventReplace + .SpanAttributes + .Type + .LLM + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Context + .builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metadata + .builder() + .build() + ) + .metrics( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Metrics + .builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.Scores + .builder() + .build() + ) + .spanAttributes( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .SpanAttributes + .builder() + .name("name") + .type( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace + .SpanAttributes + .Type + .LLM + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + ) + ) } @Test fun getBodyWithoutOptionalFields() { - val params = ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder().build()))) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()).isEqualTo(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder().build()))) + val params = + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + .build() + ) + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder().build() + ) + ) + ) } @Test fun getPathParam() { - val params = ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder().build()))) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events( + listOf( + ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( + ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() + .build() + ) + ) + ) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectReplaceParamsTest.kt deleted file mode 100644 index c74489a..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectReplaceParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectReplaceParamsTest { - - @Test - fun createProjectReplaceParams() { - ProjectReplaceParams.builder().name("string").orgName("string").build() - } - - @Test - fun getBody() { - val params = ProjectReplaceParams.builder().name("string").orgName("string").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("string") - assertThat(body.orgName()).isEqualTo("string") - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = ProjectReplaceParams.builder().name("string").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt index 26b20bb..231a186 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt @@ -2,39 +2,27 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectRetrieveParamsTest { @Test fun createProjectRetrieveParams() { - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectRetrieveParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt new file mode 100644 index 0000000..655684c --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectScoreCreateParamsTest { + + @Test + fun createProjectScoreCreateParams() { + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categories( + ProjectScoreCreateParams.Categories.ofList( + listOf( + ProjectScoreCreateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .build() + } + + @Test + fun getBody() { + val params = + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categories( + ProjectScoreCreateParams.Categories.ofList( + listOf( + ProjectScoreCreateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertThat(body.categories()) + .isEqualTo( + ProjectScoreCreateParams.Categories.ofList( + listOf( + ProjectScoreCreateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + assertThat(body.description()).isEqualTo("description") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt new file mode 100644 index 0000000..896f79a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectScoreDeleteParamsTest { + + @Test + fun createProjectScoreDeleteParams() { + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt new file mode 100644 index 0000000..b01ca07 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectScoreListParamsTest { + + @Test + fun createProjectScoreListParams() { + ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .projectScoreName("project_score_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getQueryParams() { + val params = + ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .projectScoreName("project_score_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf( + ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .toString() + ) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("project_score_name", listOf("project_score_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = ProjectScoreListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt new file mode 100644 index 0000000..ec36925 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectScoreReplaceParamsTest { + + @Test + fun createProjectScoreReplaceParams() { + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categories( + ProjectScoreReplaceParams.Categories.ofList( + listOf( + ProjectScoreReplaceParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .build() + } + + @Test + fun getBody() { + val params = + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categories( + ProjectScoreReplaceParams.Categories.ofList( + listOf( + ProjectScoreReplaceParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertThat(body.categories()) + .isEqualTo( + ProjectScoreReplaceParams.Categories.ofList( + listOf( + ProjectScoreReplaceParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + assertThat(body.description()).isEqualTo("description") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt new file mode 100644 index 0000000..9237a10 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectScoreRetrieveParamsTest { + + @Test + fun createProjectScoreRetrieveParams() { + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt new file mode 100644 index 0000000..4d7d106 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectScoreTest { + + @Test + fun createProjectScore() { + val projectScore = + ProjectScore.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScore.ScoreType.SLIDER) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categories( + ProjectScore.Categories.ofList( + listOf( + ProjectScore.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .config( + ProjectScore.Config.builder() + .destination(ProjectScore.Config.Destination.EXPECTED) + .multiSelect(true) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .position("position") + .build() + assertThat(projectScore).isNotNull + assertThat(projectScore.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.name()).isEqualTo("name") + assertThat(projectScore.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.scoreType()).contains(ProjectScore.ScoreType.SLIDER) + assertThat(projectScore.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.categories()) + .contains( + ProjectScore.Categories.ofList( + listOf( + ProjectScore.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + assertThat(projectScore.config()) + .contains( + ProjectScore.Config.builder() + .destination(ProjectScore.Config.Destination.EXPECTED) + .multiSelect(true) + .build() + ) + assertThat(projectScore.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectScore.description()).contains("description") + assertThat(projectScore.position()).contains("position") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt new file mode 100644 index 0000000..3f05a7d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectScoreUpdateParamsTest { + + @Test + fun createProjectScoreUpdateParams() { + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categories( + ProjectScoreUpdateParams.Categories.ofList( + listOf( + ProjectScoreUpdateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() + } + + @Test + fun getBody() { + val params = + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categories( + ProjectScoreUpdateParams.Categories.ofList( + listOf( + ProjectScoreUpdateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.categories()) + .isEqualTo( + ProjectScoreUpdateParams.Categories.ofList( + listOf( + ProjectScoreUpdateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.scoreType()).isEqualTo(ProjectScoreUpdateParams.ScoreType.SLIDER) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt new file mode 100644 index 0000000..111ab84 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectTagCreateParamsTest { + + @Test + fun createProjectTagCreateParams() { + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + } + + @Test + fun getBody() { + val params = + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).isEqualTo("color") + assertThat(body.description()).isEqualTo("description") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt new file mode 100644 index 0000000..12369e0 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectTagDeleteParamsTest { + + @Test + fun createProjectTagDeleteParams() { + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt new file mode 100644 index 0000000..672c32d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectTagListParamsTest { + + @Test + fun createProjectTagListParams() { + ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getQueryParams() { + val params = + ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf( + ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("project_tag_name", listOf("project_tag_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = ProjectTagListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt new file mode 100644 index 0000000..bec95fa --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectTagReplaceParamsTest { + + @Test + fun createProjectTagReplaceParams() { + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + } + + @Test + fun getBody() { + val params = + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).isEqualTo("color") + assertThat(body.description()).isEqualTo("description") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt new file mode 100644 index 0000000..cd79259 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectTagRetrieveParamsTest { + + @Test + fun createProjectTagRetrieveParams() { + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt new file mode 100644 index 0000000..d9a8375 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectTagTest { + + @Test + fun createProjectTag() { + val projectTag = + ProjectTag.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .build() + assertThat(projectTag).isNotNull + assertThat(projectTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.name()).isEqualTo("name") + assertThat(projectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.color()).contains("color") + assertThat(projectTag.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectTag.description()).contains("description") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt new file mode 100644 index 0000000..9b5ac6a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectTagUpdateParamsTest { + + @Test + fun createProjectTagUpdateParams() { + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + } + + @Test + fun getBody() { + val params = + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.color()).isEqualTo("color") + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 9288581..08b9f5f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -13,18 +13,21 @@ class ProjectTest { val project = Project.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(Project.Settings.builder().comparisonKey("comparison_key").build()) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(project).isNotNull assertThat(project.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(project.name()).isEqualTo("string") + assertThat(project.name()).isEqualTo("name") assertThat(project.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.settings()) + .contains(Project.Settings.builder().comparisonKey("comparison_key").build()) assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 0e2baf3..a224eab 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -2,70 +2,58 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.models.ProjectUpdateParams.ProjectUpdateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class ProjectUpdateParamsTest { @Test fun createProjectUpdateParams() { - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectUpdateParams.Settings.builder() - .comparisonKey("comparison_key") - .build()) - .build() + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings( + ProjectUpdateParams.Settings.builder().comparisonKey("comparison_key").build() + ) + .build() } @Test fun getBody() { - val params = ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectUpdateParams.Settings.builder() - .comparisonKey("comparison_key") - .build()) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.settings()).isEqualTo(ProjectUpdateParams.Settings.builder() - .comparisonKey("comparison_key") - .build()) + val params = + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings( + ProjectUpdateParams.Settings.builder().comparisonKey("comparison_key").build() + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.settings()) + .isEqualTo( + ProjectUpdateParams.Settings.builder().comparisonKey("comparison_key").build() + ) } @Test fun getBodyWithoutOptionalFields() { - val params = ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 34f9dea..c4e100b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -2,154 +2,301 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.PromptCreateParams -import com.braintrustdata.api.models.PromptCreateParams.PromptCreateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class PromptCreateParamsTest { @Test fun createPromptCreateParams() { - PromptCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .promptData(PromptCreateParams.PromptData.builder() - .options(PromptCreateParams.PromptData.Options.builder() - .model("model") - .params(PromptCreateParams.PromptData.Options.Params.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptCreateParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptCreateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptCreateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptCreateParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptCreateParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptCreateParams.PromptData.Prompt.ofUnionMember0(PromptCreateParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptCreateParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - .tags(listOf("string")) - .build() + PromptCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + PromptCreateParams.PromptData.builder() + .options( + PromptCreateParams.PromptData.Options.builder() + .model("model") + .params( + PromptCreateParams.PromptData.Options.Params.ofOpenAIModelParams( + PromptCreateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptCreateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptCreateParams.PromptData.Prompt.ofCompletion( + PromptCreateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptCreateParams.PromptData.Prompt.Completion.Type.COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = PromptCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .promptData(PromptCreateParams.PromptData.builder() - .options(PromptCreateParams.PromptData.Options.builder() - .model("model") - .params(PromptCreateParams.PromptData.Options.Params.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptCreateParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptCreateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptCreateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptCreateParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptCreateParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptCreateParams.PromptData.Prompt.ofUnionMember0(PromptCreateParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptCreateParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.description()).isEqualTo("description") - assertThat(body.promptData()).isEqualTo(PromptCreateParams.PromptData.builder() - .options(PromptCreateParams.PromptData.Options.builder() - .model("model") - .params(PromptCreateParams.PromptData.Options.Params.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptCreateParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptCreateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptCreateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptCreateParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptCreateParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptCreateParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptCreateParams.PromptData.Prompt.ofUnionMember0(PromptCreateParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptCreateParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = + PromptCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + PromptCreateParams.PromptData.builder() + .options( + PromptCreateParams.PromptData.Options.builder() + .model("model") + .params( + PromptCreateParams.PromptData.Options.Params + .ofOpenAIModelParams( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptCreateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptCreateParams.PromptData.Prompt.ofCompletion( + PromptCreateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptCreateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.promptData()) + .isEqualTo( + PromptCreateParams.PromptData.builder() + .options( + PromptCreateParams.PromptData.Options.builder() + .model("model") + .params( + PromptCreateParams.PromptData.Options.Params.ofOpenAIModelParams( + PromptCreateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptCreateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptCreateParams.PromptData.Prompt.ofCompletion( + PromptCreateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptCreateParams.PromptData.Prompt.Completion.Type.COMPLETION + ) + .build() + ) + ) + .build() + ) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = PromptCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + val params = + PromptCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt index 8623039..a819f9d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.PromptDeleteParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class PromptDeleteParamsTest { @Test fun createPromptDeleteParams() { - PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptFeedbackParamsTest.kt deleted file mode 100644 index 3985ceb..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptFeedbackParamsTest.kt +++ /dev/null @@ -1,86 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.PromptFeedbackParams -import com.braintrustdata.api.models.PromptFeedbackParams.PromptFeedbackBody - -class PromptFeedbackParamsTest { - - @Test - fun createPromptFeedbackParams() { - PromptFeedbackParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(PromptFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .metadata(PromptFeedbackParams.Feedback.Metadata.builder().build()) - .source(PromptFeedbackParams.Feedback.Source.APP) - .build())) - .build() - } - - @Test - fun getBody() { - val params = PromptFeedbackParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(PromptFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .metadata(PromptFeedbackParams.Feedback.Metadata.builder().build()) - .source(PromptFeedbackParams.Feedback.Source.APP) - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(PromptFeedbackParams.Feedback.builder() - .id("id") - .comment("comment") - .metadata(PromptFeedbackParams.Feedback.Metadata.builder().build()) - .source(PromptFeedbackParams.Feedback.Source.APP) - .build())) - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = PromptFeedbackParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(PromptFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()).isEqualTo(listOf(PromptFeedbackParams.Feedback.builder() - .id("id") - .build())) - } - - @Test - fun getPathParam() { - val params = PromptFeedbackParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(PromptFeedbackParams.Feedback.builder() - .id("id") - .build())) - .build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index 0c68ea3..ddede59 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -2,68 +2,61 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.PromptListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class PromptListParamsTest { @Test fun createPromptListParams() { - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() + PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() } @Test fun getQueryParams() { - val params = PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("ids", listOf(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_name", listOf("project_name")) - expected.put("prompt_name", listOf("prompt_name")) - expected.put("slug", listOf("slug")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("prompt_name", listOf("prompt_name")) + expected.put("slug", listOf("slug")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = PromptListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = PromptListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 5ca72e3..0f30c19 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -2,154 +2,301 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.PromptReplaceParams -import com.braintrustdata.api.models.PromptReplaceParams.PromptReplaceBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class PromptReplaceParamsTest { @Test fun createPromptReplaceParams() { - PromptReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .promptData(PromptReplaceParams.PromptData.builder() - .options(PromptReplaceParams.PromptData.Options.builder() - .model("model") - .params(PromptReplaceParams.PromptData.Options.Params.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptReplaceParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptReplaceParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptReplaceParams.PromptData.Prompt.ofUnionMember0(PromptReplaceParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptReplaceParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - .tags(listOf("string")) - .build() + PromptReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + PromptReplaceParams.PromptData.builder() + .options( + PromptReplaceParams.PromptData.Options.builder() + .model("model") + .params( + PromptReplaceParams.PromptData.Options.Params.ofOpenAIModelParams( + PromptReplaceParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptReplaceParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptReplaceParams.PromptData.Prompt.ofCompletion( + PromptReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptReplaceParams.PromptData.Prompt.Completion.Type.COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = PromptReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .promptData(PromptReplaceParams.PromptData.builder() - .options(PromptReplaceParams.PromptData.Options.builder() - .model("model") - .params(PromptReplaceParams.PromptData.Options.Params.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptReplaceParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptReplaceParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptReplaceParams.PromptData.Prompt.ofUnionMember0(PromptReplaceParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptReplaceParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.description()).isEqualTo("description") - assertThat(body.promptData()).isEqualTo(PromptReplaceParams.PromptData.builder() - .options(PromptReplaceParams.PromptData.Options.builder() - .model("model") - .params(PromptReplaceParams.PromptData.Options.Params.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptReplaceParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptReplaceParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptReplaceParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptReplaceParams.PromptData.Prompt.ofUnionMember0(PromptReplaceParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptReplaceParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = + PromptReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + PromptReplaceParams.PromptData.builder() + .options( + PromptReplaceParams.PromptData.Options.builder() + .model("model") + .params( + PromptReplaceParams.PromptData.Options.Params + .ofOpenAIModelParams( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptReplaceParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptReplaceParams.PromptData.Prompt.ofCompletion( + PromptReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptReplaceParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.promptData()) + .isEqualTo( + PromptReplaceParams.PromptData.builder() + .options( + PromptReplaceParams.PromptData.Options.builder() + .model("model") + .params( + PromptReplaceParams.PromptData.Options.Params.ofOpenAIModelParams( + PromptReplaceParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptReplaceParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptReplaceParams.PromptData.Prompt.ofCompletion( + PromptReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptReplaceParams.PromptData.Prompt.Completion.Type.COMPLETION + ) + .build() + ) + ) + .build() + ) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = PromptReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + val params = + PromptReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt index 34040a7..d8aa509 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.PromptRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class PromptRetrieveParamsTest { @Test fun createPromptRetrieveParams() { - PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index 6345008..b546d77 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -13,32 +13,32 @@ class PromptTest { val prompt = Prompt.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("string") + ._xactId("_xact_id") .logId(Prompt.LogId.P) - .name("string") + .name("name") .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") + .slug("slug") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") + .description("description") .metadata(Prompt.Metadata.builder().build()) .promptData( Prompt.PromptData.builder() .options( Prompt.PromptData.Options.builder() - .model("string") + .model("model") .params( - Prompt.PromptData.Options.Params.ofUnionMember0( - Prompt.PromptData.Options.Params.UnionMember0.builder() + Prompt.PromptData.Options.Params.ofOpenAIModelParams( + Prompt.PromptData.Options.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - Prompt.PromptData.Options.Params.UnionMember0 + Prompt.PromptData.Options.Params.OpenAIModelParams .FunctionCall - .ofUnionMember0( + .ofAuto( Prompt.PromptData.Options.Params - .UnionMember0 + .OpenAIModelParams .FunctionCall - .UnionMember0 + .Auto .AUTO ) ) @@ -46,12 +46,12 @@ class PromptTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - Prompt.PromptData.Options.Params.UnionMember0 + Prompt.PromptData.Options.Params.OpenAIModelParams .ResponseFormat .builder() .type( Prompt.PromptData.Options.Params - .UnionMember0 + .OpenAIModelParams .ResponseFormat .Type .JSON_OBJECT @@ -61,13 +61,13 @@ class PromptTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - Prompt.PromptData.Options.Params.UnionMember0 + Prompt.PromptData.Options.Params.OpenAIModelParams .ToolChoice - .ofUnionMember0( + .ofAuto( Prompt.PromptData.Options.Params - .UnionMember0 + .OpenAIModelParams .ToolChoice - .UnionMember0 + .Auto .AUTO ) ) @@ -76,21 +76,21 @@ class PromptTest { .build() ) ) - .position("string") + .position("position") .build() ) .origin( Prompt.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") .build() ) .prompt( - Prompt.PromptData.Prompt.ofUnionMember0( - Prompt.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type(Prompt.PromptData.Prompt.UnionMember0.Type.COMPLETION) + Prompt.PromptData.Prompt.ofCompletion( + Prompt.PromptData.Prompt.Completion.builder() + .content("content") + .type(Prompt.PromptData.Prompt.Completion.Type.COMPLETION) .build() ) ) @@ -100,32 +100,33 @@ class PromptTest { .build() assertThat(prompt).isNotNull assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt._xactId()).isEqualTo("string") + assertThat(prompt._xactId()).isEqualTo("_xact_id") assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) - assertThat(prompt.name()).isEqualTo("string") + assertThat(prompt.name()).isEqualTo("name") assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt.slug()).isEqualTo("string") + assertThat(prompt.slug()).isEqualTo("slug") assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(prompt.description()).contains("string") + assertThat(prompt.description()).contains("description") assertThat(prompt.metadata()).contains(Prompt.Metadata.builder().build()) assertThat(prompt.promptData()) .contains( Prompt.PromptData.builder() .options( Prompt.PromptData.Options.builder() - .model("string") + .model("model") .params( - Prompt.PromptData.Options.Params.ofUnionMember0( - Prompt.PromptData.Options.Params.UnionMember0.builder() + Prompt.PromptData.Options.Params.ofOpenAIModelParams( + Prompt.PromptData.Options.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - Prompt.PromptData.Options.Params.UnionMember0 + Prompt.PromptData.Options.Params.OpenAIModelParams .FunctionCall - .ofUnionMember0( - Prompt.PromptData.Options.Params.UnionMember0 + .ofAuto( + Prompt.PromptData.Options.Params + .OpenAIModelParams .FunctionCall - .UnionMember0 + .Auto .AUTO ) ) @@ -133,11 +134,12 @@ class PromptTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - Prompt.PromptData.Options.Params.UnionMember0 + Prompt.PromptData.Options.Params.OpenAIModelParams .ResponseFormat .builder() .type( - Prompt.PromptData.Options.Params.UnionMember0 + Prompt.PromptData.Options.Params + .OpenAIModelParams .ResponseFormat .Type .JSON_OBJECT @@ -147,11 +149,13 @@ class PromptTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - Prompt.PromptData.Options.Params.UnionMember0.ToolChoice - .ofUnionMember0( - Prompt.PromptData.Options.Params.UnionMember0 + Prompt.PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + Prompt.PromptData.Options.Params + .OpenAIModelParams .ToolChoice - .UnionMember0 + .Auto .AUTO ) ) @@ -160,21 +164,21 @@ class PromptTest { .build() ) ) - .position("string") + .position("position") .build() ) .origin( Prompt.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") .build() ) .prompt( - Prompt.PromptData.Prompt.ofUnionMember0( - Prompt.PromptData.Prompt.UnionMember0.builder() - .content("string") - .type(Prompt.PromptData.Prompt.UnionMember0.Type.COMPLETION) + Prompt.PromptData.Prompt.ofCompletion( + Prompt.PromptData.Prompt.Completion.builder() + .content("content") + .type(Prompt.PromptData.Prompt.Completion.Type.COMPLETION) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 16081d5..fbbda4a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -2,157 +2,301 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.PromptUpdateParams -import com.braintrustdata.api.models.PromptUpdateParams.PromptUpdateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class PromptUpdateParamsTest { @Test fun createPromptUpdateParams() { - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData(PromptUpdateParams.PromptData.builder() - .options(PromptUpdateParams.PromptData.Options.builder() - .model("model") - .params(PromptUpdateParams.PromptData.Options.Params.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptUpdateParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptUpdateParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptUpdateParams.PromptData.Prompt.ofUnionMember0(PromptUpdateParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptUpdateParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - .tags(listOf("string")) - .build() + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData( + PromptUpdateParams.PromptData.builder() + .options( + PromptUpdateParams.PromptData.Options.builder() + .model("model") + .params( + PromptUpdateParams.PromptData.Options.Params.ofOpenAIModelParams( + PromptUpdateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptUpdateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptUpdateParams.PromptData.Prompt.ofCompletion( + PromptUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptUpdateParams.PromptData.Prompt.Completion.Type.COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData(PromptUpdateParams.PromptData.builder() - .options(PromptUpdateParams.PromptData.Options.builder() - .model("model") - .params(PromptUpdateParams.PromptData.Options.Params.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptUpdateParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptUpdateParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptUpdateParams.PromptData.Prompt.ofUnionMember0(PromptUpdateParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptUpdateParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.promptData()).isEqualTo(PromptUpdateParams.PromptData.builder() - .options(PromptUpdateParams.PromptData.Options.builder() - .model("model") - .params(PromptUpdateParams.PromptData.Options.Params.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.builder() - .frequencyPenalty(42.23) - .functionCall(PromptUpdateParams.PromptData.Options.Params.UnionMember0.FunctionCall.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.FunctionCall.UnionMember0.AUTO)) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.builder() - .type(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ResponseFormat.Type.JSON_OBJECT) - .build()) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ToolChoice.ofUnionMember0(PromptUpdateParams.PromptData.Options.Params.UnionMember0.ToolChoice.UnionMember0.AUTO)) - .topP(42.23) - .useCache(true) - .build())) - .position("position") - .build()) - .origin(PromptUpdateParams.PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .prompt(PromptUpdateParams.PromptData.Prompt.ofUnionMember0(PromptUpdateParams.PromptData.Prompt.UnionMember0.builder() - .content("content") - .type(PromptUpdateParams.PromptData.Prompt.UnionMember0.Type.COMPLETION) - .build())) - .build()) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData( + PromptUpdateParams.PromptData.builder() + .options( + PromptUpdateParams.PromptData.Options.builder() + .model("model") + .params( + PromptUpdateParams.PromptData.Options.Params + .ofOpenAIModelParams( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptUpdateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptUpdateParams.PromptData.Prompt.ofCompletion( + PromptUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptUpdateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptData()) + .isEqualTo( + PromptUpdateParams.PromptData.builder() + .options( + PromptUpdateParams.PromptData.Options.builder() + .model("model") + .params( + PromptUpdateParams.PromptData.Options.Params.ofOpenAIModelParams( + PromptUpdateParams.PromptData.Options.Params.OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + PromptUpdateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + PromptUpdateParams.PromptData.Prompt.ofCompletion( + PromptUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + PromptUpdateParams.PromptData.Prompt.Completion.Type.COMPLETION + ) + .build() + ) + ) + .build() + ) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt index 795f66b..e4500a9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt @@ -2,69 +2,75 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.RoleCreateParams -import com.braintrustdata.api.models.RoleCreateParams.RoleCreateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class RoleCreateParamsTest { @Test fun createRoleCreateParams() { - RoleCreateParams.builder() - .name("name") - .description("description") - .memberPermissions(listOf(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + RoleCreateParams.builder() + .name("name") + .description("description") + .memberPermissions( + listOf( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = RoleCreateParams.builder() - .name("name") - .description("description") - .memberPermissions(listOf(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberPermissions()).isEqualTo(listOf(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = + RoleCreateParams.builder() + .name("name") + .description("description") + .memberPermissions( + listOf( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberPermissions()) + .isEqualTo( + listOf( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = RoleCreateParams.builder() - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = RoleCreateParams.builder().name("name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt index 5c7dce9..df2e651 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.RoleDeleteParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class RoleDeleteParamsTest { @Test fun createRoleDeleteParams() { - RoleDeleteParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = RoleDeleteParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 07eceb0..2db9679 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -2,59 +2,52 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.RoleListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class RoleListParamsTest { @Test fun createRoleListParams() { - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("ids", listOf(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("role_name", listOf("role_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("role_name", listOf("role_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = RoleListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = RoleListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt index 08305d3..299ccd3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt @@ -2,69 +2,75 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.RoleReplaceParams -import com.braintrustdata.api.models.RoleReplaceParams.RoleReplaceBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class RoleReplaceParamsTest { @Test fun createRoleReplaceParams() { - RoleReplaceParams.builder() - .name("name") - .description("description") - .memberPermissions(listOf(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + RoleReplaceParams.builder() + .name("name") + .description("description") + .memberPermissions( + listOf( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = RoleReplaceParams.builder() - .name("name") - .description("description") - .memberPermissions(listOf(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberPermissions()).isEqualTo(listOf(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = + RoleReplaceParams.builder() + .name("name") + .description("description") + .memberPermissions( + listOf( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberPermissions()) + .isEqualTo( + listOf( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = RoleReplaceParams.builder() - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = RoleReplaceParams.builder().name("name").build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt index de7ef2c..d0791c4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.RoleRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class RoleRetrieveParamsTest { @Test fun createRoleRetrieveParams() { - RoleRetrieveParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = RoleRetrieveParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt index 161e13d..c232595 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt @@ -13,22 +13,37 @@ class RoleTest { val role = Role.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("string") - .memberPermissions(listOf(Role.MemberPermission.CREATE)) + .description("description") + .memberPermissions( + listOf( + Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType( + Role.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(role).isNotNull assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.name()).isEqualTo("string") + assertThat(role.name()).isEqualTo("name") assertThat(role.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(role.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.description()).contains("string") - assertThat(role.memberPermissions().get()).containsExactly(Role.MemberPermission.CREATE) + assertThat(role.description()).contains("description") + assertThat(role.memberPermissions().get()) + .containsExactly( + Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build() + ) assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(role.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(role.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt index 260c271..46274c4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt @@ -2,94 +2,121 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.RoleUpdateParams -import com.braintrustdata.api.models.RoleUpdateParams.RoleUpdateBody +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class RoleUpdateParamsTest { @Test fun createRoleUpdateParams() { - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions(listOf(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberPermissions(listOf(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberPermissions( + listOf( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberPermissions( + listOf( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() } @Test fun getBody() { - val params = RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions(listOf(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberPermissions(listOf(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.addMemberPermissions()).isEqualTo(listOf(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.addMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.removeMemberPermissions()).isEqualTo(listOf(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.removeMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val params = + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberPermissions( + listOf( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberPermissions( + listOf( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + ) + .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.addMemberPermissions()) + .isEqualTo( + listOf( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.addMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.removeMemberPermissions()) + .isEqualTo( + listOf( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.removeMemberRoles()) + .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun getBodyWithoutOptionalFields() { - val params = RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = + RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt index 71f6a83..b059ced 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt @@ -2,25 +2,13 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.TopLevelHelloWorldParams +import org.junit.jupiter.api.Test class TopLevelHelloWorldParamsTest { @Test fun createTopLevelHelloWorldParams() { - TopLevelHelloWorldParams.builder().build() + TopLevelHelloWorldParams.builder().build() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 0f7b567..45d5d6c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -2,65 +2,58 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.UserListParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class UserListParamsTest { @Test fun createUserListParams() { - UserListParams.builder() - .email("email") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("family_name") - .givenName("given_name") - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + UserListParams.builder() + .email(UserListParams.Email.ofString("string")) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName(UserListParams.FamilyName.ofString("string")) + .givenName(UserListParams.GivenName.ofString("string")) + .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = UserListParams.builder() - .email("email") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("family_name") - .givenName("given_name") - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("email", listOf("email")) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("family_name", listOf("family_name")) - expected.put("given_name", listOf("given_name")) - expected.put("ids", listOf(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = + UserListParams.builder() + .email(UserListParams.Email.ofString("string")) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName(UserListParams.FamilyName.ofString("string")) + .givenName(UserListParams.GivenName.ofString("string")) + .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("email", listOf(UserListParams.Email.ofString("string").toString())) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("family_name", listOf(UserListParams.FamilyName.ofString("string").toString())) + expected.put("given_name", listOf(UserListParams.GivenName.ofString("string").toString())) + expected.put( + "ids", + listOf(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = UserListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = UserListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt index bb485d8..ee03a0d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt @@ -2,39 +2,25 @@ package com.braintrustdata.api.models -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.UUID -import org.junit.jupiter.api.Test -import org.assertj.core.api.Assertions.assertThat -import org.apache.hc.core5.http.ContentType -import com.braintrustdata.api.core.ContentTypes -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.UserRetrieveParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test class UserRetrieveParamsTest { @Test fun createUserRetrieveParams() { - UserRetrieveParams.builder() - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = UserRetrieveParams.builder() - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "userId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "userId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt index d29fe01..fe6f480 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt @@ -13,18 +13,18 @@ class UserTest { val user = User.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .avatarUrl("string") + .avatarUrl("avatar_url") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .email("string") - .familyName("string") - .givenName("string") + .email("email") + .familyName("family_name") + .givenName("given_name") .build() assertThat(user).isNotNull assertThat(user.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(user.avatarUrl()).contains("string") + assertThat(user.avatarUrl()).contains("avatar_url") assertThat(user.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(user.email()).contains("string") - assertThat(user.familyName()).contains("string") - assertThat(user.givenName()).contains("string") + assertThat(user.email()).contains("email") + assertThat(user.familyName()).contains("family_name") + assertThat(user.givenName()).contains("given_name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt new file mode 100644 index 0000000..0d8738d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.* +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ViewCreateParamsTest { + + @Test + fun createViewCreateParams() { + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewCreateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewCreateParams.Options.ColumnSizing.builder().build()) + .columnVisibility(ViewCreateParams.Options.ColumnVisibility.builder().build()) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewCreateParams.ViewData.builder() + .search( + ViewCreateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + } + + @Test + fun getBody() { + val params = + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewCreateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewCreateParams.Options.ColumnSizing.builder().build()) + .columnVisibility( + ViewCreateParams.Options.ColumnVisibility.builder().build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewCreateParams.ViewData.builder() + .search( + ViewCreateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).isEqualTo(ViewCreateParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()) + .isEqualTo( + ViewCreateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewCreateParams.Options.ColumnSizing.builder().build()) + .columnVisibility(ViewCreateParams.Options.ColumnVisibility.builder().build()) + .build() + ) + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()) + .isEqualTo( + ViewCreateParams.ViewData.builder() + .search( + ViewCreateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt new file mode 100644 index 0000000..07e7efc --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ViewDeleteParamsTest { + + @Test + fun createViewDeleteParams() { + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + } + + @Test + fun getBody() { + val params = + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun getPathParam() { + val params = + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt new file mode 100644 index 0000000..5b51a37 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ViewListParamsTest { + + @Test + fun createViewListParams() { + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewName("view_name") + .viewType(ViewListParams.ViewType.PROJECTS) + .build() + } + + @Test + fun getQueryParams() { + val params = + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewName("view_name") + .viewType(ViewListParams.ViewType.PROJECTS) + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("object_type", listOf(ViewListParams.ObjectType.ORGANIZATION.toString())) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put( + "ids", + listOf(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ) + expected.put("limit", listOf("123")) + expected.put("project_name", listOf("project_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("view_name", listOf("view_name")) + expected.put("view_type", listOf(ViewListParams.ViewType.PROJECTS.toString())) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + ViewListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt new file mode 100644 index 0000000..065d488 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.* +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ViewReplaceParamsTest { + + @Test + fun createViewReplaceParams() { + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewReplaceParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewReplaceParams.Options.ColumnSizing.builder().build()) + .columnVisibility(ViewReplaceParams.Options.ColumnVisibility.builder().build()) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewReplaceParams.ViewData.builder() + .search( + ViewReplaceParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + } + + @Test + fun getBody() { + val params = + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewReplaceParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewReplaceParams.Options.ColumnSizing.builder().build()) + .columnVisibility( + ViewReplaceParams.Options.ColumnVisibility.builder().build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewReplaceParams.ViewData.builder() + .search( + ViewReplaceParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).isEqualTo(ViewReplaceParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()) + .isEqualTo( + ViewReplaceParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewReplaceParams.Options.ColumnSizing.builder().build()) + .columnVisibility(ViewReplaceParams.Options.ColumnVisibility.builder().build()) + .build() + ) + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()) + .isEqualTo( + ViewReplaceParams.ViewData.builder() + .search( + ViewReplaceParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt new file mode 100644 index 0000000..9e08a8b --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ViewRetrieveParamsTest { + + @Test + fun createViewRetrieveParams() { + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + } + + @Test + fun getQueryParams() { + val params = + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("object_type", listOf(ViewRetrieveParams.ObjectType.ORGANIZATION.toString())) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt new file mode 100644 index 0000000..1aaa88e --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ViewTest { + + @Test + fun createView() { + val view = + View.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(View.ObjectType.ORGANIZATION) + .viewType(View.ViewType.PROJECTS) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + View.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(View.Options.ColumnSizing.builder().build()) + .columnVisibility(View.Options.ColumnVisibility.builder().build()) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + View.ViewData.builder() + .search( + View.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + assertThat(view).isNotNull + assertThat(view.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.name()).isEqualTo("name") + assertThat(view.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.objectType()).contains(View.ObjectType.ORGANIZATION) + assertThat(view.viewType()).contains(View.ViewType.PROJECTS) + assertThat(view.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(view.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(view.options()) + .contains( + View.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(View.Options.ColumnSizing.builder().build()) + .columnVisibility(View.Options.ColumnVisibility.builder().build()) + .build() + ) + assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.viewData()) + .contains( + View.ViewData.builder() + .search( + View.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt new file mode 100644 index 0000000..8a3a7c2 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ViewUpdateParamsTest { + + @Test + fun createViewUpdateParams() { + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewUpdateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewUpdateParams.Options.ColumnSizing.builder().build()) + .columnVisibility(ViewUpdateParams.Options.ColumnVisibility.builder().build()) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewUpdateParams.ViewData.builder() + .search( + ViewUpdateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() + } + + @Test + fun getBody() { + val params = + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewUpdateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewUpdateParams.Options.ColumnSizing.builder().build()) + .columnVisibility( + ViewUpdateParams.Options.ColumnVisibility.builder().build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewUpdateParams.ViewData.builder() + .search( + ViewUpdateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertThat(body.name()).isEqualTo("name") + assertThat(body.options()) + .isEqualTo( + ViewUpdateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewUpdateParams.Options.ColumnSizing.builder().build()) + .columnVisibility(ViewUpdateParams.Options.ColumnVisibility.builder().build()) + .build() + ) + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()) + .isEqualTo( + ViewUpdateParams.ViewData.builder() + .search( + ViewUpdateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + assertThat(body.viewType()).isEqualTo(ViewUpdateParams.ViewType.PROJECTS) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun getPathParam() { + val params = + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index b0e6ebe..e67c569 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -57,33 +57,34 @@ class ErrorHandlingTest { @Test fun projectsCreate200() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() val expected = Project.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(Project.Settings.builder().comparisonKey("comparison_key").build()) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() stubFor(post(anyUrl()).willReturn(ok().withBody(toJson(expected)))) - assertThat(client.project().create(params)).isEqualTo(expected) + assertThat(client.projects().create(params)).isEqualTo(expected) } @Test fun projectsCreate400() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(400).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertBadRequest(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) @@ -91,14 +92,14 @@ class ErrorHandlingTest { @Test fun projectsCreate401() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(401).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertUnauthorized(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) @@ -106,14 +107,14 @@ class ErrorHandlingTest { @Test fun projectsCreate403() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(403).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertPermissionDenied(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) @@ -121,14 +122,14 @@ class ErrorHandlingTest { @Test fun projectsCreate404() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(404).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertNotFound(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) @@ -136,14 +137,14 @@ class ErrorHandlingTest { @Test fun projectsCreate422() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertUnprocessableEntity( e, @@ -155,14 +156,14 @@ class ErrorHandlingTest { @Test fun projectsCreate429() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(429).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertRateLimit(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) @@ -170,14 +171,14 @@ class ErrorHandlingTest { @Test fun projectsCreate500() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(500).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertInternalServer(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) @@ -185,14 +186,14 @@ class ErrorHandlingTest { @Test fun unexpectedStatusCode() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor( post(anyUrl()) .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertUnexpectedStatusCodeException( e, @@ -205,11 +206,11 @@ class ErrorHandlingTest { @Test fun invalidBody() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor(post(anyUrl()).willReturn(status(200).withBody("Not JSON"))) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertThat(e) .isInstanceOf(BraintrustException::class.java) @@ -219,11 +220,11 @@ class ErrorHandlingTest { @Test fun invalidErrorBody() { - val params = ProjectCreateParams.builder().name("string").orgName("string").build() + val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() stubFor(post(anyUrl()).willReturn(status(400).withBody("Not JSON"))) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertBadRequest(e, ImmutableListMultimap.of(), BraintrustError.builder().build()) }) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index ac41285..f7915e8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -57,8 +57,8 @@ class ServiceParamsTest { val params = ProjectCreateParams.builder() - .name("string") - .orgName("string") + .name("name") + .orgName("org_name") .additionalHeaders(additionalHeaders) .additionalBodyProperties(additionalBodyProperties) .additionalQueryParams(additionalQueryParams) @@ -67,10 +67,11 @@ class ServiceParamsTest { val apiResponse = Project.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(Project.Settings.builder().comparisonKey("comparison_key").build()) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -82,7 +83,7 @@ class ServiceParamsTest { .willReturn(ok(JSON_MAPPER.writeValueAsString(apiResponse))) ) - client.project().create(params) + client.projects().create(params) verify(postRequestedFor(anyUrl())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt index 22d8eff..4d23625 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt @@ -19,7 +19,7 @@ class AclServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aclService = client.acl() + val aclService = client.acls() val acl = aclService.create( AclCreateParams.builder() @@ -43,7 +43,7 @@ class AclServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aclService = client.acl() + val aclService = client.acls() val acl = aclService.retrieve( AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -59,7 +59,7 @@ class AclServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aclService = client.acl() + val aclService = client.acls() val response = aclService.list( AclListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -75,7 +75,7 @@ class AclServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aclService = client.acl() + val aclService = client.acls() val acl = aclService.delete( AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -83,28 +83,4 @@ class AclServiceTest { println(acl) acl.validate() } - - @Test - fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acl() - val acl = - aclService.replace( - AclReplaceParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclReplaceParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclReplaceParams.Permission.CREATE) - .restrictObjectType(AclReplaceParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(acl) - acl.validate() - } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt new file mode 100644 index 0000000..a19bfd9 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ApiKeyListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ApiKeyServiceTest { + + @Test + fun callCreate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() + val apiKeyCreateResponse = + apiKeyService.create( + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + ) + println(apiKeyCreateResponse) + apiKeyCreateResponse.validate() + } + + @Test + fun callRetrieve() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() + val apiKey = + apiKeyService.retrieve( + ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(apiKey) + apiKey.validate() + } + + @Test + fun callList() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() + val response = apiKeyService.list(ApiKeyListParams.builder().build()) + println(response) + response.objects().forEach { it.validate() } + } + + @Test + fun callDelete() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() + val apiKey = + apiKeyService.delete( + ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(apiKey) + apiKey.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index b51db01..ce2d55c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.* import com.braintrustdata.api.models.DatasetListParams +import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,12 +21,12 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val dataset = datasetService.create( DatasetCreateParams.builder() - .name("string") - .description("string") + .name("name") + .description("description") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -40,7 +41,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val dataset = datasetService.retrieve( DatasetRetrieveParams.builder() @@ -58,13 +59,14 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val dataset = datasetService.update( DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("string") - .name("string") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder().build()) + .name("name") .build() ) println(dataset) @@ -78,7 +80,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val response = datasetService.list(DatasetListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -91,7 +93,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val dataset = datasetService.delete( DatasetDeleteParams.builder() @@ -109,15 +111,15 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() datasetService.feedback( DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( DatasetFeedbackParams.Feedback.builder() - .id("string") - .comment("string") + .id("id") + .comment("comment") .metadata(DatasetFeedbackParams.Feedback.Metadata.builder().build()) .source(DatasetFeedbackParams.Feedback.Source.APP) .build() @@ -134,15 +136,15 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val datasetFetchResponse = datasetService.fetch( DatasetFetchParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(123L) - .maxRootSpanId("string") - .maxXactId("string") - .version("string") + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") .build() ) println(datasetFetchResponse) @@ -156,12 +158,12 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val datasetFetchPostResponse = datasetService.fetchPost( DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("string") + .cursor("cursor") .filters( listOf( DatasetFetchPostParams.Filter.builder() @@ -172,9 +174,9 @@ class DatasetServiceTest { ) ) .limit(123L) - .maxRootSpanId("string") - .maxXactId("string") - .version("string") + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") .build() ) println(datasetFetchPostResponse) @@ -188,7 +190,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val datasetInsertResponse = datasetService.insert( DatasetInsertParams.builder() @@ -197,10 +199,11 @@ class DatasetServiceTest { listOf( DatasetInsertParams.Event.ofInsertDatasetEventReplace( DatasetInsertParams.Event.InsertDatasetEventReplace.builder() - .id("string") + .id("id") ._isMerge(true) ._objectDelete(true) - ._parentId("string") + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( @@ -219,26 +222,6 @@ class DatasetServiceTest { datasetInsertResponse.validate() } - @Test - fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val dataset = - datasetService.replace( - DatasetReplaceParams.builder() - .name("string") - .description("string") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(dataset) - dataset.validate() - } - @Test fun callSummarize() { val client = @@ -246,7 +229,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val datasetSummarizeResponse = datasetService.summarize( DatasetSummarizeParams.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt index fd5d17a..5159192 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.* import com.braintrustdata.api.models.ExperimentListParams +import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,30 +21,30 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experiment = experimentService.create( ExperimentCreateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("string") - .description("string") + .datasetVersion("dataset_version") + .description("description") .ensureNew(true) .metadata(ExperimentCreateParams.Metadata.builder().build()) - .name("string") + .name("name") .public_(true) .repoInfo( ExperimentCreateParams.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") .dirty(true) - .gitDiff("string") - .tag("string") + .gitDiff("git_diff") + .tag("tag") .build() ) .build() @@ -59,7 +60,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experiment = experimentService.retrieve( ExperimentRetrieveParams.builder() @@ -77,29 +78,29 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experiment = experimentService.update( ExperimentUpdateParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("string") - .description("string") + .datasetVersion("dataset_version") + .description("description") .metadata(ExperimentUpdateParams.Metadata.builder().build()) - .name("string") + .name("name") .public_(true) .repoInfo( ExperimentUpdateParams.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") .dirty(true) - .gitDiff("string") - .tag("string") + .gitDiff("git_diff") + .tag("tag") .build() ) .build() @@ -115,7 +116,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val response = experimentService.list(ExperimentListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -128,7 +129,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experiment = experimentService.delete( ExperimentDeleteParams.builder() @@ -146,15 +147,15 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() experimentService.feedback( ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( ExperimentFeedbackParams.Feedback.builder() - .id("string") - .comment("string") + .id("id") + .comment("comment") .expected(JsonValue.from(mapOf())) .metadata(ExperimentFeedbackParams.Feedback.Metadata.builder().build()) .scores(ExperimentFeedbackParams.Feedback.Scores.builder().build()) @@ -173,15 +174,15 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experimentFetchResponse = experimentService.fetch( ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(123L) - .maxRootSpanId("string") - .maxXactId("string") - .version("string") + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") .build() ) println(experimentFetchResponse) @@ -195,12 +196,12 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experimentFetchPostResponse = experimentService.fetchPost( ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("string") + .cursor("cursor") .filters( listOf( ExperimentFetchPostParams.Filter.builder() @@ -211,9 +212,9 @@ class ExperimentServiceTest { ) ) .limit(123L) - .maxRootSpanId("string") - .maxXactId("string") - .version("string") + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") .build() ) println(experimentFetchPostResponse) @@ -227,7 +228,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experimentInsertResponse = experimentService.insert( ExperimentInsertParams.builder() @@ -236,20 +237,21 @@ class ExperimentServiceTest { listOf( ExperimentInsertParams.Event.ofInsertExperimentEventReplace( ExperimentInsertParams.Event.InsertExperimentEventReplace.builder() - .id("string") + .id("id") ._isMerge(true) ._objectDelete(true) - ._parentId("string") + ._parentId("_parent_id") .context( ExperimentInsertParams.Event.InsertExperimentEventReplace .Context .builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) - .datasetRecordId("string") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( @@ -280,7 +282,7 @@ class ExperimentServiceTest { ExperimentInsertParams.Event.InsertExperimentEventReplace .SpanAttributes .builder() - .name("string") + .name("name") .type( ExperimentInsertParams.Event .InsertExperimentEventReplace @@ -301,45 +303,6 @@ class ExperimentServiceTest { experimentInsertResponse.validate() } - @Test - fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val experiment = - experimentService.replace( - ExperimentReplaceParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("string") - .description("string") - .ensureNew(true) - .metadata(ExperimentReplaceParams.Metadata.builder().build()) - .name("string") - .public_(true) - .repoInfo( - ExperimentReplaceParams.RepoInfo.builder() - .authorEmail("string") - .authorName("string") - .branch("string") - .commit("string") - .commitMessage("string") - .commitTime("string") - .dirty(true) - .gitDiff("string") - .tag("string") - .build() - ) - .build() - ) - println(experiment) - experiment.validate() - } - @Test fun callSummarize() { val client = @@ -347,7 +310,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val experimentSummarizeResponse = experimentService.summarize( ExperimentSummarizeParams.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt new file mode 100644 index 0000000..51ac54d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt @@ -0,0 +1,425 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.FunctionListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class FunctionServiceTest { + + @Test + fun callCreate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() + val function = + functionService.create( + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + FunctionCreateParams.PromptData.builder() + .options( + FunctionCreateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionCreateParams.PromptData.Options.Params + .ofOpenAIModelParams( + FunctionCreateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionCreateParams.PromptData + .Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionCreateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionCreateParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionCreateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionCreateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionCreateParams.PromptData.Prompt.ofCompletion( + FunctionCreateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionCreateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + println(function) + function.validate() + } + + @Test + fun callRetrieve() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() + val function = + functionService.retrieve( + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(function) + function.validate() + } + + @Test + fun callUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() + val function = + functionService.update( + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.ofPrompt( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .promptData( + FunctionUpdateParams.PromptData.builder() + .options( + FunctionUpdateParams.PromptData.Options.builder() + .model("model") + .params( + FunctionUpdateParams.PromptData.Options.Params + .ofOpenAIModelParams( + FunctionUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionUpdateParams.PromptData + .Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionUpdateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionUpdateParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionUpdateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionUpdateParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionUpdateParams.PromptData.Prompt.ofCompletion( + FunctionUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionUpdateParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + println(function) + function.validate() + } + + @Test + fun callList() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() + val response = functionService.list(FunctionListParams.builder().build()) + println(response) + response.objects().forEach { it.validate() } + } + + @Test + fun callDelete() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() + val function = + functionService.delete( + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(function) + function.validate() + } + + @Test + fun callReplace() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() + val function = + functionService.replace( + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .promptData( + FunctionReplaceParams.PromptData.builder() + .options( + FunctionReplaceParams.PromptData.Options.builder() + .model("model") + .params( + FunctionReplaceParams.PromptData.Options.Params + .ofOpenAIModelParams( + FunctionReplaceParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + FunctionReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + FunctionReplaceParams.PromptData + .Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + FunctionReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + FunctionReplaceParams.PromptData + .Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + FunctionReplaceParams.PromptData.Options + .Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + FunctionReplaceParams.PromptData + .Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + ) + .origin( + FunctionReplaceParams.PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .prompt( + FunctionReplaceParams.PromptData.Prompt.ofCompletion( + FunctionReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") + .type( + FunctionReplaceParams.PromptData.Prompt.Completion.Type + .COMPLETION + ) + .build() + ) + ) + .build() + ) + .tags(listOf("string")) + .build() + ) + println(function) + function.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index febf17d..197a689 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -19,15 +19,15 @@ class GroupServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val groupService = client.group() + val groupService = client.groups() val group = groupService.create( GroupCreateParams.builder() - .name("string") - .description("string") + .name("name") + .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("string") + .orgName("org_name") .build() ) println(group) @@ -41,7 +41,7 @@ class GroupServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val groupService = client.group() + val groupService = client.groups() val group = groupService.retrieve( GroupRetrieveParams.builder() @@ -59,15 +59,17 @@ class GroupServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val groupService = client.group() + val groupService = client.groups() val group = groupService.update( GroupUpdateParams.builder() .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("string") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .name("string") + .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() ) println(group) @@ -81,7 +83,7 @@ class GroupServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val groupService = client.group() + val groupService = client.groups() val response = groupService.list(GroupListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -94,7 +96,7 @@ class GroupServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val groupService = client.group() + val groupService = client.groups() val group = groupService.delete( GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -110,15 +112,15 @@ class GroupServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val groupService = client.group() + val groupService = client.groups() val group = groupService.replace( GroupReplaceParams.builder() - .name("string") - .description("string") + .name("name") + .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("string") + .orgName("org_name") .build() ) println(group) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt new file mode 100644 index 0000000..17bcb9d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class OrganizationServiceTest { + + @Test + fun callRetrieve() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() + val organization = + organizationService.retrieve( + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(organization) + organization.validate() + } + + @Test + fun callUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() + val organization = + organizationService.update( + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + ) + println(organization) + organization.validate() + } + + @Test + fun callList() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() + val response = organizationService.list(OrganizationListParams.builder().build()) + println(response) + response.objects().forEach { it.validate() } + } + + @Test + fun callDelete() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() + val organization = + organizationService.delete( + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(organization) + organization.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt new file mode 100644 index 0000000..8941a65 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectScoreListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ProjectScoreServiceTest { + + @Test + fun callCreate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + val projectScore = + projectScoreService.create( + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categories( + ProjectScoreCreateParams.Categories.ofList( + listOf( + ProjectScoreCreateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .build() + ) + println(projectScore) + projectScore.validate() + } + + @Test + fun callRetrieve() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + val projectScore = + projectScoreService.retrieve( + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(projectScore) + projectScore.validate() + } + + @Test + fun callUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + val projectScore = + projectScoreService.update( + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categories( + ProjectScoreUpdateParams.Categories.ofList( + listOf( + ProjectScoreUpdateParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() + ) + println(projectScore) + projectScore.validate() + } + + @Test + fun callList() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + val response = projectScoreService.list(ProjectScoreListParams.builder().build()) + println(response) + response.objects().forEach { it.validate() } + } + + @Test + fun callDelete() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + val projectScore = + projectScoreService.delete( + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(projectScore) + projectScore.validate() + } + + @Test + fun callReplace() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + val projectScore = + projectScoreService.replace( + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categories( + ProjectScoreReplaceParams.Categories.ofList( + listOf( + ProjectScoreReplaceParams.Categories.ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + ) + ) + ) + .description("description") + .build() + ) + println(projectScore) + projectScore.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index cbcc620..0dcc9ea 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -19,10 +19,10 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() + val projectService = client.projects() val project = projectService.create( - ProjectCreateParams.builder().name("string").orgName("string").build() + ProjectCreateParams.builder().name("name").orgName("org_name").build() ) println(project) project.validate() @@ -35,7 +35,7 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() + val projectService = client.projects() val project = projectService.retrieve( ProjectRetrieveParams.builder() @@ -53,12 +53,17 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() + val projectService = client.projects() val project = projectService.update( ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("string") + .name("name") + .settings( + ProjectUpdateParams.Settings.builder() + .comparisonKey("comparison_key") + .build() + ) .build() ) println(project) @@ -72,7 +77,7 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() + val projectService = client.projects() val response = projectService.list(ProjectListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -85,7 +90,7 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() + val projectService = client.projects() val project = projectService.delete( ProjectDeleteParams.builder() @@ -95,20 +100,4 @@ class ProjectServiceTest { println(project) project.validate() } - - @Test - fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.project() - val project = - projectService.replace( - ProjectReplaceParams.builder().name("string").orgName("string").build() - ) - println(project) - project.validate() - } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt new file mode 100644 index 0000000..bffa896 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ProjectTagServiceTest { + + @Test + fun callCreate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + val projectTag = + projectTagService.create( + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + println(projectTag) + projectTag.validate() + } + + @Test + fun callRetrieve() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + val projectTag = + projectTagService.retrieve( + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(projectTag) + projectTag.validate() + } + + @Test + fun callUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + val projectTag = + projectTagService.update( + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + ) + println(projectTag) + projectTag.validate() + } + + @Test + fun callList() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + val response = projectTagService.list(ProjectTagListParams.builder().build()) + println(response) + response.objects().forEach { it.validate() } + } + + @Test + fun callDelete() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + val projectTag = + projectTagService.delete( + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(projectTag) + projectTag.validate() + } + + @Test + fun callReplace() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + val projectTag = + projectTagService.replace( + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + println(projectTag) + projectTag.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 1a041f7..e8ecd0c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -19,92 +19,96 @@ class PromptServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val promptService = client.prompt() + val promptService = client.prompts() val prompt = promptService.create( PromptCreateParams.builder() - .name("string") + .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") - .description("string") + .slug("slug") + .description("description") .promptData( PromptCreateParams.PromptData.builder() .options( PromptCreateParams.PromptData.Options.builder() - .model("string") + .model("model") .params( - PromptCreateParams.PromptData.Options.Params.ofUnionMember0( - PromptCreateParams.PromptData.Options.Params - .UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptCreateParams.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptCreateParams.PromptData.Options - .Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptCreateParams.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptCreateParams.PromptData.Options - .Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptCreateParams.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptCreateParams.PromptData.Options - .Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptCreateParams.PromptData.Options.Params + .ofOpenAIModelParams( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptCreateParams.PromptData + .Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptCreateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptCreateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptCreateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) ) - .position("string") + .position("position") .build() ) .origin( PromptCreateParams.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") .build() ) .prompt( - PromptCreateParams.PromptData.Prompt.ofUnionMember0( - PromptCreateParams.PromptData.Prompt.UnionMember0.builder() - .content("string") + PromptCreateParams.PromptData.Prompt.ofCompletion( + PromptCreateParams.PromptData.Prompt.Completion.builder() + .content("content") .type( - PromptCreateParams.PromptData.Prompt.UnionMember0.Type + PromptCreateParams.PromptData.Prompt.Completion.Type .COMPLETION ) .build() @@ -126,7 +130,7 @@ class PromptServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val promptService = client.prompt() + val promptService = client.prompts() val prompt = promptService.retrieve( PromptRetrieveParams.builder() @@ -144,91 +148,95 @@ class PromptServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val promptService = client.prompt() + val promptService = client.prompts() val prompt = promptService.update( PromptUpdateParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("string") - .name("string") + .description("description") + .name("name") .promptData( PromptUpdateParams.PromptData.builder() .options( PromptUpdateParams.PromptData.Options.builder() - .model("string") + .model("model") .params( - PromptUpdateParams.PromptData.Options.Params.ofUnionMember0( - PromptUpdateParams.PromptData.Options.Params - .UnionMember0 - .builder() - .frequencyPenalty(42.23) - .functionCall( - PromptUpdateParams.PromptData.Options.Params - .UnionMember0 - .FunctionCall - .ofUnionMember0( - PromptUpdateParams.PromptData.Options - .Params - .UnionMember0 - .FunctionCall - .UnionMember0 - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptUpdateParams.PromptData.Options.Params - .UnionMember0 - .ResponseFormat - .builder() - .type( - PromptUpdateParams.PromptData.Options - .Params - .UnionMember0 - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptUpdateParams.PromptData.Options.Params - .UnionMember0 - .ToolChoice - .ofUnionMember0( - PromptUpdateParams.PromptData.Options - .Params - .UnionMember0 - .ToolChoice - .UnionMember0 - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptUpdateParams.PromptData.Options.Params + .ofOpenAIModelParams( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .builder() + .frequencyPenalty(42.23) + .functionCall( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .FunctionCall + .ofAuto( + PromptUpdateParams.PromptData + .Options + .Params + .OpenAIModelParams + .FunctionCall + .Auto + .AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .builder() + .type( + PromptUpdateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ResponseFormat + .Type + .JSON_OBJECT + ) + .build() + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptUpdateParams.PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .ofAuto( + PromptUpdateParams.PromptData + .Options + .Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) ) - .position("string") + .position("position") .build() ) .origin( PromptUpdateParams.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") .build() ) .prompt( - PromptUpdateParams.PromptData.Prompt.ofUnionMember0( - PromptUpdateParams.PromptData.Prompt.UnionMember0.builder() - .content("string") + PromptUpdateParams.PromptData.Prompt.ofCompletion( + PromptUpdateParams.PromptData.Prompt.Completion.builder() + .content("content") .type( - PromptUpdateParams.PromptData.Prompt.UnionMember0.Type + PromptUpdateParams.PromptData.Prompt.Completion.Type .COMPLETION ) .build() @@ -250,7 +258,7 @@ class PromptServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val promptService = client.prompt() + val promptService = client.prompts() val response = promptService.list(PromptListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -263,7 +271,7 @@ class PromptServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val promptService = client.prompt() + val promptService = client.prompts() val prompt = promptService.delete( PromptDeleteParams.builder() @@ -274,31 +282,6 @@ class PromptServiceTest { prompt.validate() } - @Test - fun callFeedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompt() - promptService.feedback( - PromptFeedbackParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - PromptFeedbackParams.Feedback.builder() - .id("string") - .comment("string") - .metadata(PromptFeedbackParams.Feedback.Metadata.builder().build()) - .source(PromptFeedbackParams.Feedback.Source.APP) - .build() - ) - ) - .build() - ) - } - @Test fun callReplace() { val client = @@ -306,38 +289,38 @@ class PromptServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val promptService = client.prompt() + val promptService = client.prompts() val prompt = promptService.replace( PromptReplaceParams.builder() - .name("string") + .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("string") - .description("string") + .slug("slug") + .description("description") .promptData( PromptReplaceParams.PromptData.builder() .options( PromptReplaceParams.PromptData.Options.builder() - .model("string") + .model("model") .params( PromptReplaceParams.PromptData.Options.Params - .ofUnionMember0( + .ofOpenAIModelParams( PromptReplaceParams.PromptData.Options.Params - .UnionMember0 + .OpenAIModelParams .builder() .frequencyPenalty(42.23) .functionCall( PromptReplaceParams.PromptData.Options .Params - .UnionMember0 + .OpenAIModelParams .FunctionCall - .ofUnionMember0( + .ofAuto( PromptReplaceParams.PromptData .Options .Params - .UnionMember0 + .OpenAIModelParams .FunctionCall - .UnionMember0 + .Auto .AUTO ) ) @@ -347,14 +330,14 @@ class PromptServiceTest { .responseFormat( PromptReplaceParams.PromptData.Options .Params - .UnionMember0 + .OpenAIModelParams .ResponseFormat .builder() .type( PromptReplaceParams.PromptData .Options .Params - .UnionMember0 + .OpenAIModelParams .ResponseFormat .Type .JSON_OBJECT @@ -366,15 +349,15 @@ class PromptServiceTest { .toolChoice( PromptReplaceParams.PromptData.Options .Params - .UnionMember0 + .OpenAIModelParams .ToolChoice - .ofUnionMember0( + .ofAuto( PromptReplaceParams.PromptData .Options .Params - .UnionMember0 + .OpenAIModelParams .ToolChoice - .UnionMember0 + .Auto .AUTO ) ) @@ -383,22 +366,22 @@ class PromptServiceTest { .build() ) ) - .position("string") + .position("position") .build() ) .origin( PromptReplaceParams.PromptData.Origin.builder() - .projectId("string") - .promptId("string") - .promptVersion("string") + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") .build() ) .prompt( - PromptReplaceParams.PromptData.Prompt.ofUnionMember0( - PromptReplaceParams.PromptData.Prompt.UnionMember0.builder() - .content("string") + PromptReplaceParams.PromptData.Prompt.ofCompletion( + PromptReplaceParams.PromptData.Prompt.Completion.builder() + .content("content") .type( - PromptReplaceParams.PromptData.Prompt.UnionMember0.Type + PromptReplaceParams.PromptData.Prompt.Completion.Type .COMPLETION ) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt index 11c7f0b..20cdf59 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt @@ -19,15 +19,25 @@ class RoleServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val roleService = client.role() + val roleService = client.roles() val role = roleService.create( RoleCreateParams.builder() - .name("string") - .description("string") - .memberPermissions(listOf(RoleCreateParams.MemberPermission.CREATE)) + .name("name") + .description("description") + .memberPermissions( + listOf( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + ) .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("string") + .orgName("org_name") .build() ) println(role) @@ -41,7 +51,7 @@ class RoleServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val roleService = client.role() + val roleService = client.roles() val role = roleService.retrieve( RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -57,15 +67,39 @@ class RoleServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val roleService = client.role() + val roleService = client.roles() val role = roleService.update( RoleUpdateParams.builder() .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("string") - .memberPermissions(listOf(RoleUpdateParams.MemberPermission.CREATE)) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .name("string") + .addMemberPermissions( + listOf( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + ) + .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberPermissions( + listOf( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission( + RoleUpdateParams.RemoveMemberPermission.Permission.CREATE + ) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + ) + .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() ) println(role) @@ -79,7 +113,7 @@ class RoleServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val roleService = client.role() + val roleService = client.roles() val response = roleService.list(RoleListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -92,7 +126,7 @@ class RoleServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val roleService = client.role() + val roleService = client.roles() val role = roleService.delete( RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -108,15 +142,25 @@ class RoleServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val roleService = client.role() + val roleService = client.roles() val role = roleService.replace( RoleReplaceParams.builder() - .name("string") - .description("string") - .memberPermissions(listOf(RoleReplaceParams.MemberPermission.CREATE)) + .name("name") + .description("description") + .memberPermissions( + listOf( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + ) .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("string") + .orgName("org_name") .build() ) println(role) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index 747c114..24f732e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -19,7 +19,7 @@ class UserServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val userService = client.user() + val userService = client.users() val user = userService.retrieve( UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -35,7 +35,7 @@ class UserServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val userService = client.user() + val userService = client.users() val response = userService.list(UserListParams.builder().build()) println(response) response.objects().forEach { it.validate() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt new file mode 100644 index 0000000..fc231b4 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ViewListParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ViewServiceTest { + + @Test + fun callCreate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + val view = + viewService.create( + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewCreateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewCreateParams.Options.ColumnSizing.builder().build()) + .columnVisibility( + ViewCreateParams.Options.ColumnVisibility.builder().build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewCreateParams.ViewData.builder() + .search( + ViewCreateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + ) + println(view) + view.validate() + } + + @Test + fun callRetrieve() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + val view = + viewService.retrieve( + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + ) + println(view) + view.validate() + } + + @Test + fun callUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + val view = + viewService.update( + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewUpdateParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewUpdateParams.Options.ColumnSizing.builder().build()) + .columnVisibility( + ViewUpdateParams.Options.ColumnVisibility.builder().build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewUpdateParams.ViewData.builder() + .search( + ViewUpdateParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() + ) + println(view) + view.validate() + } + + @Test + fun callList() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + val response = + viewService.list( + ViewListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + println(response) + response.objects().forEach { it.validate() } + } + + @Test + fun callDelete() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + val view = + viewService.delete( + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + ) + println(view) + view.validate() + } + + @Test + fun callReplace() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + val view = + viewService.replace( + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewReplaceParams.Options.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewReplaceParams.Options.ColumnSizing.builder().build()) + .columnVisibility( + ViewReplaceParams.Options.ColumnVisibility.builder().build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewReplaceParams.ViewData.builder() + .search( + ViewReplaceParams.ViewData.Search.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + ) + .build() + ) + .build() + ) + println(view) + view.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt new file mode 100644 index 0000000..da1637a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking.organizations + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.* +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class MemberServiceTest { + + @Test + fun callUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberService = client.organizations().members() + val organizationMemberUpdateResponse = + memberService.update( + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + .build() + ) + println(organizationMemberUpdateResponse) + organizationMemberUpdateResponse.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt similarity index 86% rename from braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt index 1a34e11..859bdd5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt @@ -1,11 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.braintrustdata.api.services.blocking.project +package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.* +import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -19,15 +20,15 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() logService.feedback( ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .feedback( listOf( ProjectLogFeedbackParams.Feedback.builder() - .id("string") - .comment("string") + .id("id") + .comment("comment") .expected(JsonValue.from(mapOf())) .metadata(ProjectLogFeedbackParams.Feedback.Metadata.builder().build()) .scores(ProjectLogFeedbackParams.Feedback.Scores.builder().build()) @@ -46,15 +47,15 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() val projectLogFetchResponse = logService.fetch( ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .limit(123L) - .maxRootSpanId("string") - .maxXactId("string") - .version("string") + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") .build() ) println(projectLogFetchResponse) @@ -68,12 +69,12 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() val projectLogFetchPostResponse = logService.fetchPost( ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("string") + .cursor("cursor") .filters( listOf( ProjectLogFetchPostParams.Filter.builder() @@ -84,9 +85,9 @@ class LogServiceTest { ) ) .limit(123L) - .maxRootSpanId("string") - .maxXactId("string") - .version("string") + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") .build() ) println(projectLogFetchPostResponse) @@ -100,7 +101,7 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() val projectLogInsertResponse = logService.insert( ProjectLogInsertParams.builder() @@ -109,19 +110,20 @@ class LogServiceTest { listOf( ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( ProjectLogInsertParams.Event.InsertProjectLogsEventReplace.builder() - .id("string") + .id("id") ._isMerge(true) ._objectDelete(true) - ._parentId("string") + ._parentId("_parent_id") .context( ProjectLogInsertParams.Event.InsertProjectLogsEventReplace .Context .builder() - .callerFilename("string") - .callerFunctionname("string") + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") .callerLineno(123L) .build() ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( @@ -152,7 +154,7 @@ class LogServiceTest { ProjectLogInsertParams.Event.InsertProjectLogsEventReplace .SpanAttributes .builder() - .name("string") + .name("name") .type( ProjectLogInsertParams.Event .InsertProjectLogsEventReplace diff --git a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts index e19eea7..cf06fbd 100644 --- a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts @@ -29,7 +29,7 @@ configure { pom { name.set("Braintrust API") - description.set("API specification for the backend data server. The API is hosted globally at\nhttps://api.braintrustdata.com or in your own environment.\n\nYou can access the OpenAPI spec for this API at\nhttps://github.com/braintrustdata/braintrust-openapi.") + description.set("API specification for the backend data server. The API is hosted globally at\nhttps://api.braintrust.dev or in your own environment.\n\nYou can access the OpenAPI spec for this API at\nhttps://github.com/braintrustdata/braintrust-openapi.") url.set("https://www.braintrustdata.com/docs/api/spec") licenses { diff --git a/scripts/mock b/scripts/mock index fe89a1d..f586157 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" fi