From 1849200da79418f180ec435ef95625e34ba46987 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:27:02 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#56) --- .stats.yml | 2 +- README.md | 30 +- .../api/client/BraintrustClient.kt | 30 +- .../api/client/BraintrustClientAsync.kt | 30 +- .../api/client/BraintrustClientAsyncImpl.kt | 62 +- .../api/client/BraintrustClientImpl.kt | 66 +- .../braintrustdata/api/models/AclListPage.kt | 14 +- .../api/models/AclListPageAsync.kt | 14 +- .../api/models/AiSecretListPage.kt | 14 +- .../api/models/AiSecretListPageAsync.kt | 14 +- ...eCreateParams.kt => ApiKeyCreateParams.kt} | 46 +- ...eDeleteParams.kt => ApiKeyDeleteParams.kt} | 20 +- ...yResourceListPage.kt => ApiKeyListPage.kt} | 46 +- ...istPageAsync.kt => ApiKeyListPageAsync.kt} | 48 +- ...ourceListParams.kt => ApiKeyListParams.kt} | 28 +- ...rieveParams.kt => ApiKeyRetrieveParams.kt} | 18 +- .../api/models/DatasetListPage.kt | 14 +- .../api/models/DatasetListPageAsync.kt | 18 +- .../api/models/ExperimentListPage.kt | 14 +- .../api/models/ExperimentListPageAsync.kt | 14 +- .../com/braintrustdata/api/models/Function.kt | 1277 +++++--- .../api/models/FunctionCreateParams.kt | 1267 +++++--- .../api/models/FunctionInvokeParams.kt | 2661 ++++++++++++++++- .../api/models/FunctionListPage.kt | 14 +- .../api/models/FunctionListPageAsync.kt | 14 +- .../api/models/FunctionReplaceParams.kt | 1267 +++++--- .../api/models/FunctionUpdateParams.kt | 1121 ++++--- .../api/models/GroupListPage.kt | 14 +- .../api/models/GroupListPageAsync.kt | 14 +- .../api/models/OrganizationListPage.kt | 14 +- .../api/models/OrganizationListPageAsync.kt | 14 +- .../models/{ProjectModel.kt => Project.kt} | 32 +- .../api/models/ProjectListPage.kt | 34 +- .../api/models/ProjectListPageAsync.kt | 40 +- .../api/models/ProjectScoreListPage.kt | 14 +- .../api/models/ProjectScoreListPageAsync.kt | 14 +- .../api/models/ProjectTagListPage.kt | 14 +- .../api/models/ProjectTagListPageAsync.kt | 14 +- .../com/braintrustdata/api/models/Prompt.kt | 18 +- .../api/models/PromptCreateParams.kt | 18 +- .../braintrustdata/api/models/PromptData.kt | 474 ++- .../api/models/PromptListPage.kt | 14 +- .../api/models/PromptListPageAsync.kt | 14 +- .../api/models/PromptReplaceParams.kt | 18 +- .../braintrustdata/api/models/RoleListPage.kt | 14 +- .../api/models/RoleListPageAsync.kt | 14 +- .../braintrustdata/api/models/UserListPage.kt | 14 +- .../api/models/UserListPageAsync.kt | 14 +- .../braintrustdata/api/models/ViewListPage.kt | 14 +- .../api/models/ViewListPageAsync.kt | 14 +- ...eServiceAsync.kt => ApiKeyServiceAsync.kt} | 22 +- ...AsyncImpl.kt => ApiKeyServiceAsyncImpl.kt} | 30 +- .../async/OrganizationServiceAsync.kt | 2 +- .../async/OrganizationServiceAsyncImpl.kt | 4 +- .../api/services/async/ProjectServiceAsync.kt | 12 +- .../services/async/ProjectServiceAsyncImpl.kt | 30 +- .../MemberServiceAsync.kt | 2 +- .../MemberServiceAsyncImpl.kt | 2 +- .../{project => projects}/LogServiceAsync.kt | 2 +- .../LogServiceAsyncImpl.kt | 2 +- ...KeyResourceService.kt => ApiKeyService.kt} | 22 +- ...rceServiceImpl.kt => ApiKeyServiceImpl.kt} | 37 +- .../services/blocking/OrganizationService.kt | 2 +- .../blocking/OrganizationServiceImpl.kt | 4 +- .../api/services/blocking/ProjectService.kt | 12 +- .../services/blocking/ProjectServiceImpl.kt | 33 +- .../MemberService.kt | 2 +- .../MemberServiceImpl.kt | 2 +- .../{project => projects}/LogService.kt | 2 +- .../{project => projects}/LogServiceImpl.kt | 2 +- ...aramsTest.kt => ApiKeyCreateParamsTest.kt} | 10 +- ...aramsTest.kt => ApiKeyDeleteParamsTest.kt} | 12 +- ...tParamsTest.kt => ApiKeyListParamsTest.kt} | 19 +- ...amsTest.kt => ApiKeyRetrieveParamsTest.kt} | 12 +- .../api/models/FunctionCreateParamsTest.kt | 56 +- .../api/models/FunctionInvokeParamsTest.kt | 37 + .../api/models/FunctionReplaceParamsTest.kt | 56 +- .../braintrustdata/api/models/FunctionTest.kt | 38 +- .../api/models/FunctionUpdateParamsTest.kt | 30 + .../api/models/ProjectModelTest.kt | 35 - .../braintrustdata/api/models/ProjectTest.kt | 33 + .../api/models/PromptCreateParamsTest.kt | 36 +- .../api/models/PromptDataTest.kt | 19 + .../api/models/PromptReplaceParamsTest.kt | 36 +- .../braintrustdata/api/models/PromptTest.kt | 24 +- .../api/models/PromptUpdateParamsTest.kt | 30 + .../api/services/ErrorHandlingTest.kt | 26 +- .../api/services/ServiceParamsTest.kt | 6 +- .../api/services/blocking/AclServiceTest.kt | 12 +- .../services/blocking/AiSecretServiceTest.kt | 14 +- ...rceServiceTest.kt => ApiKeyServiceTest.kt} | 26 +- .../services/blocking/DatasetServiceTest.kt | 20 +- .../blocking/ExperimentServiceTest.kt | 20 +- .../services/blocking/FunctionServiceTest.kt | 72 +- .../api/services/blocking/GroupServiceTest.kt | 12 +- .../blocking/OrganizationServiceTest.kt | 8 +- .../blocking/ProjectScoreServiceTest.kt | 12 +- .../services/blocking/ProjectServiceTest.kt | 34 +- .../blocking/ProjectTagServiceTest.kt | 12 +- .../services/blocking/PromptServiceTest.kt | 46 +- .../api/services/blocking/RoleServiceTest.kt | 12 +- .../api/services/blocking/UserServiceTest.kt | 4 +- .../api/services/blocking/ViewServiceTest.kt | 12 +- .../MemberServiceTest.kt | 4 +- .../{project => projects}/LogServiceTest.kt | 10 +- 105 files changed, 7631 insertions(+), 2461 deletions(-) rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{ApiKeyResourceCreateParams.kt => ApiKeyCreateParams.kt} (84%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{ApiKeyResourceDeleteParams.kt => ApiKeyDeleteParams.kt} (86%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{ApiKeyResourceListPage.kt => ApiKeyListPage.kt} (76%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{ApiKeyResourceListPageAsync.kt => ApiKeyListPageAsync.kt} (76%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{ApiKeyResourceListParams.kt => ApiKeyListParams.kt} (91%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{ApiKeyResourceRetrieveParams.kt => ApiKeyRetrieveParams.kt} (85%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{ProjectModel.kt => Project.kt} (92%) rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/{ApiKeyResourceServiceAsync.kt => ApiKeyServiceAsync.kt} (68%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/{ApiKeyResourceServiceAsyncImpl.kt => ApiKeyServiceAsyncImpl.kt} (86%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/{organization => organizations}/MemberServiceAsync.kt (91%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/{organization => organizations}/MemberServiceAsyncImpl.kt (97%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/{project => projects}/LogServiceAsync.kt (97%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/{project => projects}/LogServiceAsyncImpl.kt (99%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/{ApiKeyResourceService.kt => ApiKeyService.kt} (67%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/{ApiKeyResourceServiceImpl.kt => ApiKeyServiceImpl.kt} (83%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/{organization => organizations}/MemberService.kt (90%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/{organization => organizations}/MemberServiceImpl.kt (97%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/{project => projects}/LogService.kt (96%) mode change 100755 => 100644 rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/{project => projects}/LogServiceImpl.kt (99%) mode change 100755 => 100644 rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/{ApiKeyResourceCreateParamsTest.kt => ApiKeyCreateParamsTest.kt} (64%) mode change 100755 => 100644 rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/{ApiKeyResourceDeleteParamsTest.kt => ApiKeyDeleteParamsTest.kt} (61%) mode change 100755 => 100644 rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/{ApiKeyResourceListParamsTest.kt => ApiKeyListParamsTest.kt} (72%) mode change 100755 => 100644 rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/{ApiKeyResourceRetrieveParamsTest.kt => ApiKeyRetrieveParamsTest.kt} (60%) mode change 100755 => 100644 delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectModelTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/{ApiKeyResourceServiceTest.kt => ApiKeyServiceTest.kt} (70%) mode change 100755 => 100644 rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/{organization => organizations}/MemberServiceTest.kt (93%) mode change 100755 => 100644 rename braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/{project => projects}/LogServiceTest.kt (96%) mode change 100755 => 100644 diff --git a/.stats.yml b/.stats.yml index fb939f9..ec9fdac 100755 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 97 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-35ca662bf69021273747db3b70d40b924819af0f6e01b38001c7c1ae2f8a4712.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-dd60fe261caab803c127a0f29cadcab5f1956be0a5a265100476b972b4b5b62e.yml diff --git a/README.md b/README.md index c5a997c..0120811 100755 --- a/README.md +++ b/README.md @@ -69,29 +69,29 @@ Read the documentation for more configuration options. ### Example: creating a resource To create a new project, first use the `ProjectCreateParams` builder to specify attributes, -then pass that to the `create` method of the `project` service. +then pass that to the `create` method of the `projects` service. ```java +import com.braintrustdata.api.models.Project; import com.braintrustdata.api.models.ProjectCreateParams; -import com.braintrustdata.api.models.ProjectModel; ProjectCreateParams params = ProjectCreateParams.builder() .name("foobar") .build(); -ProjectModel projectModel = client.project().create(params); +Project project = client.projects().create(params); ``` ### Example: listing resources -The Braintrust API provides a `list` method to get a paginated list of project. +The Braintrust API provides a `list` method to get a paginated list of projects. You can retrieve the first page by: ```java import com.braintrustdata.api.models.Page; -import com.braintrustdata.api.models.ProjectModel; +import com.braintrustdata.api.models.Project; -ProjectListPage page = client.project().list(); -for (ProjectModel project : page.objects()) { +ProjectListPage page = client.projects().list(); +for (Project project : page.objects()) { System.out.println(project); } ``` @@ -107,7 +107,7 @@ See [Pagination](#pagination) below for more information on transparently workin To make a request to the Braintrust API, you generally build an instance of the appropriate `Params` class. In [Example: creating a resource](#example-creating-a-resource) above, we used the `ProjectCreateParams.builder()` to pass to -the `create` method of the `project` service. +the `create` method of the `projects` service. Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using the `putAdditionalProperty` method. @@ -127,7 +127,7 @@ ProjectCreateParams params = ProjectCreateParams.builder() When receiving a response, the Braintrust Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `BraintrustInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model. ```java -ProjectModel projectModel = client.project().create().validate(); +Project project = client.projects().create().validate(); ``` ### Response properties as JSON @@ -176,13 +176,13 @@ which automatically handles fetching more pages for you: ```java // As an Iterable: -ProjectListPage page = client.project().list(params); -for (ProjectModel project : page.autoPager()) { +ProjectListPage page = client.projects().list(params); +for (Project project : page.autoPager()) { System.out.println(project); }; // As a Stream: -client.project().list(params).autoPager().stream() +client.projects().list(params).autoPager().stream() .limit(50) .forEach(project -> System.out.println(project)); ``` @@ -191,7 +191,7 @@ client.project().list(params).autoPager().stream() ```java // Using forEach, which returns CompletableFuture: -asyncClient.project().list(params).autoPager() +asyncClient.projects().list(params).autoPager() .forEach(project -> System.out.println(project), executor); ``` @@ -203,9 +203,9 @@ A page of results has a `data()` method to fetch the list of objects, as well as `hasNextPage`, `getNextPage`, and `getNextPageParams` methods to help with pagination. ```java -ProjectListPage page = client.project().list(params); +ProjectListPage page = client.projects().list(params); while (page != null) { - for (ProjectModel project : page.objects()) { + for (Project project : page.objects()) { System.out.println(project); } 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 f48c8d0..a8e2bda 100755 --- 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 @@ -13,33 +13,33 @@ interface BraintrustClient { fun topLevel(): TopLevelService - fun project(): ProjectService + fun projects(): ProjectService - fun experiment(): ExperimentService + fun experiments(): ExperimentService - fun dataset(): DatasetService + fun datasets(): DatasetService - fun prompt(): PromptService + fun prompts(): PromptService - fun role(): RoleService + fun roles(): RoleService - fun group(): GroupService + fun groups(): GroupService - fun acl(): AclService + fun acls(): AclService - fun user(): UserService + fun users(): UserService - fun projectScore(): ProjectScoreService + fun projectScores(): ProjectScoreService - fun projectTag(): ProjectTagService + fun projectTags(): ProjectTagService - fun function(): FunctionService + fun functions(): FunctionService - fun view(): ViewService + fun views(): ViewService - fun organization(): OrganizationService + fun organizations(): OrganizationService - fun apiKeyResource(): ApiKeyResourceService + fun apiKeys(): ApiKeyService - fun aiSecret(): AiSecretService + fun aiSecrets(): AiSecretService } 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 a5873b1..06b2a25 100755 --- 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 @@ -13,33 +13,33 @@ interface BraintrustClientAsync { fun topLevel(): TopLevelServiceAsync - fun project(): ProjectServiceAsync + fun projects(): ProjectServiceAsync - fun experiment(): ExperimentServiceAsync + fun experiments(): ExperimentServiceAsync - fun dataset(): DatasetServiceAsync + fun datasets(): DatasetServiceAsync - fun prompt(): PromptServiceAsync + fun prompts(): PromptServiceAsync - fun role(): RoleServiceAsync + fun roles(): RoleServiceAsync - fun group(): GroupServiceAsync + fun groups(): GroupServiceAsync - fun acl(): AclServiceAsync + fun acls(): AclServiceAsync - fun user(): UserServiceAsync + fun users(): UserServiceAsync - fun projectScore(): ProjectScoreServiceAsync + fun projectScores(): ProjectScoreServiceAsync - fun projectTag(): ProjectTagServiceAsync + fun projectTags(): ProjectTagServiceAsync - fun function(): FunctionServiceAsync + fun functions(): FunctionServiceAsync - fun view(): ViewServiceAsync + fun views(): ViewServiceAsync - fun organization(): OrganizationServiceAsync + fun organizations(): OrganizationServiceAsync - fun apiKeyResource(): ApiKeyResourceServiceAsync + fun apiKeys(): ApiKeyServiceAsync - fun aiSecret(): AiSecretServiceAsync + fun aiSecrets(): AiSecretServiceAsync } 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 113a10d..52440ba 100755 --- 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 @@ -20,77 +20,75 @@ constructor( private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptions) } - private val project: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) } + private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) } - private val experiment: ExperimentServiceAsync by lazy { + private val experiments: ExperimentServiceAsync by lazy { ExperimentServiceAsyncImpl(clientOptions) } - private val dataset: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } + private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } - private val prompt: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptions) } + private val prompts: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptions) } - private val role: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) } + private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) } - private val group: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) } + private val groups: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) } - private val acl: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptions) } + private val acls: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptions) } - private val user: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptions) } + private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptions) } - private val projectScore: ProjectScoreServiceAsync by lazy { + private val projectScores: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptions) } - private val projectTag: ProjectTagServiceAsync by lazy { + private val projectTags: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptions) } - private val function: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptions) } + private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptions) } - private val view: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptions) } + private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptions) } - private val organization: OrganizationServiceAsync by lazy { + private val organizations: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptions) } - private val apiKeyResource: ApiKeyResourceServiceAsync by lazy { - ApiKeyResourceServiceAsyncImpl(clientOptions) - } + private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptions) } - private val aiSecret: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptions) } + private val aiSecrets: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptions) } override fun sync(): BraintrustClient = sync override fun topLevel(): TopLevelServiceAsync = topLevel - override fun project(): ProjectServiceAsync = project + override fun projects(): ProjectServiceAsync = projects - override fun experiment(): ExperimentServiceAsync = experiment + override fun experiments(): ExperimentServiceAsync = experiments - override fun dataset(): DatasetServiceAsync = dataset + override fun datasets(): DatasetServiceAsync = datasets - override fun prompt(): PromptServiceAsync = prompt + override fun prompts(): PromptServiceAsync = prompts - override fun role(): RoleServiceAsync = role + override fun roles(): RoleServiceAsync = roles - override fun group(): GroupServiceAsync = group + override fun groups(): GroupServiceAsync = groups - override fun acl(): AclServiceAsync = acl + override fun acls(): AclServiceAsync = acls - override fun user(): UserServiceAsync = user + override fun users(): UserServiceAsync = users - override fun projectScore(): ProjectScoreServiceAsync = projectScore + override fun projectScores(): ProjectScoreServiceAsync = projectScores - override fun projectTag(): ProjectTagServiceAsync = projectTag + override fun projectTags(): ProjectTagServiceAsync = projectTags - override fun function(): FunctionServiceAsync = function + override fun functions(): FunctionServiceAsync = functions - override fun view(): ViewServiceAsync = view + override fun views(): ViewServiceAsync = views - override fun organization(): OrganizationServiceAsync = organization + override fun organizations(): OrganizationServiceAsync = organizations - override fun apiKeyResource(): ApiKeyResourceServiceAsync = apiKeyResource + override fun apiKeys(): ApiKeyServiceAsync = apiKeys - override fun aiSecret(): AiSecretServiceAsync = aiSecret + override fun aiSecrets(): AiSecretServiceAsync = aiSecrets } 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 c0d3cbe..7f8b705 100755 --- 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 @@ -20,69 +20,71 @@ constructor( private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptions) } - private val project: ProjectService by lazy { ProjectServiceImpl(clientOptions) } + private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptions) } - private val experiment: ExperimentService by lazy { ExperimentServiceImpl(clientOptions) } + private val experiments: ExperimentService by lazy { ExperimentServiceImpl(clientOptions) } - private val dataset: DatasetService by lazy { DatasetServiceImpl(clientOptions) } + private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptions) } - private val prompt: PromptService by lazy { PromptServiceImpl(clientOptions) } + private val prompts: PromptService by lazy { PromptServiceImpl(clientOptions) } - private val role: RoleService by lazy { RoleServiceImpl(clientOptions) } + private val roles: RoleService by lazy { RoleServiceImpl(clientOptions) } - private val group: GroupService by lazy { GroupServiceImpl(clientOptions) } + private val groups: GroupService by lazy { GroupServiceImpl(clientOptions) } - private val acl: AclService by lazy { AclServiceImpl(clientOptions) } + private val acls: AclService by lazy { AclServiceImpl(clientOptions) } - private val user: UserService by lazy { UserServiceImpl(clientOptions) } + private val users: UserService by lazy { UserServiceImpl(clientOptions) } - private val projectScore: ProjectScoreService by lazy { ProjectScoreServiceImpl(clientOptions) } - - private val projectTag: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptions) } + private val projectScores: ProjectScoreService by lazy { + ProjectScoreServiceImpl(clientOptions) + } - private val function: FunctionService by lazy { FunctionServiceImpl(clientOptions) } + private val projectTags: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptions) } - private val view: ViewService by lazy { ViewServiceImpl(clientOptions) } + private val functions: FunctionService by lazy { FunctionServiceImpl(clientOptions) } - private val organization: OrganizationService by lazy { OrganizationServiceImpl(clientOptions) } + private val views: ViewService by lazy { ViewServiceImpl(clientOptions) } - private val apiKeyResource: ApiKeyResourceService by lazy { - ApiKeyResourceServiceImpl(clientOptions) + private val organizations: OrganizationService by lazy { + OrganizationServiceImpl(clientOptions) } - private val aiSecret: AiSecretService by lazy { AiSecretServiceImpl(clientOptions) } + private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptions) } + + private val aiSecrets: AiSecretService by lazy { AiSecretServiceImpl(clientOptions) } override fun async(): BraintrustClientAsync = async override fun topLevel(): TopLevelService = topLevel - override fun project(): ProjectService = project + override fun projects(): ProjectService = projects - override fun experiment(): ExperimentService = experiment + override fun experiments(): ExperimentService = experiments - override fun dataset(): DatasetService = dataset + override fun datasets(): DatasetService = datasets - override fun prompt(): PromptService = prompt + override fun prompts(): PromptService = prompts - override fun role(): RoleService = role + override fun roles(): RoleService = roles - override fun group(): GroupService = group + override fun groups(): GroupService = groups - override fun acl(): AclService = acl + override fun acls(): AclService = acls - override fun user(): UserService = user + override fun users(): UserService = users - override fun projectScore(): ProjectScoreService = projectScore + override fun projectScores(): ProjectScoreService = projectScores - override fun projectTag(): ProjectTagService = projectTag + override fun projectTags(): ProjectTagService = projectTags - override fun function(): FunctionService = function + override fun functions(): FunctionService = functions - override fun view(): ViewService = view + override fun views(): ViewService = views - override fun organization(): OrganizationService = organization + override fun organizations(): OrganizationService = organizations - override fun apiKeyResource(): ApiKeyResourceService = apiKeyResource + override fun apiKeys(): ApiKeyService = apiKeys - override fun aiSecret(): AiSecretService = aiSecret + override fun aiSecrets(): AiSecretService = aiSecrets } 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 97c29ff..b3c8096 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class AclListPage private constructor( - private val aclService: AclService, + private val aclsService: AclService, private val params: AclListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is AclListPage && - this.aclService == other.aclService && + this.aclsService == other.aclsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - aclService, + aclsService, params, response, ) } override fun toString() = - "AclListPage{aclService=$aclService, params=$params, response=$response}" + "AclListPage{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -72,7 +72,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { aclService.list(it) } + return getNextPageParams().map { aclsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,9 +80,9 @@ private constructor( companion object { @JvmStatic - fun of(aclService: AclService, params: AclListParams, response: Response) = + fun of(aclsService: AclService, params: AclListParams, response: Response) = AclListPage( - aclService, + aclsService, params, response, ) 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 4c29b84..ec02e5b 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class AclListPageAsync private constructor( - private val aclService: AclServiceAsync, + private val aclsService: AclServiceAsync, private val params: AclListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is AclListPageAsync && - this.aclService == other.aclService && + this.aclsService == other.aclsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - aclService, + aclsService, params, response, ) } override fun toString() = - "AclListPageAsync{aclService=$aclService, params=$params, response=$response}" + "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -74,7 +74,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { aclService.list(it).thenApply { Optional.of(it) } } + .map { aclsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -83,9 +83,9 @@ private constructor( companion object { @JvmStatic - fun of(aclService: AclServiceAsync, params: AclListParams, response: Response) = + fun of(aclsService: AclServiceAsync, params: AclListParams, response: Response) = AclListPageAsync( - aclService, + aclsService, params, response, ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index d5bdbba..2adbb61 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class AiSecretListPage private constructor( - private val aiSecretService: AiSecretService, + private val aiSecretsService: AiSecretService, private val params: AiSecretListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is AiSecretListPage && - this.aiSecretService == other.aiSecretService && + this.aiSecretsService == other.aiSecretsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - aiSecretService, + aiSecretsService, params, response, ) } override fun toString() = - "AiSecretListPage{aiSecretService=$aiSecretService, params=$params, response=$response}" + "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { aiSecretService.list(it) } + return getNextPageParams().map { aiSecretsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,9 +86,9 @@ private constructor( companion object { @JvmStatic - fun of(aiSecretService: AiSecretService, params: AiSecretListParams, response: Response) = + fun of(aiSecretsService: AiSecretService, params: AiSecretListParams, response: Response) = AiSecretListPage( - aiSecretService, + aiSecretsService, params, response, ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 4febf7e..af3a136 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -21,7 +21,7 @@ import java.util.function.Predicate class AiSecretListPageAsync private constructor( - private val aiSecretService: AiSecretServiceAsync, + private val aiSecretsService: AiSecretServiceAsync, private val params: AiSecretListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is AiSecretListPageAsync && - this.aiSecretService == other.aiSecretService && + this.aiSecretsService == other.aiSecretsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - aiSecretService, + aiSecretsService, params, response, ) } override fun toString() = - "AiSecretListPageAsync{aiSecretService=$aiSecretService, params=$params, response=$response}" + "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { aiSecretService.list(it).thenApply { Optional.of(it) } } + .map { aiSecretsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -90,12 +90,12 @@ private constructor( @JvmStatic fun of( - aiSecretService: AiSecretServiceAsync, + aiSecretsService: AiSecretServiceAsync, params: AiSecretListParams, response: Response ) = AiSecretListPageAsync( - aiSecretService, + aiSecretsService, params, response, ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt old mode 100755 new mode 100644 similarity index 84% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParams.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 277684d..e5d0f3b --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -14,7 +14,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -class ApiKeyResourceCreateParams +class ApiKeyCreateParams constructor( private val name: String, private val orgName: String?, @@ -28,8 +28,8 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) @JvmSynthetic - internal fun getBody(): ApiKeyResourceCreateBody { - return ApiKeyResourceCreateBody( + internal fun getBody(): ApiKeyCreateBody { + return ApiKeyCreateBody( name, orgName, additionalBodyProperties, @@ -40,9 +40,9 @@ constructor( @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - @JsonDeserialize(builder = ApiKeyResourceCreateBody.Builder::class) + @JsonDeserialize(builder = ApiKeyCreateBody.Builder::class) @NoAutoDetect - class ApiKeyResourceCreateBody + class ApiKeyCreateBody internal constructor( private val name: String?, private val orgName: String?, @@ -72,7 +72,7 @@ constructor( return true } - return other is ApiKeyResourceCreateBody && + return other is ApiKeyCreateBody && this.name == other.name && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties @@ -91,7 +91,7 @@ constructor( } override fun toString() = - "ApiKeyResourceCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { @@ -105,10 +105,10 @@ constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyResourceCreateBody: ApiKeyResourceCreateBody) = apply { - this.name = apiKeyResourceCreateBody.name - this.orgName = apiKeyResourceCreateBody.orgName - additionalProperties(apiKeyResourceCreateBody.additionalProperties) + internal fun from(apiKeyCreateBody: ApiKeyCreateBody) = apply { + this.name = apiKeyCreateBody.name + this.orgName = apiKeyCreateBody.orgName + additionalProperties(apiKeyCreateBody.additionalProperties) } /** Name of the api key. Does not have to be unique */ @@ -136,8 +136,8 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ApiKeyResourceCreateBody = - ApiKeyResourceCreateBody( + fun build(): ApiKeyCreateBody = + ApiKeyCreateBody( checkNotNull(name) { "`name` is required but was not set" }, orgName, additionalProperties.toUnmodifiable(), @@ -156,7 +156,7 @@ constructor( return true } - return other is ApiKeyResourceCreateParams && + return other is ApiKeyCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && @@ -175,7 +175,7 @@ constructor( } override fun toString() = - "ApiKeyResourceCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -194,12 +194,12 @@ constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyResourceCreateParams: ApiKeyResourceCreateParams) = apply { - this.name = apiKeyResourceCreateParams.name - this.orgName = apiKeyResourceCreateParams.orgName - additionalQueryParams(apiKeyResourceCreateParams.additionalQueryParams) - additionalHeaders(apiKeyResourceCreateParams.additionalHeaders) - additionalBodyProperties(apiKeyResourceCreateParams.additionalBodyProperties) + internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { + this.name = apiKeyCreateParams.name + this.orgName = apiKeyCreateParams.orgName + additionalQueryParams(apiKeyCreateParams.additionalQueryParams) + additionalHeaders(apiKeyCreateParams.additionalHeaders) + additionalBodyProperties(apiKeyCreateParams.additionalBodyProperties) } /** Name of the api key. Does not have to be unique */ @@ -266,8 +266,8 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun build(): ApiKeyResourceCreateParams = - ApiKeyResourceCreateParams( + fun build(): ApiKeyCreateParams = + ApiKeyCreateParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt old mode 100755 new mode 100644 similarity index 86% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParams.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index d09a829..8b48e6d --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -9,7 +9,7 @@ import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional -class ApiKeyResourceDeleteParams +class ApiKeyDeleteParams constructor( private val apiKeyId: String, private val additionalQueryParams: Map>, @@ -46,7 +46,7 @@ constructor( return true } - return other is ApiKeyResourceDeleteParams && + return other is ApiKeyDeleteParams && this.apiKeyId == other.apiKeyId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && @@ -63,7 +63,7 @@ constructor( } override fun toString() = - "ApiKeyResourceDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -81,11 +81,11 @@ constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyResourceDeleteParams: ApiKeyResourceDeleteParams) = apply { - this.apiKeyId = apiKeyResourceDeleteParams.apiKeyId - additionalQueryParams(apiKeyResourceDeleteParams.additionalQueryParams) - additionalHeaders(apiKeyResourceDeleteParams.additionalHeaders) - additionalBodyProperties(apiKeyResourceDeleteParams.additionalBodyProperties) + internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { + this.apiKeyId = apiKeyDeleteParams.apiKeyId + additionalQueryParams(apiKeyDeleteParams.additionalQueryParams) + additionalHeaders(apiKeyDeleteParams.additionalHeaders) + additionalBodyProperties(apiKeyDeleteParams.additionalBodyProperties) } /** ApiKey id */ @@ -145,8 +145,8 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun build(): ApiKeyResourceDeleteParams = - ApiKeyResourceDeleteParams( + 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(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt old mode 100755 new mode 100644 similarity index 76% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPage.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index f0d42d8..6369da7 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -8,7 +8,7 @@ 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.ApiKeyResourceService +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 @@ -18,10 +18,10 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport -class ApiKeyResourceListPage +class ApiKeyListPage private constructor( - private val apiKeyResourceService: ApiKeyResourceService, - private val params: ApiKeyResourceListParams, + private val apiKeysService: ApiKeyService, + private val params: ApiKeyListParams, private val response: Response, ) { @@ -34,51 +34,45 @@ private constructor( return true } - return other is ApiKeyResourceListPage && - this.apiKeyResourceService == other.apiKeyResourceService && + return other is ApiKeyListPage && + this.apiKeysService == other.apiKeysService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - apiKeyResourceService, + apiKeysService, params, response, ) } override fun toString() = - "ApiKeyResourceListPage{apiKeyResourceService=$apiKeyResourceService, params=$params, response=$response}" + "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() } - fun getNextPageParams(): Optional { + fun getNextPageParams(): Optional { if (!hasNextPage()) { return Optional.empty() } return if (params.endingBefore().isPresent) { Optional.of( - ApiKeyResourceListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() + ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() ) } else { Optional.of( - ApiKeyResourceListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() + ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() ) } } - fun getNextPage(): Optional { - return getNextPageParams().map { apiKeyResourceService.list(it) } + fun getNextPage(): Optional { + return getNextPageParams().map { apiKeysService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,13 +80,9 @@ private constructor( companion object { @JvmStatic - fun of( - apiKeyResourceService: ApiKeyResourceService, - params: ApiKeyResourceListParams, - response: Response - ) = - ApiKeyResourceListPage( - apiKeyResourceService, + fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = + ApiKeyListPage( + apiKeysService, params, response, ) @@ -141,7 +131,7 @@ private constructor( } override fun toString() = - "ApiKeyResourceListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "ApiKeyListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -175,7 +165,7 @@ private constructor( class AutoPager constructor( - private val firstPage: ApiKeyResourceListPage, + private val firstPage: ApiKeyListPage, ) : Iterable { override fun iterator(): Iterator = iterator { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt old mode 100755 new mode 100644 similarity index 76% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPageAsync.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index c777ad6..d874255 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -8,7 +8,7 @@ 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.ApiKeyResourceServiceAsync +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 @@ -19,10 +19,10 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -class ApiKeyResourceListPageAsync +class ApiKeyListPageAsync private constructor( - private val apiKeyResourceService: ApiKeyResourceServiceAsync, - private val params: ApiKeyResourceListParams, + private val apiKeysService: ApiKeyServiceAsync, + private val params: ApiKeyListParams, private val response: Response, ) { @@ -35,52 +35,46 @@ private constructor( return true } - return other is ApiKeyResourceListPageAsync && - this.apiKeyResourceService == other.apiKeyResourceService && + return other is ApiKeyListPageAsync && + this.apiKeysService == other.apiKeysService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - apiKeyResourceService, + apiKeysService, params, response, ) } override fun toString() = - "ApiKeyResourceListPageAsync{apiKeyResourceService=$apiKeyResourceService, params=$params, response=$response}" + "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() } - fun getNextPageParams(): Optional { + fun getNextPageParams(): Optional { if (!hasNextPage()) { return Optional.empty() } return if (params.endingBefore().isPresent) { Optional.of( - ApiKeyResourceListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() + ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() ) } else { Optional.of( - ApiKeyResourceListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() + ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() ) } } - fun getNextPage(): CompletableFuture> { + fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { apiKeyResourceService.list(it).thenApply { Optional.of(it) } } + .map { apiKeysService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -89,13 +83,9 @@ private constructor( companion object { @JvmStatic - fun of( - apiKeyResourceService: ApiKeyResourceServiceAsync, - params: ApiKeyResourceListParams, - response: Response - ) = - ApiKeyResourceListPageAsync( - apiKeyResourceService, + fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = + ApiKeyListPageAsync( + apiKeysService, params, response, ) @@ -144,7 +134,7 @@ private constructor( } override fun toString() = - "ApiKeyResourceListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "ApiKeyListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -178,11 +168,11 @@ private constructor( class AutoPager constructor( - private val firstPage: ApiKeyResourceListPageAsync, + private val firstPage: ApiKeyListPageAsync, ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( + fun CompletableFuture>.forEach( action: (ApiKey) -> Boolean, executor: Executor ): CompletableFuture = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt old mode 100755 new mode 100644 similarity index 91% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParams.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 98f3587..dbaf434 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -20,7 +20,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional -class ApiKeyResourceListParams +class ApiKeyListParams constructor( private val apiKeyName: String?, private val endingBefore: String?, @@ -68,7 +68,7 @@ constructor( return true } - return other is ApiKeyResourceListParams && + return other is ApiKeyListParams && this.apiKeyName == other.apiKeyName && this.endingBefore == other.endingBefore && this.ids == other.ids && @@ -93,7 +93,7 @@ constructor( } override fun toString() = - "ApiKeyResourceListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -115,15 +115,15 @@ constructor( private var additionalHeaders: MutableMap> = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyResourceListParams: ApiKeyResourceListParams) = apply { - this.apiKeyName = apiKeyResourceListParams.apiKeyName - this.endingBefore = apiKeyResourceListParams.endingBefore - this.ids = apiKeyResourceListParams.ids - this.limit = apiKeyResourceListParams.limit - this.orgName = apiKeyResourceListParams.orgName - this.startingAfter = apiKeyResourceListParams.startingAfter - additionalQueryParams(apiKeyResourceListParams.additionalQueryParams) - additionalHeaders(apiKeyResourceListParams.additionalHeaders) + internal fun from(apiKeyListParams: ApiKeyListParams) = apply { + this.apiKeyName = apiKeyListParams.apiKeyName + this.endingBefore = apiKeyListParams.endingBefore + this.ids = apiKeyListParams.ids + this.limit = apiKeyListParams.limit + this.orgName = apiKeyListParams.orgName + this.startingAfter = apiKeyListParams.startingAfter + additionalQueryParams(apiKeyListParams.additionalQueryParams) + additionalHeaders(apiKeyListParams.additionalHeaders) } /** Name of the api_key to search for */ @@ -211,8 +211,8 @@ constructor( fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - fun build(): ApiKeyResourceListParams = - ApiKeyResourceListParams( + fun build(): ApiKeyListParams = + ApiKeyListParams( apiKeyName, endingBefore, ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt old mode 100755 new mode 100644 similarity index 85% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParams.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 35f91e8..836fb6f --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.toUnmodifiable import com.braintrustdata.api.models.* import java.util.Objects -class ApiKeyResourceRetrieveParams +class ApiKeyRetrieveParams constructor( private val apiKeyId: String, private val additionalQueryParams: Map>, @@ -36,7 +36,7 @@ constructor( return true } - return other is ApiKeyResourceRetrieveParams && + return other is ApiKeyRetrieveParams && this.apiKeyId == other.apiKeyId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders @@ -51,7 +51,7 @@ constructor( } override fun toString() = - "ApiKeyResourceRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -68,10 +68,10 @@ constructor( private var additionalHeaders: MutableMap> = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyResourceRetrieveParams: ApiKeyResourceRetrieveParams) = apply { - this.apiKeyId = apiKeyResourceRetrieveParams.apiKeyId - additionalQueryParams(apiKeyResourceRetrieveParams.additionalQueryParams) - additionalHeaders(apiKeyResourceRetrieveParams.additionalHeaders) + internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { + this.apiKeyId = apiKeyRetrieveParams.apiKeyId + additionalQueryParams(apiKeyRetrieveParams.additionalQueryParams) + additionalHeaders(apiKeyRetrieveParams.additionalHeaders) } /** ApiKey id */ @@ -117,8 +117,8 @@ constructor( fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - fun build(): ApiKeyResourceRetrieveParams = - ApiKeyResourceRetrieveParams( + 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(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 0e34b80..5ad3404 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class DatasetListPage private constructor( - private val datasetService: DatasetService, + private val datasetsService: DatasetService, private val params: DatasetListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is DatasetListPage && - this.datasetService == other.datasetService && + this.datasetsService == other.datasetsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - datasetService, + datasetsService, params, response, ) } override fun toString() = - "DatasetListPage{datasetService=$datasetService, params=$params, response=$response}" + "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { datasetService.list(it) } + return getNextPageParams().map { datasetsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,9 +86,9 @@ private constructor( companion object { @JvmStatic - fun of(datasetService: DatasetService, params: DatasetListParams, response: Response) = + fun of(datasetsService: DatasetService, params: DatasetListParams, response: Response) = DatasetListPage( - datasetService, + datasetsService, params, response, ) 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 3969867..ab1096f 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class DatasetListPageAsync private constructor( - private val datasetService: DatasetServiceAsync, + private val datasetsService: DatasetServiceAsync, private val params: DatasetListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is DatasetListPageAsync && - this.datasetService == other.datasetService && + this.datasetsService == other.datasetsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - datasetService, + datasetsService, params, response, ) } override fun toString() = - "DatasetListPageAsync{datasetService=$datasetService, params=$params, response=$response}" + "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { datasetService.list(it).thenApply { Optional.of(it) } } + .map { datasetsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -89,9 +89,13 @@ private constructor( companion object { @JvmStatic - fun of(datasetService: DatasetServiceAsync, params: DatasetListParams, response: Response) = + fun of( + datasetsService: DatasetServiceAsync, + params: DatasetListParams, + response: Response + ) = DatasetListPageAsync( - datasetService, + datasetsService, params, response, ) 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 4af7988..18eb99a 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class ExperimentListPage private constructor( - private val experimentService: ExperimentService, + private val experimentsService: ExperimentService, private val params: ExperimentListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is ExperimentListPage && - this.experimentService == other.experimentService && + this.experimentsService == other.experimentsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - experimentService, + experimentsService, params, response, ) } override fun toString() = - "ExperimentListPage{experimentService=$experimentService, params=$params, response=$response}" + "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { experimentService.list(it) } + return getNextPageParams().map { experimentsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -87,12 +87,12 @@ private constructor( @JvmStatic fun of( - experimentService: ExperimentService, + experimentsService: ExperimentService, params: ExperimentListParams, response: Response ) = ExperimentListPage( - experimentService, + experimentsService, params, response, ) 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 c195d45..2b5d3b7 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class ExperimentListPageAsync private constructor( - private val experimentService: ExperimentServiceAsync, + private val experimentsService: ExperimentServiceAsync, private val params: ExperimentListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is ExperimentListPageAsync && - this.experimentService == other.experimentService && + this.experimentsService == other.experimentsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - experimentService, + experimentsService, params, response, ) } override fun toString() = - "ExperimentListPageAsync{experimentService=$experimentService, params=$params, response=$response}" + "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { experimentService.list(it).thenApply { Optional.of(it) } } + .map { experimentsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -90,12 +90,12 @@ private constructor( @JvmStatic fun of( - experimentService: ExperimentServiceAsync, + experimentsService: ExperimentServiceAsync, params: ExperimentListParams, response: Response ) = ExperimentListPageAsync( - experimentService, + experimentsService, params, response, ) 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 74535f3..3460ba4 100755 --- 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 @@ -47,6 +47,7 @@ private constructor( private val functionType: JsonField, private val functionData: JsonField, private val origin: JsonField, + private val functionSchema: JsonField, private val additionalProperties: Map, ) { @@ -103,6 +104,10 @@ private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** JSON schema for the function's parameters and return type */ + fun functionSchema(): Optional = + Optional.ofNullable(functionSchema.getNullable("function_schema")) + /** Unique identifier for the prompt */ @JsonProperty("id") @ExcludeMissing fun _id() = id @@ -149,6 +154,9 @@ private constructor( @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + /** JSON schema for the function's parameters and return type */ + @JsonProperty("function_schema") @ExcludeMissing fun _functionSchema() = functionSchema + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -170,6 +178,7 @@ private constructor( functionType() functionData() origin().map { it.validate() } + functionSchema().map { it.validate() } validated = true } } @@ -197,6 +206,7 @@ private constructor( this.functionType == other.functionType && this.functionData == other.functionData && this.origin == other.origin && + this.functionSchema == other.functionSchema && this.additionalProperties == other.additionalProperties } @@ -219,6 +229,7 @@ private constructor( functionType, functionData, origin, + functionSchema, additionalProperties, ) } @@ -226,7 +237,7 @@ private constructor( } 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, functionType=$functionType, functionData=$functionData, origin=$origin, additionalProperties=$additionalProperties}" + "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, functionType=$functionType, functionData=$functionData, origin=$origin, functionSchema=$functionSchema, additionalProperties=$additionalProperties}" companion object { @@ -250,6 +261,7 @@ private constructor( private var functionType: JsonField = JsonMissing.of() private var functionData: JsonField = JsonMissing.of() private var origin: JsonField = JsonMissing.of() + private var functionSchema: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -269,6 +281,7 @@ private constructor( this.functionType = function.functionType this.functionData = function.functionData this.origin = function.origin + this.functionSchema = function.functionSchema additionalProperties(function.additionalProperties) } @@ -396,6 +409,17 @@ private constructor( @ExcludeMissing fun origin(origin: JsonField) = apply { this.origin = origin } + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema) = + functionSchema(JsonField.of(functionSchema)) + + /** JSON schema for the function's parameters and return type */ + @JsonProperty("function_schema") + @ExcludeMissing + fun functionSchema(functionSchema: JsonField) = apply { + this.functionSchema = functionSchema + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -427,6 +451,7 @@ private constructor( functionType, functionData, origin, + functionSchema, additionalProperties.toUnmodifiable(), ) } @@ -996,7 +1021,7 @@ private constructor( if (!validated) { type() runtimeContext().validate() - location().validate() + location() bundleId() preview() validated = true @@ -1127,646 +1152,957 @@ private constructor( ) } - @JsonDeserialize(builder = Location.Builder::class) - @NoAutoDetect + @JsonDeserialize(using = Location.Deserializer::class) + @JsonSerialize(using = Location.Serializer::class) class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + private val experiment: Experiment? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun experiment(): Optional = Optional.ofNullable(experiment) - fun type(): Type = type.getRequired("type") + fun function(): Optional = Optional.ofNullable(function) - fun evalName(): String = evalName.getRequired("eval_name") + fun isExperiment(): Boolean = experiment != null - fun position(): Position = position.getRequired("position") + fun isFunction(): Boolean = function != null - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun asExperiment(): Experiment = experiment.getOrThrow("experiment") - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + fun asFunction(): Function = function.getOrThrow("function") - @JsonProperty("position") @ExcludeMissing fun _position() = position + fun _json(): Optional = Optional.ofNullable(_json) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun accept(visitor: Visitor): T { + return when { + experiment != null -> visitor.visitExperiment(experiment) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() + if (experiment == null && function == null) { + throw BraintrustInvalidDataException("Unknown Location: $_json") + } + experiment?.validate() + function?.validate() 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 + this.experiment == other.experiment && + this.function == other.function } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + return Objects.hash(experiment, function) } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + experiment != null -> "Location{experiment=$experiment}" + function != null -> "Location{function=$function}" + _json != null -> "Location{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Location") + } + } companion object { - @JvmStatic fun builder() = Builder() + @JvmStatic + fun ofExperiment(experiment: Experiment) = + Location(experiment = experiment) + + @JvmStatic + fun ofFunction(function: Function) = Location(function = function) } - class Builder { + interface Visitor { - private var type: JsonField = JsonMissing.of() - private var evalName: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun visitExperiment(experiment: Experiment): T - @JvmSynthetic - internal fun from(location: Location) = apply { - this.type = location.type - this.evalName = location.evalName - this.position = location.position - additionalProperties(location.additionalProperties) - } + fun visitFunction(function: Function): T - fun type(type: Type) = type(JsonField.of(type)) + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Location: $json") + } + } - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + class Deserializer : BaseDeserializer(Location::class) { - fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + override fun ObjectCodec.deserialize(node: JsonNode): Location { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(experiment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(function = it, _json = json) + } - @JsonProperty("eval_name") - @ExcludeMissing - fun evalName(evalName: JsonField) = apply { - this.evalName = evalName + return Location(_json = json) } + } - fun position(position: Position) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } + class Serializer : BaseSerializer(Location::class) { - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + override fun serialize( + value: Location, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.experiment != null -> + generator.writeObject(value.experiment) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Location") } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) } - @JsonDeserialize(using = Position.Deserializer::class) - @JsonSerialize(using = Position.Serializer::class) - class Position + @JsonDeserialize(builder = Experiment.Builder::class) + @NoAutoDetect + class Experiment private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) + private var hashCode: Int = 0 - fun scorer(): Optional = Optional.ofNullable(scorer) + fun type(): Type = type.getRequired("type") - fun isType(): Boolean = type != null + fun evalName(): String = evalName.getRequired("eval_name") - fun isScorer(): Boolean = scorer != null + fun position(): Position = position.getRequired("position") - fun asType(): Type = type.getOrThrow("type") + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun asScorer(): Scorer = scorer.getOrThrow("scorer") + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - fun _json(): Optional = Optional.ofNullable(_json) + @JsonProperty("position") @ExcludeMissing fun _position() = position - fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - scorer != null -> visitor.visitScorer(scorer) - else -> visitor.unknown(_json) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Position = apply { + fun validate(): Experiment = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() + type() + evalName() + position() validated = true } } + fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Position && + return other is Experiment && this.type == other.type && - this.scorer == other.scorer + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(type, scorer) - } - - override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) } + return hashCode } - companion object { + override fun toString() = + "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" - @JvmStatic fun ofType(type: Type) = Position(type = type) + companion object { - @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + @JvmStatic fun builder() = Builder() } - interface Visitor { + class Builder { - fun visitType(type: Type): T + private var type: JsonField = JsonMissing.of() + private var evalName: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitScorer(scorer: Scorer): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + @JvmSynthetic + internal fun from(experiment: Experiment) = apply { + this.type = experiment.type + this.evalName = experiment.evalName + this.position = experiment.position + additionalProperties(experiment.additionalProperties) } - } - class Deserializer : BaseDeserializer(Position::class) { + fun type(type: Type) = type(JsonField.of(type)) - override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(scorer = it, _json = json) - } + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } - return Position(_json = json) + fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + + @JsonProperty("eval_name") + @ExcludeMissing + fun evalName(evalName: JsonField) = apply { + this.evalName = evalName } - } - class Serializer : BaseSerializer(Position::class) { + fun position(position: Position) = position(JsonField.of(position)) - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.type != null -> generator.writeObject(value.type) - value.scorer != null -> generator.writeObject(value.scorer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + @JsonProperty("position") + @ExcludeMissing + fun position(position: JsonField) = apply { + this.position = position + } + + 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(): Experiment = + Experiment( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } - @JsonDeserialize(builder = Type.Builder::class) - @NoAutoDetect - class Type + @JsonDeserialize(using = Position.Deserializer::class) + @JsonSerialize(using = Position.Serializer::class) + class Position private constructor( - private val type: JsonField, - private val additionalProperties: Map, + private val type: Type? = null, + private val scorer: Scorer? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun type(): Optional = Optional.ofNullable(type) - fun type(): Type = type.getRequired("type") + fun scorer(): Optional = Optional.ofNullable(scorer) - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun isType(): Boolean = type != null - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun isScorer(): Boolean = scorer != null + + fun asType(): Type = type.getOrThrow("type") + + fun asScorer(): Scorer = scorer.getOrThrow("scorer") + + fun _json(): Optional = Optional.ofNullable(_json) - fun validate(): Type = apply { + fun accept(visitor: Visitor): T { + return when { + type != null -> visitor.visitType(type) + scorer != null -> visitor.visitScorer(scorer) + else -> visitor.unknown(_json) + } + } + + fun validate(): Position = apply { if (!validated) { - type() + if (type == null && scorer == null) { + throw BraintrustInvalidDataException( + "Unknown Position: $_json" + ) + } + type?.validate() + scorer?.validate() validated = true } } - fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && + return other is Position && this.type == other.type && - this.additionalProperties == other.additionalProperties + this.scorer == other.scorer } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + return Objects.hash(type, scorer) } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } + } companion object { - @JvmStatic fun builder() = Builder() - } + @JvmStatic fun ofType(type: Type) = Position(type = type) - class Builder { + @JvmStatic + fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + } - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + interface Visitor { - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) - } + fun visitType(type: Type): T - fun type(type: Type) = type(JsonField.of(type)) + fun visitScorer(scorer: Scorer): T - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown Position: $json" + ) + } + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + class Deserializer : BaseDeserializer(Position::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Position { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(type = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(scorer = it, _json = json) + } + + return Position(_json = json) } + } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + class Serializer : BaseSerializer(Position::class) { + + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.type != null -> generator.writeObject(value.type) + value.scorer != null -> + generator.writeObject(value.scorer) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) } - - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) } + @JsonDeserialize(builder = Type.Builder::class) + @NoAutoDetect class Type - @JsonCreator private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Type = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - TASK, - } + class Builder { - enum class Value { - TASK, - _UNKNOWN, - } + private var type: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN + @JvmSynthetic + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties(type.additionalProperties) } - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) } - fun asString(): String = _value().asStringOrThrow() - } - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - @JsonDeserialize(builder = Scorer.Builder::class) - @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } - private var validated: Boolean = false + fun build(): Type = + Type(type, additionalProperties.toUnmodifiable()) + } - private var hashCode: Int = 0 + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - fun type(): Type = type.getRequired("type") + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun index(): Double = index.getRequired("index") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonProperty("type") @ExcludeMissing fun _type() = type + return other is Type && this.value == other.value + } - @JsonProperty("index") @ExcludeMissing fun _index() = index + override fun hashCode() = value.hashCode() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + override fun toString() = value.toString() - fun validate(): Scorer = apply { - if (!validated) { - type() - index() - validated = true - } - } + companion object { - fun toBuilder() = Builder().from(this) + @JvmField val TASK = Type(JsonField.of("task")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) + } - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties - } + enum class Known { + TASK, + } - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) + enum class Value { + TASK, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() } - return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + @JsonDeserialize(builder = Scorer.Builder::class) + @NoAutoDetect + class Scorer + private constructor( + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - companion object { + private var validated: Boolean = false - @JvmStatic fun builder() = Builder() - } + private var hashCode: Int = 0 - class Builder { + fun type(): Type = type.getRequired("type") - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + fun index(): Long = index.getRequired("index") - @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - this.type = scorer.type - this.index = scorer.index - additionalProperties(scorer.additionalProperties) - } + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun type(type: Type) = type(JsonField.of(type)) + @JsonProperty("index") @ExcludeMissing fun _index() = index - @JsonProperty("type") + @JsonAnyGetter @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Scorer = apply { + if (!validated) { + type() + index() + validated = true + } + } - fun index(index: Double) = index(JsonField.of(index)) + fun toBuilder() = Builder().from(this) - @JsonProperty("index") - @ExcludeMissing - fun index(index: JsonField) = apply { - this.index = index - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) } + return hashCode + } + + override fun toString() = + "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) + @JvmStatic fun builder() = Builder() } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) - } + class Builder { - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmSynthetic + internal fun from(scorer: Scorer) = apply { + this.type = scorer.type + this.index = scorer.index + additionalProperties(scorer.additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { + this.index = index } - return other is Type && this.value == other.value + 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(): Scorer = + Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - override fun hashCode() = value.hashCode() + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - override fun toString() = value.toString() + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val SCORER = Type(JsonField.of("scorer")) + return other is Type && this.value == other.value + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode() = value.hashCode() - enum class Known { - SCORER, - } + override fun toString() = value.toString() - enum class Value { - SCORER, - _UNKNOWN, - } + companion object { - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN + @JvmField val SCORER = Type(JsonField.of("scorer")) + + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + enum class Known { + SCORER, + } + + enum class Value { + SCORER, + _UNKNOWN, } - fun asString(): String = _value().asStringOrThrow() + fun value(): Value = + when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SCORER -> Known.SCORER + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() + } + } + } + + 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 + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, } + + enum class Value { + EXPERIMENT, + _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 asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun index(): Long = index.getRequired("index") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("index") @ExcludeMissing fun _index() = index + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + index() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Function && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { - @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - EXPERIMENT, - } + class Builder { - enum class Value { - EXPERIMENT, - _UNKNOWN, + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.index = function.index + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { this.index = index } + + 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(): Function = + Function( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN + 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 + } + + return other is Type && this.value == other.value } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - fun asString(): String = _value().asStringOrThrow() + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _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 asString(): String = _value().asStringOrThrow() + } } } @@ -2647,6 +2983,117 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + /** JSON schema for the function's parameters and return type */ + @JsonDeserialize(builder = FunctionSchema.Builder::class) + @NoAutoDetect + class FunctionSchema + private constructor( + private val parameters: JsonValue, + private val returns: JsonValue, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun parameters(): JsonValue = parameters + + fun returns(): JsonValue = returns + + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + @JsonProperty("returns") @ExcludeMissing fun _returns() = returns + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FunctionSchema = apply { + if (!validated) { + parameters() + returns() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FunctionSchema && + this.parameters == other.parameters && + this.returns == other.returns && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + returns, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonValue = JsonMissing.of() + private var returns: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionSchema: FunctionSchema) = apply { + this.parameters = functionSchema.parameters + this.returns = functionSchema.returns + additionalProperties(functionSchema.additionalProperties) + } + + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + + @JsonProperty("returns") + @ExcludeMissing + fun returns(returns: JsonValue) = apply { this.returns = returns } + + 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(): FunctionSchema = + FunctionSchema( + parameters, + returns, + additionalProperties.toUnmodifiable(), + ) + } + } + class FunctionType @JsonCreator private constructor( @@ -2669,41 +3116,47 @@ private constructor( companion object { - @JvmField val TASK = FunctionType(JsonField.of("task")) - @JvmField val LLM = FunctionType(JsonField.of("llm")) @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val TASK = FunctionType(JsonField.of("task")) + + @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } enum class Known { - TASK, LLM, SCORER, + TASK, + TOOL, } enum class Value { - TASK, LLM, SCORER, + TASK, + TOOL, _UNKNOWN, } fun value(): Value = when (this) { - TASK -> Value.TASK LLM -> Value.LLM SCORER -> Value.SCORER + TASK -> Value.TASK + TOOL -> Value.TOOL else -> Value._UNKNOWN } fun known(): Known = when (this) { - TASK -> Known.TASK LLM -> Known.LLM SCORER -> Known.SCORER + TASK -> Known.TASK + TOOL -> Known.TOOL else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } 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 e6f11b1..0731309 100755 --- 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 @@ -35,6 +35,7 @@ constructor( private val projectId: String, private val slug: String, private val description: String?, + private val functionSchema: FunctionSchema?, private val functionType: FunctionType?, private val origin: Origin?, private val promptData: PromptData?, @@ -54,6 +55,8 @@ constructor( fun description(): Optional = Optional.ofNullable(description) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema) + fun functionType(): Optional = Optional.ofNullable(functionType) fun origin(): Optional = Optional.ofNullable(origin) @@ -70,6 +73,7 @@ constructor( projectId, slug, description, + functionSchema, functionType, origin, promptData, @@ -91,6 +95,7 @@ constructor( private val projectId: String?, private val slug: String?, private val description: String?, + private val functionSchema: FunctionSchema?, private val functionType: FunctionType?, private val origin: Origin?, private val promptData: PromptData?, @@ -114,6 +119,9 @@ constructor( /** Textual description of the prompt */ @JsonProperty("description") fun description(): String? = description + /** JSON schema for the function's parameters and return type */ + @JsonProperty("function_schema") fun functionSchema(): FunctionSchema? = functionSchema + @JsonProperty("function_type") fun functionType(): FunctionType? = functionType @JsonProperty("origin") fun origin(): Origin? = origin @@ -141,6 +149,7 @@ constructor( this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && + this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && @@ -157,6 +166,7 @@ constructor( projectId, slug, description, + functionSchema, functionType, origin, promptData, @@ -168,7 +178,7 @@ constructor( } override fun toString() = - "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -182,6 +192,7 @@ constructor( private var projectId: String? = null private var slug: String? = null private var description: String? = null + private var functionSchema: FunctionSchema? = null private var functionType: FunctionType? = null private var origin: Origin? = null private var promptData: PromptData? = null @@ -195,6 +206,7 @@ constructor( this.projectId = functionCreateBody.projectId this.slug = functionCreateBody.slug this.description = functionCreateBody.description + this.functionSchema = functionCreateBody.functionSchema this.functionType = functionCreateBody.functionType this.origin = functionCreateBody.origin this.promptData = functionCreateBody.promptData @@ -221,6 +233,12 @@ constructor( @JsonProperty("description") fun description(description: String) = apply { this.description = description } + /** JSON schema for the function's parameters and return type */ + @JsonProperty("function_schema") + fun functionSchema(functionSchema: FunctionSchema) = apply { + this.functionSchema = functionSchema + } + @JsonProperty("function_type") fun functionType(functionType: FunctionType) = apply { this.functionType = functionType @@ -256,6 +274,7 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(slug) { "`slug` is required but was not set" }, description, + functionSchema, functionType, origin, promptData, @@ -282,6 +301,7 @@ constructor( this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && + this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && @@ -298,6 +318,7 @@ constructor( projectId, slug, description, + functionSchema, functionType, origin, promptData, @@ -309,7 +330,7 @@ constructor( } override fun toString() = - "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -326,6 +347,7 @@ constructor( private var projectId: String? = null private var slug: String? = null private var description: String? = null + private var functionSchema: FunctionSchema? = null private var functionType: FunctionType? = null private var origin: Origin? = null private var promptData: PromptData? = null @@ -341,6 +363,7 @@ constructor( this.projectId = functionCreateParams.projectId this.slug = functionCreateParams.slug this.description = functionCreateParams.description + this.functionSchema = functionCreateParams.functionSchema this.functionType = functionCreateParams.functionType this.origin = functionCreateParams.origin this.promptData = functionCreateParams.promptData @@ -376,6 +399,11 @@ constructor( /** Textual description of the prompt */ fun description(description: String) = apply { this.description = description } + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema) = apply { + this.functionSchema = functionSchema + } + fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } fun origin(origin: Origin) = apply { this.origin = origin } @@ -453,6 +481,7 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(slug) { "`slug` is required but was not set" }, description, + functionSchema, functionType, origin, promptData, @@ -1028,7 +1057,7 @@ constructor( if (!validated) { type() runtimeContext().validate() - location().validate() + location() bundleId() preview() validated = true @@ -1159,646 +1188,957 @@ constructor( ) } - @JsonDeserialize(builder = Location.Builder::class) - @NoAutoDetect + @JsonDeserialize(using = Location.Deserializer::class) + @JsonSerialize(using = Location.Serializer::class) class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + private val experiment: Experiment? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun experiment(): Optional = Optional.ofNullable(experiment) - fun type(): Type = type.getRequired("type") + fun function(): Optional = Optional.ofNullable(function) - fun evalName(): String = evalName.getRequired("eval_name") + fun isExperiment(): Boolean = experiment != null - fun position(): Position = position.getRequired("position") + fun isFunction(): Boolean = function != null - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun asExperiment(): Experiment = experiment.getOrThrow("experiment") - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + fun asFunction(): Function = function.getOrThrow("function") - @JsonProperty("position") @ExcludeMissing fun _position() = position + fun _json(): Optional = Optional.ofNullable(_json) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun accept(visitor: Visitor): T { + return when { + experiment != null -> visitor.visitExperiment(experiment) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() + if (experiment == null && function == null) { + throw BraintrustInvalidDataException("Unknown Location: $_json") + } + experiment?.validate() + function?.validate() 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 + this.experiment == other.experiment && + this.function == other.function } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + return Objects.hash(experiment, function) } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + experiment != null -> "Location{experiment=$experiment}" + function != null -> "Location{function=$function}" + _json != null -> "Location{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Location") + } + } companion object { - @JvmStatic fun builder() = Builder() + @JvmStatic + fun ofExperiment(experiment: Experiment) = + Location(experiment = experiment) + + @JvmStatic + fun ofFunction(function: Function) = Location(function = function) } - class Builder { + interface Visitor { - private var type: JsonField = JsonMissing.of() - private var evalName: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun visitExperiment(experiment: Experiment): T - @JvmSynthetic - internal fun from(location: Location) = apply { - this.type = location.type - this.evalName = location.evalName - this.position = location.position - additionalProperties(location.additionalProperties) - } + fun visitFunction(function: Function): T - fun type(type: Type) = type(JsonField.of(type)) + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Location: $json") + } + } - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + class Deserializer : BaseDeserializer(Location::class) { - fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + override fun ObjectCodec.deserialize(node: JsonNode): Location { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(experiment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(function = it, _json = json) + } - @JsonProperty("eval_name") - @ExcludeMissing - fun evalName(evalName: JsonField) = apply { - this.evalName = evalName + return Location(_json = json) } + } - fun position(position: Position) = position(JsonField.of(position)) + class Serializer : BaseSerializer(Location::class) { - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + override fun serialize( + value: Location, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.experiment != null -> + generator.writeObject(value.experiment) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Location") } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) } - @JsonDeserialize(using = Position.Deserializer::class) - @JsonSerialize(using = Position.Serializer::class) - class Position + @JsonDeserialize(builder = Experiment.Builder::class) + @NoAutoDetect + class Experiment private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) + private var hashCode: Int = 0 - fun scorer(): Optional = Optional.ofNullable(scorer) + fun type(): Type = type.getRequired("type") - fun isType(): Boolean = type != null + fun evalName(): String = evalName.getRequired("eval_name") - fun isScorer(): Boolean = scorer != null + fun position(): Position = position.getRequired("position") - fun asType(): Type = type.getOrThrow("type") + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun asScorer(): Scorer = scorer.getOrThrow("scorer") + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - fun _json(): Optional = Optional.ofNullable(_json) + @JsonProperty("position") @ExcludeMissing fun _position() = position - fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - scorer != null -> visitor.visitScorer(scorer) - else -> visitor.unknown(_json) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Position = apply { + fun validate(): Experiment = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() + type() + evalName() + position() validated = true } } + fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Position && + return other is Experiment && this.type == other.type && - this.scorer == other.scorer + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(type, scorer) - } - - override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) } + return hashCode } - companion object { + override fun toString() = + "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" - @JvmStatic fun ofType(type: Type) = Position(type = type) + companion object { - @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + @JvmStatic fun builder() = Builder() } - interface Visitor { + class Builder { - fun visitType(type: Type): T + private var type: JsonField = JsonMissing.of() + private var evalName: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitScorer(scorer: Scorer): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + @JvmSynthetic + internal fun from(experiment: Experiment) = apply { + this.type = experiment.type + this.evalName = experiment.evalName + this.position = experiment.position + additionalProperties(experiment.additionalProperties) } - } - class Deserializer : BaseDeserializer(Position::class) { + fun type(type: Type) = type(JsonField.of(type)) - override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(scorer = it, _json = json) - } + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - return Position(_json = json) + @JsonProperty("eval_name") + @ExcludeMissing + fun evalName(evalName: JsonField) = apply { + this.evalName = evalName } - } - class Serializer : BaseSerializer(Position::class) { + fun position(position: Position) = position(JsonField.of(position)) - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.type != null -> generator.writeObject(value.type) - value.scorer != null -> generator.writeObject(value.scorer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + @JsonProperty("position") + @ExcludeMissing + fun position(position: JsonField) = apply { + this.position = position + } + + 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(): Experiment = + Experiment( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } - @JsonDeserialize(builder = Type.Builder::class) - @NoAutoDetect - class Type + @JsonDeserialize(using = Position.Deserializer::class) + @JsonSerialize(using = Position.Serializer::class) + class Position private constructor( - private val type: JsonField, - private val additionalProperties: Map, + private val type: Type? = null, + private val scorer: Scorer? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun type(): Optional = Optional.ofNullable(type) - fun type(): Type = type.getRequired("type") + fun scorer(): Optional = Optional.ofNullable(scorer) - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun isType(): Boolean = type != null - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun isScorer(): Boolean = scorer != null - fun validate(): Type = apply { + fun asType(): Type = type.getOrThrow("type") + + fun asScorer(): Scorer = scorer.getOrThrow("scorer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + type != null -> visitor.visitType(type) + scorer != null -> visitor.visitScorer(scorer) + else -> visitor.unknown(_json) + } + } + + fun validate(): Position = apply { if (!validated) { - type() + if (type == null && scorer == null) { + throw BraintrustInvalidDataException( + "Unknown Position: $_json" + ) + } + type?.validate() + scorer?.validate() validated = true } } - fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && + return other is Position && this.type == other.type && - this.additionalProperties == other.additionalProperties + this.scorer == other.scorer } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + return Objects.hash(type, scorer) } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } + } companion object { - @JvmStatic fun builder() = Builder() - } + @JvmStatic fun ofType(type: Type) = Position(type = type) - class Builder { + @JvmStatic + fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + } - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + interface Visitor { - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) - } + fun visitType(type: Type): T - fun type(type: Type) = type(JsonField.of(type)) + fun visitScorer(scorer: Scorer): T - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown Position: $json" + ) + } + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + class Deserializer : BaseDeserializer(Position::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Position { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(type = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(scorer = it, _json = json) + } + + return Position(_json = json) } + } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + class Serializer : BaseSerializer(Position::class) { + + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.type != null -> generator.writeObject(value.type) + value.scorer != null -> + generator.writeObject(value.scorer) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) } - - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) } + @JsonDeserialize(builder = Type.Builder::class) + @NoAutoDetect class Type - @JsonCreator private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Type = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - TASK, - } + class Builder { - enum class Value { - TASK, - _UNKNOWN, - } + private var type: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN + @JvmSynthetic + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties(type.additionalProperties) } - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) } - fun asString(): String = _value().asStringOrThrow() - } - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - @JsonDeserialize(builder = Scorer.Builder::class) - @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } - private var validated: Boolean = false + fun build(): Type = + Type(type, additionalProperties.toUnmodifiable()) + } - private var hashCode: Int = 0 + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - fun type(): Type = type.getRequired("type") + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun index(): Double = index.getRequired("index") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonProperty("type") @ExcludeMissing fun _type() = type + return other is Type && this.value == other.value + } - @JsonProperty("index") @ExcludeMissing fun _index() = index + override fun hashCode() = value.hashCode() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + override fun toString() = value.toString() - fun validate(): Scorer = apply { - if (!validated) { - type() - index() - validated = true - } - } + companion object { - fun toBuilder() = Builder().from(this) + @JvmField val TASK = Type(JsonField.of("task")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) + } - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties - } + enum class Known { + TASK, + } - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) + enum class Value { + TASK, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() } - return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + @JsonDeserialize(builder = Scorer.Builder::class) + @NoAutoDetect + class Scorer + private constructor( + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - companion object { + private var validated: Boolean = false - @JvmStatic fun builder() = Builder() - } + private var hashCode: Int = 0 - class Builder { + fun type(): Type = type.getRequired("type") - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + fun index(): Long = index.getRequired("index") - @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - this.type = scorer.type - this.index = scorer.index - additionalProperties(scorer.additionalProperties) - } + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun type(type: Type) = type(JsonField.of(type)) + @JsonProperty("index") @ExcludeMissing fun _index() = index - @JsonProperty("type") + @JsonAnyGetter @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Scorer = apply { + if (!validated) { + type() + index() + validated = true + } + } - fun index(index: Double) = index(JsonField.of(index)) + fun toBuilder() = Builder().from(this) - @JsonProperty("index") - @ExcludeMissing - fun index(index: JsonField) = apply { - this.index = index - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) } + return hashCode + } + + override fun toString() = + "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) + companion object { + + @JvmStatic fun builder() = Builder() } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) - } + class Builder { - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmSynthetic + internal fun from(scorer: Scorer) = apply { + this.type = scorer.type + this.index = scorer.index + additionalProperties(scorer.additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { + this.index = index + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) } - return other is Type && this.value == other.value + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Scorer = + Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - override fun hashCode() = value.hashCode() + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - override fun toString() = value.toString() + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val SCORER = Type(JsonField.of("scorer")) + return other is Type && this.value == other.value + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode() = value.hashCode() - enum class Known { - SCORER, - } + override fun toString() = value.toString() - enum class Value { - SCORER, - _UNKNOWN, - } + companion object { + + @JvmField val SCORER = Type(JsonField.of("scorer")) - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + enum class Known { + SCORER, + } + + enum class Value { + SCORER, + _UNKNOWN, } - fun asString(): String = _value().asStringOrThrow() + fun value(): Value = + when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SCORER -> Known.SCORER + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() + } + } + } + + 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 + } + + return other is Type && this.value == other.value } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + } + + enum class Value { + EXPERIMENT, + _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 asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun index(): Long = index.getRequired("index") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("index") @ExcludeMissing fun _index() = index + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + index() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Function && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { - @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - EXPERIMENT, - } + class Builder { - enum class Value { - EXPERIMENT, - _UNKNOWN, + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.index = function.index + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { this.index = index } + + 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(): Function = + Function( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN + 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 + } + + return other is Type && this.value == other.value } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - fun asString(): String = _value().asStringOrThrow() + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _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 asString(): String = _value().asStringOrThrow() + } } } @@ -2628,6 +2968,101 @@ constructor( } } + /** JSON schema for the function's parameters and return type */ + @JsonDeserialize(builder = FunctionSchema.Builder::class) + @NoAutoDetect + class FunctionSchema + private constructor( + private val parameters: JsonValue?, + private val returns: JsonValue?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("parameters") fun parameters(): JsonValue? = parameters + + @JsonProperty("returns") fun returns(): JsonValue? = returns + + @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 FunctionSchema && + this.parameters == other.parameters && + this.returns == other.returns && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + returns, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonValue? = null + private var returns: JsonValue? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionSchema: FunctionSchema) = apply { + this.parameters = functionSchema.parameters + this.returns = functionSchema.returns + additionalProperties(functionSchema.additionalProperties) + } + + @JsonProperty("parameters") + fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + + @JsonProperty("returns") + fun returns(returns: JsonValue) = apply { this.returns = returns } + + 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(): FunctionSchema = + FunctionSchema( + parameters, + returns, + additionalProperties.toUnmodifiable(), + ) + } + } + class FunctionType @JsonCreator private constructor( @@ -2650,41 +3085,47 @@ constructor( companion object { - @JvmField val TASK = FunctionType(JsonField.of("task")) - @JvmField val LLM = FunctionType(JsonField.of("llm")) @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val TASK = FunctionType(JsonField.of("task")) + + @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } enum class Known { - TASK, LLM, SCORER, + TASK, + TOOL, } enum class Value { - TASK, LLM, SCORER, + TASK, + TOOL, _UNKNOWN, } fun value(): Value = when (this) { - TASK -> Value.TASK LLM -> Value.LLM SCORER -> Value.SCORER + TASK -> Value.TASK + TOOL -> Value.TOOL else -> Value._UNKNOWN } fun known(): Known = when (this) { - TASK -> Known.TASK LLM -> Known.LLM SCORER -> Known.SCORER + TASK -> Known.TASK + TOOL -> Known.TOOL else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 8f10bf7..1e54ce8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -32,6 +32,8 @@ class FunctionInvokeParams constructor( private val functionId: String, private val input: JsonValue?, + private val messages: List?, + private val mode: Mode?, private val parent: Parent?, private val stream: Boolean?, private val version: String?, @@ -44,6 +46,10 @@ constructor( fun input(): Optional = Optional.ofNullable(input) + fun messages(): Optional> = Optional.ofNullable(messages) + + fun mode(): Optional = Optional.ofNullable(mode) + fun parent(): Optional = Optional.ofNullable(parent) fun stream(): Optional = Optional.ofNullable(stream) @@ -54,6 +60,8 @@ constructor( internal fun getBody(): FunctionInvokeBody { return FunctionInvokeBody( input, + messages, + mode, parent, stream, version, @@ -78,6 +86,8 @@ constructor( class FunctionInvokeBody internal constructor( private val input: JsonValue?, + private val messages: List?, + private val mode: Mode?, private val parent: Parent?, private val stream: Boolean?, private val version: String?, @@ -89,6 +99,12 @@ constructor( /** Argument to the function, which can be any JSON serializable value */ @JsonProperty("input") fun input(): JsonValue? = input + /** If the function is an LLM, additional messages to pass along to it */ + @JsonProperty("messages") fun messages(): List? = messages + + /** The mode format of the returned value (defaults to 'auto') */ + @JsonProperty("mode") fun mode(): Mode? = mode + /** Options for tracing the function call */ @JsonProperty("parent") fun parent(): Parent? = parent @@ -114,6 +130,8 @@ constructor( return other is FunctionInvokeBody && this.input == other.input && + this.messages == other.messages && + this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && @@ -125,6 +143,8 @@ constructor( hashCode = Objects.hash( input, + messages, + mode, parent, stream, version, @@ -135,7 +155,7 @@ constructor( } override fun toString() = - "FunctionInvokeBody{input=$input, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" + "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -145,6 +165,8 @@ constructor( class Builder { private var input: JsonValue? = null + private var messages: List? = null + private var mode: Mode? = null private var parent: Parent? = null private var stream: Boolean? = null private var version: String? = null @@ -153,6 +175,8 @@ constructor( @JvmSynthetic internal fun from(functionInvokeBody: FunctionInvokeBody) = apply { this.input = functionInvokeBody.input + this.messages = functionInvokeBody.messages + this.mode = functionInvokeBody.mode this.parent = functionInvokeBody.parent this.stream = functionInvokeBody.stream this.version = functionInvokeBody.version @@ -162,6 +186,13 @@ constructor( /** Argument to the function, which can be any JSON serializable value */ @JsonProperty("input") fun input(input: JsonValue) = apply { this.input = input } + /** If the function is an LLM, additional messages to pass along to it */ + @JsonProperty("messages") + fun messages(messages: List) = apply { this.messages = messages } + + /** The mode format of the returned value (defaults to 'auto') */ + @JsonProperty("mode") fun mode(mode: Mode) = apply { this.mode = mode } + /** Options for tracing the function call */ @JsonProperty("parent") fun parent(parent: Parent) = apply { this.parent = parent } @@ -191,6 +222,8 @@ constructor( fun build(): FunctionInvokeBody = FunctionInvokeBody( input, + messages?.toUnmodifiable(), + mode, parent, stream, version, @@ -213,6 +246,8 @@ constructor( return other is FunctionInvokeParams && this.functionId == other.functionId && this.input == other.input && + this.messages == other.messages && + this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && @@ -225,6 +260,8 @@ constructor( return Objects.hash( functionId, input, + messages, + mode, parent, stream, version, @@ -235,7 +272,7 @@ constructor( } override fun toString() = - "FunctionInvokeParams{functionId=$functionId, input=$input, parent=$parent, stream=$stream, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionInvokeParams{functionId=$functionId, input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -249,6 +286,8 @@ constructor( private var functionId: String? = null private var input: JsonValue? = null + private var messages: MutableList = mutableListOf() + private var mode: Mode? = null private var parent: Parent? = null private var stream: Boolean? = null private var version: String? = null @@ -260,6 +299,8 @@ constructor( internal fun from(functionInvokeParams: FunctionInvokeParams) = apply { this.functionId = functionInvokeParams.functionId this.input = functionInvokeParams.input + this.messages(functionInvokeParams.messages ?: listOf()) + this.mode = functionInvokeParams.mode this.parent = functionInvokeParams.parent this.stream = functionInvokeParams.stream this.version = functionInvokeParams.version @@ -274,6 +315,18 @@ constructor( /** Argument to the function, which can be any JSON serializable value */ fun input(input: JsonValue) = apply { this.input = input } + /** If the function is an LLM, additional messages to pass along to it */ + fun messages(messages: List) = apply { + this.messages.clear() + this.messages.addAll(messages) + } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(message: Message) = apply { this.messages.add(message) } + + /** The mode format of the returned value (defaults to 'auto') */ + fun mode(mode: Mode) = apply { this.mode = mode } + /** Options for tracing the function call */ fun parent(parent: Parent) = apply { this.parent = parent } @@ -352,6 +405,8 @@ constructor( FunctionInvokeParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, input, + if (messages.size == 0) null else messages.toUnmodifiable(), + mode, parent, stream, version, @@ -361,6 +416,2608 @@ constructor( ) } + @JsonDeserialize(using = Message.Deserializer::class) + @JsonSerialize(using = Message.Serializer::class) + 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 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 { + 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 ( + 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.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( + system, + user, + assistant, + tool, + function, + fallback, + ) + } + + override fun toString(): String { + 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 ofSystem(system: System) = Message(system = system) + + @JvmStatic fun ofUser(user: User) = Message(user = user) + + @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) + + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) + + @JvmStatic fun ofFunction(function: Function) = Message(function = function) + + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + } + + interface Visitor { + + fun visitSystem(system: System): T + + fun visitUser(user: User): T + + fun visitAssistant(assistant: Assistant): T + + fun visitTool(tool: Tool): T + + fun visitFunction(function: Function): T + + fun visitFallback(fallback: Fallback): T + + fun unknown(json: JsonValue?): T { + 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(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.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 = System.Builder::class) + @NoAutoDetect + 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 role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): System = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 + } + + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + 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 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(): System = + System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Role && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SYSTEM = Role(JsonField.of("system")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + SYSTEM, + } + + enum class Value { + SYSTEM, + _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 asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = User.Builder::class) + @NoAutoDetect + 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 role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): User = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 + } + + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + 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 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(): User = + User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Role && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USER = Role(JsonField.of("user")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + USER, + } + + enum class Value { + USER, + _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 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 chatCompletionContentParts: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun chatCompletionContentParts(): Optional> = + Optional.ofNullable(chatCompletionContentParts) + + fun isString(): Boolean = string != null + + fun isChatCompletionContentParts(): Boolean = chatCompletionContentParts != null + + fun asString(): String = string.getOrThrow("string") + + fun asChatCompletionContentParts(): List = + chatCompletionContentParts.getOrThrow("chatCompletionContentParts") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + chatCompletionContentParts != null -> + visitor.visitChatCompletionContentParts(chatCompletionContentParts) + else -> visitor.unknown(_json) + } + } + + fun validate(): Content = apply { + if (!validated) { + if (string == null && chatCompletionContentParts == null) { + throw BraintrustInvalidDataException("Unknown Content: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + this.string == other.string && + this.chatCompletionContentParts == other.chatCompletionContentParts + } + + override fun hashCode(): Int { + return Objects.hash(string, chatCompletionContentParts) + } + + override fun toString(): String { + return when { + string != null -> "Content{string=$string}" + chatCompletionContentParts != null -> + "Content{chatCompletionContentParts=$chatCompletionContentParts}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofChatCompletionContentParts( + chatCompletionContentParts: List + ) = Content(chatCompletionContentParts = chatCompletionContentParts) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitChatCompletionContentParts( + chatCompletionContentParts: List + ): T + + fun unknown(json: JsonValue?): T { + 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(chatCompletionContentParts = 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.chatCompletionContentParts != null -> + generator.writeObject(value.chatCompletionContentParts) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val text: Text? = null, + private val imageUrl: ImageUrl? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun text(): Optional = Optional.ofNullable(text) + + fun imageUrl(): Optional = Optional.ofNullable(imageUrl) + + 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 { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + text?.validate() + imageUrl?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChatCompletionContentPart && + this.text == other.text && + this.imageUrl == other.imageUrl + } + + override fun hashCode(): Int { + return Objects.hash(text, imageUrl) + } + + override fun toString(): String { + return when { + text != null -> "ChatCompletionContentPart{text=$text}" + imageUrl != null -> "ChatCompletionContentPart{imageUrl=$imageUrl}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic fun ofText(text: Text) = ChatCompletionContentPart(text = text) + + @JvmStatic + fun ofImageUrl(imageUrl: ImageUrl) = + ChatCompletionContentPart(imageUrl = imageUrl) + } + + interface Visitor { + + fun visitText(text: Text): T + + fun visitImageUrl(imageUrl: ImageUrl): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) + } + } + + class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionContentPart(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionContentPart(imageUrl = it, _json = json) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + 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 ChatCompletionContentPart") + } + } + } + + @JsonDeserialize(builder = Text.Builder::class) + @NoAutoDetect + 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 type(): Type = type.getRequired("type") + + @JsonProperty("text") @ExcludeMissing fun _text() = text + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Text = apply { + if (!validated) { + text() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + 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 + } + + override fun toString() = + "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var text: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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)) + + @JsonProperty("text") + @ExcludeMissing + fun text(text: JsonField) = apply { this.text = text } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + 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(): Text = + Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TEXT = Type(JsonField.of("text")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + TEXT, + } + + enum class Value { + TEXT, + _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 asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = ImageUrl.Builder::class) + @NoAutoDetect + class ImageUrl + private constructor( + private val imageUrl: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") + + fun type(): Type = type.getRequired("type") + + @JsonProperty("image_url") @ExcludeMissing fun _imageUrl() = imageUrl + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ImageUrl = apply { + if (!validated) { + imageUrl().validate() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + 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 + } + + override fun toString() = + "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var imageUrl: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + 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)) + + @JsonProperty("image_url") + @ExcludeMissing + fun imageUrl(imageUrl: JsonField) = apply { + this.imageUrl = imageUrl + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + 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(): 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, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun url(): String = url.getRequired("url") + + fun detail(): Optional = + Optional.ofNullable(detail.getNullable("detail")) + + @JsonProperty("url") @ExcludeMissing fun _url() = url + + @JsonProperty("detail") @ExcludeMissing fun _detail() = detail + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): ImageUrl = apply { + if (!validated) { + 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 hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var url: JsonField = JsonMissing.of() + private var detail: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(imageUrl: ImageUrl) = apply { + this.url = imageUrl.url + this.detail = imageUrl.detail + additionalProperties(imageUrl.additionalProperties) + } + + fun url(url: String) = url(JsonField.of(url)) + + @JsonProperty("url") + @ExcludeMissing + fun url(url: JsonField) = apply { this.url = url } + + fun detail(detail: Detail) = detail(JsonField.of(detail)) + + @JsonProperty("detail") + @ExcludeMissing + fun detail(detail: JsonField) = apply { + this.detail = detail + } + + 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(): ImageUrl = + ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Detail && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AUTO = Detail(JsonField.of("auto")) + + @JvmField val LOW = Detail(JsonField.of("low")) + + @JvmField val HIGH = Detail(JsonField.of("high")) + + @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) + } + + enum class Known { + AUTO, + LOW, + HIGH, + } + + enum class Value { + AUTO, + LOW, + HIGH, + _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 asString(): String = _value().asStringOrThrow() + } + } + + 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 + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + IMAGE_URL, + } + + enum class Value { + IMAGE_URL, + _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 asString(): String = _value().asStringOrThrow() + } + } + } + } + } + + @JsonDeserialize(builder = Assistant.Builder::class) + @NoAutoDetect + 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 + + private var hashCode: Int = 0 + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + 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")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Assistant = apply { + if (!validated) { + 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 + } + + 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 + } + + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var toolCalls: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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 content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) + + @JsonProperty("function_call") + @ExcludeMissing + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) + + @JsonProperty("tool_calls") + @ExcludeMissing + fun toolCalls(toolCalls: JsonField>) = apply { + this.toolCalls = toolCalls + } + + 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(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Role && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ASSISTANT = Role(JsonField.of("assistant")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + ASSISTANT, + } + + enum class Value { + ASSISTANT, + _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 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, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun arguments(): String = arguments.getRequired("arguments") + + fun name(): String = name.getRequired("name") + + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FunctionCall = apply { + if (!validated) { + arguments() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 + } + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionCall: FunctionCall) = apply { + this.arguments = functionCall.arguments + this.name = functionCall.name + additionalProperties(functionCall.additionalProperties) + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + @JsonProperty("arguments") + @ExcludeMissing + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + 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(): 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, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun id(): String = id.getRequired("id") + + fun function(): Function = function.getRequired("function") + + fun type(): Type = type.getRequired("type") + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonProperty("function") @ExcludeMissing fun _function() = function + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ToolCall = apply { + if (!validated) { + id() + function().validate() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + 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 + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var function: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(toolCall: ToolCall) = apply { + this.id = toolCall.id + this.function = toolCall.function + this.type = toolCall.type + additionalProperties(toolCall.additionalProperties) + } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + fun function(function: Function) = function(JsonField.of(function)) + + @JsonProperty("function") + @ExcludeMissing + fun function(function: JsonField) = apply { this.function = function } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + 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(): 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, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun arguments(): String = arguments.getRequired("arguments") + + fun name(): String = name.getRequired("name") + + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + 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 + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.arguments = function.arguments + this.name = function.name + additionalProperties(function.additionalProperties) + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + @JsonProperty("arguments") + @ExcludeMissing + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + 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(): Function = + Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) + } + } + + 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 + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _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 asString(): String = _value().asStringOrThrow() + } + } + } + + @JsonDeserialize(builder = Tool.Builder::class) + @NoAutoDetect + 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 role(): Role = role.getRequired("role") + + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Tool = apply { + if (!validated) { + content() + role() + toolCallId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 + } + + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var toolCallId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + @JsonProperty("tool_call_id") + @ExcludeMissing + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } + + 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(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Role && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TOOL = Role(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + TOOL, + } + + enum class Value { + TOOL, + _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 asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + 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 name(): String = name.getRequired("name") + + fun role(): Role = role.getRequired("role") + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + content() + name() + role() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 + } + + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + 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 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(): Function = + Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Role && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Role(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _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 asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = Fallback.Builder::class) + @NoAutoDetect + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Fallback = apply { + if (!validated) { + role() + content() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 + } + + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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 content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + 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(): Fallback = + Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Role && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MODEL = Role(JsonField.of("model")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + MODEL, + } + + enum class Value { + MODEL, + _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 asString(): String = _value().asStringOrThrow() + } + } + } + + class Mode + @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 Mode && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AUTO = Mode(JsonField.of("auto")) + + @JvmField val PARALLEL = Mode(JsonField.of("parallel")) + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + enum class Known { + AUTO, + PARALLEL, + } + + enum class Value { + AUTO, + PARALLEL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + PARALLEL -> Value.PARALLEL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + PARALLEL -> Known.PARALLEL + else -> throw BraintrustInvalidDataException("Unknown Mode: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + @JsonDeserialize(using = Parent.Deserializer::class) @JsonSerialize(using = Parent.Serializer::class) class Parent 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 31262fc..9b9e1ca 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class FunctionListPage private constructor( - private val functionService: FunctionService, + private val functionsService: FunctionService, private val params: FunctionListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is FunctionListPage && - this.functionService == other.functionService && + this.functionsService == other.functionsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - functionService, + functionsService, params, response, ) } override fun toString() = - "FunctionListPage{functionService=$functionService, params=$params, response=$response}" + "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { functionService.list(it) } + return getNextPageParams().map { functionsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,9 +86,9 @@ private constructor( companion object { @JvmStatic - fun of(functionService: FunctionService, params: FunctionListParams, response: Response) = + fun of(functionsService: FunctionService, params: FunctionListParams, response: Response) = FunctionListPage( - functionService, + functionsService, params, response, ) 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 f1ce966..9daf7ae 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class FunctionListPageAsync private constructor( - private val functionService: FunctionServiceAsync, + private val functionsService: FunctionServiceAsync, private val params: FunctionListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is FunctionListPageAsync && - this.functionService == other.functionService && + this.functionsService == other.functionsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - functionService, + functionsService, params, response, ) } override fun toString() = - "FunctionListPageAsync{functionService=$functionService, params=$params, response=$response}" + "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { functionService.list(it).thenApply { Optional.of(it) } } + .map { functionsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -90,12 +90,12 @@ private constructor( @JvmStatic fun of( - functionService: FunctionServiceAsync, + functionsService: FunctionServiceAsync, params: FunctionListParams, response: Response ) = FunctionListPageAsync( - functionService, + functionsService, params, response, ) 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 1e682fc..29363c9 100755 --- 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 @@ -35,6 +35,7 @@ constructor( private val projectId: String, private val slug: String, private val description: String?, + private val functionSchema: FunctionSchema?, private val functionType: FunctionType?, private val origin: Origin?, private val promptData: PromptData?, @@ -54,6 +55,8 @@ constructor( fun description(): Optional = Optional.ofNullable(description) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema) + fun functionType(): Optional = Optional.ofNullable(functionType) fun origin(): Optional = Optional.ofNullable(origin) @@ -70,6 +73,7 @@ constructor( projectId, slug, description, + functionSchema, functionType, origin, promptData, @@ -91,6 +95,7 @@ constructor( private val projectId: String?, private val slug: String?, private val description: String?, + private val functionSchema: FunctionSchema?, private val functionType: FunctionType?, private val origin: Origin?, private val promptData: PromptData?, @@ -114,6 +119,9 @@ constructor( /** Textual description of the prompt */ @JsonProperty("description") fun description(): String? = description + /** JSON schema for the function's parameters and return type */ + @JsonProperty("function_schema") fun functionSchema(): FunctionSchema? = functionSchema + @JsonProperty("function_type") fun functionType(): FunctionType? = functionType @JsonProperty("origin") fun origin(): Origin? = origin @@ -141,6 +149,7 @@ constructor( this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && + this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && @@ -157,6 +166,7 @@ constructor( projectId, slug, description, + functionSchema, functionType, origin, promptData, @@ -168,7 +178,7 @@ constructor( } override fun toString() = - "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -182,6 +192,7 @@ constructor( private var projectId: String? = null private var slug: String? = null private var description: String? = null + private var functionSchema: FunctionSchema? = null private var functionType: FunctionType? = null private var origin: Origin? = null private var promptData: PromptData? = null @@ -195,6 +206,7 @@ constructor( this.projectId = functionReplaceBody.projectId this.slug = functionReplaceBody.slug this.description = functionReplaceBody.description + this.functionSchema = functionReplaceBody.functionSchema this.functionType = functionReplaceBody.functionType this.origin = functionReplaceBody.origin this.promptData = functionReplaceBody.promptData @@ -221,6 +233,12 @@ constructor( @JsonProperty("description") fun description(description: String) = apply { this.description = description } + /** JSON schema for the function's parameters and return type */ + @JsonProperty("function_schema") + fun functionSchema(functionSchema: FunctionSchema) = apply { + this.functionSchema = functionSchema + } + @JsonProperty("function_type") fun functionType(functionType: FunctionType) = apply { this.functionType = functionType @@ -256,6 +274,7 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(slug) { "`slug` is required but was not set" }, description, + functionSchema, functionType, origin, promptData, @@ -282,6 +301,7 @@ constructor( this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && + this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && @@ -298,6 +318,7 @@ constructor( projectId, slug, description, + functionSchema, functionType, origin, promptData, @@ -309,7 +330,7 @@ constructor( } override fun toString() = - "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -326,6 +347,7 @@ constructor( private var projectId: String? = null private var slug: String? = null private var description: String? = null + private var functionSchema: FunctionSchema? = null private var functionType: FunctionType? = null private var origin: Origin? = null private var promptData: PromptData? = null @@ -341,6 +363,7 @@ constructor( this.projectId = functionReplaceParams.projectId this.slug = functionReplaceParams.slug this.description = functionReplaceParams.description + this.functionSchema = functionReplaceParams.functionSchema this.functionType = functionReplaceParams.functionType this.origin = functionReplaceParams.origin this.promptData = functionReplaceParams.promptData @@ -376,6 +399,11 @@ constructor( /** Textual description of the prompt */ fun description(description: String) = apply { this.description = description } + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema) = apply { + this.functionSchema = functionSchema + } + fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } fun origin(origin: Origin) = apply { this.origin = origin } @@ -453,6 +481,7 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(slug) { "`slug` is required but was not set" }, description, + functionSchema, functionType, origin, promptData, @@ -1028,7 +1057,7 @@ constructor( if (!validated) { type() runtimeContext().validate() - location().validate() + location() bundleId() preview() validated = true @@ -1159,646 +1188,957 @@ constructor( ) } - @JsonDeserialize(builder = Location.Builder::class) - @NoAutoDetect + @JsonDeserialize(using = Location.Deserializer::class) + @JsonSerialize(using = Location.Serializer::class) class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + private val experiment: Experiment? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun experiment(): Optional = Optional.ofNullable(experiment) - fun type(): Type = type.getRequired("type") + fun function(): Optional = Optional.ofNullable(function) - fun evalName(): String = evalName.getRequired("eval_name") + fun isExperiment(): Boolean = experiment != null - fun position(): Position = position.getRequired("position") + fun isFunction(): Boolean = function != null - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun asExperiment(): Experiment = experiment.getOrThrow("experiment") - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + fun asFunction(): Function = function.getOrThrow("function") - @JsonProperty("position") @ExcludeMissing fun _position() = position + fun _json(): Optional = Optional.ofNullable(_json) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun accept(visitor: Visitor): T { + return when { + experiment != null -> visitor.visitExperiment(experiment) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() + if (experiment == null && function == null) { + throw BraintrustInvalidDataException("Unknown Location: $_json") + } + experiment?.validate() + function?.validate() 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 + this.experiment == other.experiment && + this.function == other.function } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + return Objects.hash(experiment, function) } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + experiment != null -> "Location{experiment=$experiment}" + function != null -> "Location{function=$function}" + _json != null -> "Location{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Location") + } + } companion object { - @JvmStatic fun builder() = Builder() + @JvmStatic + fun ofExperiment(experiment: Experiment) = + Location(experiment = experiment) + + @JvmStatic + fun ofFunction(function: Function) = Location(function = function) } - class Builder { + interface Visitor { - private var type: JsonField = JsonMissing.of() - private var evalName: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun visitExperiment(experiment: Experiment): T - @JvmSynthetic - internal fun from(location: Location) = apply { - this.type = location.type - this.evalName = location.evalName - this.position = location.position - additionalProperties(location.additionalProperties) - } + fun visitFunction(function: Function): T - fun type(type: Type) = type(JsonField.of(type)) + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Location: $json") + } + } - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + class Deserializer : BaseDeserializer(Location::class) { - fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + override fun ObjectCodec.deserialize(node: JsonNode): Location { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(experiment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(function = it, _json = json) + } - @JsonProperty("eval_name") - @ExcludeMissing - fun evalName(evalName: JsonField) = apply { - this.evalName = evalName + return Location(_json = json) } + } - fun position(position: Position) = position(JsonField.of(position)) + class Serializer : BaseSerializer(Location::class) { - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + override fun serialize( + value: Location, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.experiment != null -> + generator.writeObject(value.experiment) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Location") } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) } - @JsonDeserialize(using = Position.Deserializer::class) - @JsonSerialize(using = Position.Serializer::class) - class Position + @JsonDeserialize(builder = Experiment.Builder::class) + @NoAutoDetect + class Experiment private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) + private var hashCode: Int = 0 - fun scorer(): Optional = Optional.ofNullable(scorer) + fun type(): Type = type.getRequired("type") - fun isType(): Boolean = type != null + fun evalName(): String = evalName.getRequired("eval_name") - fun isScorer(): Boolean = scorer != null + fun position(): Position = position.getRequired("position") - fun asType(): Type = type.getOrThrow("type") + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun asScorer(): Scorer = scorer.getOrThrow("scorer") + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - fun _json(): Optional = Optional.ofNullable(_json) + @JsonProperty("position") @ExcludeMissing fun _position() = position - fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - scorer != null -> visitor.visitScorer(scorer) - else -> visitor.unknown(_json) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Position = apply { + fun validate(): Experiment = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() + type() + evalName() + position() validated = true } } + fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Position && + return other is Experiment && this.type == other.type && - this.scorer == other.scorer + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(type, scorer) - } - - override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) } + return hashCode } - companion object { + override fun toString() = + "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" - @JvmStatic fun ofType(type: Type) = Position(type = type) + companion object { - @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + @JvmStatic fun builder() = Builder() } - interface Visitor { + class Builder { - fun visitType(type: Type): T + private var type: JsonField = JsonMissing.of() + private var evalName: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitScorer(scorer: Scorer): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + @JvmSynthetic + internal fun from(experiment: Experiment) = apply { + this.type = experiment.type + this.evalName = experiment.evalName + this.position = experiment.position + additionalProperties(experiment.additionalProperties) } - } - class Deserializer : BaseDeserializer(Position::class) { + fun type(type: Type) = type(JsonField.of(type)) - override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(scorer = it, _json = json) - } + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - return Position(_json = json) + @JsonProperty("eval_name") + @ExcludeMissing + fun evalName(evalName: JsonField) = apply { + this.evalName = evalName } - } - class Serializer : BaseSerializer(Position::class) { + fun position(position: Position) = position(JsonField.of(position)) - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.type != null -> generator.writeObject(value.type) - value.scorer != null -> generator.writeObject(value.scorer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + @JsonProperty("position") + @ExcludeMissing + fun position(position: JsonField) = apply { + this.position = position + } + + 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(): Experiment = + Experiment( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } - @JsonDeserialize(builder = Type.Builder::class) - @NoAutoDetect - class Type + @JsonDeserialize(using = Position.Deserializer::class) + @JsonSerialize(using = Position.Serializer::class) + class Position private constructor( - private val type: JsonField, - private val additionalProperties: Map, + private val type: Type? = null, + private val scorer: Scorer? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun type(): Optional = Optional.ofNullable(type) - fun type(): Type = type.getRequired("type") + fun scorer(): Optional = Optional.ofNullable(scorer) - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun isType(): Boolean = type != null - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun isScorer(): Boolean = scorer != null - fun validate(): Type = apply { + fun asType(): Type = type.getOrThrow("type") + + fun asScorer(): Scorer = scorer.getOrThrow("scorer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + type != null -> visitor.visitType(type) + scorer != null -> visitor.visitScorer(scorer) + else -> visitor.unknown(_json) + } + } + + fun validate(): Position = apply { if (!validated) { - type() + if (type == null && scorer == null) { + throw BraintrustInvalidDataException( + "Unknown Position: $_json" + ) + } + type?.validate() + scorer?.validate() validated = true } } - fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && + return other is Position && this.type == other.type && - this.additionalProperties == other.additionalProperties + this.scorer == other.scorer } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + return Objects.hash(type, scorer) } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } + } companion object { - @JvmStatic fun builder() = Builder() - } + @JvmStatic fun ofType(type: Type) = Position(type = type) - class Builder { + @JvmStatic + fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + } - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + interface Visitor { - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) - } + fun visitType(type: Type): T - fun type(type: Type) = type(JsonField.of(type)) + fun visitScorer(scorer: Scorer): T - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown Position: $json" + ) + } + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + class Deserializer : BaseDeserializer(Position::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Position { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(type = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(scorer = it, _json = json) + } + + return Position(_json = json) } + } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + class Serializer : BaseSerializer(Position::class) { + + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.type != null -> generator.writeObject(value.type) + value.scorer != null -> + generator.writeObject(value.scorer) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) } - - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) } + @JsonDeserialize(builder = Type.Builder::class) + @NoAutoDetect class Type - @JsonCreator private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Type = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - TASK, - } + class Builder { - enum class Value { - TASK, - _UNKNOWN, - } + private var type: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN + @JvmSynthetic + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties(type.additionalProperties) } - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) } - fun asString(): String = _value().asStringOrThrow() - } - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - @JsonDeserialize(builder = Scorer.Builder::class) - @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } - private var validated: Boolean = false + fun build(): Type = + Type(type, additionalProperties.toUnmodifiable()) + } - private var hashCode: Int = 0 + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - fun type(): Type = type.getRequired("type") + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun index(): Double = index.getRequired("index") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonProperty("type") @ExcludeMissing fun _type() = type + return other is Type && this.value == other.value + } - @JsonProperty("index") @ExcludeMissing fun _index() = index + override fun hashCode() = value.hashCode() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + override fun toString() = value.toString() - fun validate(): Scorer = apply { - if (!validated) { - type() - index() - validated = true - } - } + companion object { - fun toBuilder() = Builder().from(this) + @JvmField val TASK = Type(JsonField.of("task")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) + } - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties - } + enum class Known { + TASK, + } - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) + enum class Value { + TASK, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() } - return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + @JsonDeserialize(builder = Scorer.Builder::class) + @NoAutoDetect + class Scorer + private constructor( + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - companion object { + private var validated: Boolean = false - @JvmStatic fun builder() = Builder() - } + private var hashCode: Int = 0 - class Builder { + fun type(): Type = type.getRequired("type") - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + fun index(): Long = index.getRequired("index") - @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - this.type = scorer.type - this.index = scorer.index - additionalProperties(scorer.additionalProperties) - } + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun type(type: Type) = type(JsonField.of(type)) + @JsonProperty("index") @ExcludeMissing fun _index() = index - @JsonProperty("type") + @JsonAnyGetter @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Scorer = apply { + if (!validated) { + type() + index() + validated = true + } + } - fun index(index: Double) = index(JsonField.of(index)) + fun toBuilder() = Builder().from(this) - @JsonProperty("index") - @ExcludeMissing - fun index(index: JsonField) = apply { - this.index = index - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) } + return hashCode + } + + override fun toString() = + "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) + companion object { + + @JvmStatic fun builder() = Builder() } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) - } + class Builder { - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmSynthetic + internal fun from(scorer: Scorer) = apply { + this.type = scorer.type + this.index = scorer.index + additionalProperties(scorer.additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { + this.index = index + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) } - return other is Type && this.value == other.value + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Scorer = + Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - override fun hashCode() = value.hashCode() + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - override fun toString() = value.toString() + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val SCORER = Type(JsonField.of("scorer")) + return other is Type && this.value == other.value + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode() = value.hashCode() - enum class Known { - SCORER, - } + override fun toString() = value.toString() - enum class Value { - SCORER, - _UNKNOWN, - } + companion object { + + @JvmField val SCORER = Type(JsonField.of("scorer")) - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + enum class Known { + SCORER, + } + + enum class Value { + SCORER, + _UNKNOWN, } - fun asString(): String = _value().asStringOrThrow() + fun value(): Value = + when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SCORER -> Known.SCORER + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() + } + } + } + + 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 + } + + return other is Type && this.value == other.value } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + } + + enum class Value { + EXPERIMENT, + _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 asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun index(): Long = index.getRequired("index") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("index") @ExcludeMissing fun _index() = index + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + index() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Function && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { - @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - EXPERIMENT, - } + class Builder { - enum class Value { - EXPERIMENT, - _UNKNOWN, + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.index = function.index + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { this.index = index } + + 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(): Function = + Function( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN + 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 + } + + return other is Type && this.value == other.value } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - fun asString(): String = _value().asStringOrThrow() + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _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 asString(): String = _value().asStringOrThrow() + } } } @@ -2628,6 +2968,101 @@ constructor( } } + /** JSON schema for the function's parameters and return type */ + @JsonDeserialize(builder = FunctionSchema.Builder::class) + @NoAutoDetect + class FunctionSchema + private constructor( + private val parameters: JsonValue?, + private val returns: JsonValue?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("parameters") fun parameters(): JsonValue? = parameters + + @JsonProperty("returns") fun returns(): JsonValue? = returns + + @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 FunctionSchema && + this.parameters == other.parameters && + this.returns == other.returns && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + returns, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonValue? = null + private var returns: JsonValue? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionSchema: FunctionSchema) = apply { + this.parameters = functionSchema.parameters + this.returns = functionSchema.returns + additionalProperties(functionSchema.additionalProperties) + } + + @JsonProperty("parameters") + fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + + @JsonProperty("returns") + fun returns(returns: JsonValue) = apply { this.returns = returns } + + 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(): FunctionSchema = + FunctionSchema( + parameters, + returns, + additionalProperties.toUnmodifiable(), + ) + } + } + class FunctionType @JsonCreator private constructor( @@ -2650,41 +3085,47 @@ constructor( companion object { - @JvmField val TASK = FunctionType(JsonField.of("task")) - @JvmField val LLM = FunctionType(JsonField.of("llm")) @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val TASK = FunctionType(JsonField.of("task")) + + @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } enum class Known { - TASK, LLM, SCORER, + TASK, + TOOL, } enum class Value { - TASK, LLM, SCORER, + TASK, + TOOL, _UNKNOWN, } fun value(): Value = when (this) { - TASK -> Value.TASK LLM -> Value.LLM SCORER -> Value.SCORER + TASK -> Value.TASK + TOOL -> Value.TOOL else -> Value._UNKNOWN } fun known(): Known = when (this) { - TASK -> Known.TASK LLM -> Known.LLM SCORER -> Known.SCORER + TASK -> Known.TASK + TOOL -> Known.TOOL else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } 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 17e6953..a6f3568 100755 --- 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 @@ -979,7 +979,7 @@ constructor( if (!validated) { type() runtimeContext().validate() - location().validate() + location() bundleId() preview() validated = true @@ -1110,646 +1110,957 @@ constructor( ) } - @JsonDeserialize(builder = Location.Builder::class) - @NoAutoDetect + @JsonDeserialize(using = Location.Deserializer::class) + @JsonSerialize(using = Location.Serializer::class) class Location private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + private val experiment: Experiment? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun experiment(): Optional = Optional.ofNullable(experiment) - fun type(): Type = type.getRequired("type") + fun function(): Optional = Optional.ofNullable(function) - fun evalName(): String = evalName.getRequired("eval_name") + fun isExperiment(): Boolean = experiment != null - fun position(): Position = position.getRequired("position") + fun isFunction(): Boolean = function != null - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun asExperiment(): Experiment = experiment.getOrThrow("experiment") - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + fun asFunction(): Function = function.getOrThrow("function") - @JsonProperty("position") @ExcludeMissing fun _position() = position + fun _json(): Optional = Optional.ofNullable(_json) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun accept(visitor: Visitor): T { + return when { + experiment != null -> visitor.visitExperiment(experiment) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() + if (experiment == null && function == null) { + throw BraintrustInvalidDataException("Unknown Location: $_json") + } + experiment?.validate() + function?.validate() 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 + this.experiment == other.experiment && + this.function == other.function } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + return Objects.hash(experiment, function) } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + experiment != null -> "Location{experiment=$experiment}" + function != null -> "Location{function=$function}" + _json != null -> "Location{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Location") + } + } companion object { - @JvmStatic fun builder() = Builder() + @JvmStatic + fun ofExperiment(experiment: Experiment) = + Location(experiment = experiment) + + @JvmStatic + fun ofFunction(function: Function) = Location(function = function) } - class Builder { + interface Visitor { - private var type: JsonField = JsonMissing.of() - private var evalName: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + fun visitExperiment(experiment: Experiment): T - @JvmSynthetic - internal fun from(location: Location) = apply { - this.type = location.type - this.evalName = location.evalName - this.position = location.position - additionalProperties(location.additionalProperties) + fun visitFunction(function: Function): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Location: $json") } + } - fun type(type: Type) = type(JsonField.of(type)) + class Deserializer : BaseDeserializer(Location::class) { - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + override fun ObjectCodec.deserialize(node: JsonNode): Location { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(experiment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(function = it, _json = json) + } - @JsonProperty("eval_name") - @ExcludeMissing - fun evalName(evalName: JsonField) = apply { - this.evalName = evalName + return Location(_json = json) } + } - fun position(position: Position) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } + class Serializer : BaseSerializer(Location::class) { - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + override fun serialize( + value: Location, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.experiment != null -> + generator.writeObject(value.experiment) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Location") } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) } - @JsonDeserialize(using = Position.Deserializer::class) - @JsonSerialize(using = Position.Serializer::class) - class Position + @JsonDeserialize(builder = Experiment.Builder::class) + @NoAutoDetect + class Experiment private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, ) { private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) + private var hashCode: Int = 0 - fun scorer(): Optional = Optional.ofNullable(scorer) + fun type(): Type = type.getRequired("type") - fun isType(): Boolean = type != null + fun evalName(): String = evalName.getRequired("eval_name") - fun isScorer(): Boolean = scorer != null + fun position(): Position = position.getRequired("position") - fun asType(): Type = type.getOrThrow("type") + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun asScorer(): Scorer = scorer.getOrThrow("scorer") + @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - fun _json(): Optional = Optional.ofNullable(_json) + @JsonProperty("position") @ExcludeMissing fun _position() = position - fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - scorer != null -> visitor.visitScorer(scorer) - else -> visitor.unknown(_json) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties - fun validate(): Position = apply { + fun validate(): Experiment = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() + type() + evalName() + position() validated = true } } + fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Position && + return other is Experiment && this.type == other.type && - this.scorer == other.scorer + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(type, scorer) - } - - override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + evalName, + position, + additionalProperties, + ) } + return hashCode } - companion object { + override fun toString() = + "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" - @JvmStatic fun ofType(type: Type) = Position(type = type) + companion object { - @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + @JvmStatic fun builder() = Builder() } - interface Visitor { + class Builder { - fun visitType(type: Type): T + private var type: JsonField = JsonMissing.of() + private var evalName: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitScorer(scorer: Scorer): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + @JvmSynthetic + internal fun from(experiment: Experiment) = apply { + this.type = experiment.type + this.evalName = experiment.evalName + this.position = experiment.position + additionalProperties(experiment.additionalProperties) } - } - class Deserializer : BaseDeserializer(Position::class) { + fun type(type: Type) = type(JsonField.of(type)) - override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(scorer = it, _json = json) - } + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } - return Position(_json = json) + fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + + @JsonProperty("eval_name") + @ExcludeMissing + fun evalName(evalName: JsonField) = apply { + this.evalName = evalName } - } - class Serializer : BaseSerializer(Position::class) { + fun position(position: Position) = position(JsonField.of(position)) - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.type != null -> generator.writeObject(value.type) - value.scorer != null -> generator.writeObject(value.scorer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + @JsonProperty("position") + @ExcludeMissing + fun position(position: JsonField) = apply { + this.position = position + } + + 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(): Experiment = + Experiment( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } - @JsonDeserialize(builder = Type.Builder::class) - @NoAutoDetect - class Type + @JsonDeserialize(using = Position.Deserializer::class) + @JsonSerialize(using = Position.Serializer::class) + class Position private constructor( - private val type: JsonField, - private val additionalProperties: Map, + private val type: Type? = null, + private val scorer: Scorer? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - private var hashCode: Int = 0 + fun type(): Optional = Optional.ofNullable(type) - fun type(): Type = type.getRequired("type") + fun scorer(): Optional = Optional.ofNullable(scorer) - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun isType(): Boolean = type != null - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun isScorer(): Boolean = scorer != null - fun validate(): Type = apply { + fun asType(): Type = type.getOrThrow("type") + + fun asScorer(): Scorer = scorer.getOrThrow("scorer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + type != null -> visitor.visitType(type) + scorer != null -> visitor.visitScorer(scorer) + else -> visitor.unknown(_json) + } + } + + fun validate(): Position = apply { if (!validated) { - type() + if (type == null && scorer == null) { + throw BraintrustInvalidDataException( + "Unknown Position: $_json" + ) + } + type?.validate() + scorer?.validate() validated = true } } - fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && + return other is Position && this.type == other.type && - this.additionalProperties == other.additionalProperties + this.scorer == other.scorer } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + return Objects.hash(type, scorer) } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString(): String { + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } + } companion object { - @JvmStatic fun builder() = Builder() - } + @JvmStatic fun ofType(type: Type) = Position(type = type) - class Builder { + @JvmStatic + fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + } - private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + interface Visitor { - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties(type.additionalProperties) - } + fun visitType(type: Type): T - fun type(type: Type) = type(JsonField.of(type)) + fun visitScorer(scorer: Scorer): T - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown Position: $json" + ) + } + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + class Deserializer : BaseDeserializer(Position::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Position { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(type = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Position(scorer = it, _json = json) + } + + return Position(_json = json) } + } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + class Serializer : BaseSerializer(Position::class) { + + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.type != null -> generator.writeObject(value.type) + value.scorer != null -> + generator.writeObject(value.scorer) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) } - - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) } + @JsonDeserialize(builder = Type.Builder::class) + @NoAutoDetect class Type - @JsonCreator private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val additionalProperties: Map, + ) { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Type = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" companion object { - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - TASK, - } + class Builder { - enum class Value { - TASK, - _UNKNOWN, - } + private var type: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN + @JvmSynthetic + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties(type.additionalProperties) } - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) } - fun asString(): String = _value().asStringOrThrow() - } - } + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - @JsonDeserialize(builder = Scorer.Builder::class) - @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } - private var validated: Boolean = false + fun build(): Type = + Type(type, additionalProperties.toUnmodifiable()) + } - private var hashCode: Int = 0 + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - fun type(): Type = type.getRequired("type") + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun index(): Double = index.getRequired("index") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonProperty("type") @ExcludeMissing fun _type() = type + return other is Type && this.value == other.value + } - @JsonProperty("index") @ExcludeMissing fun _index() = index + override fun hashCode() = value.hashCode() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + override fun toString() = value.toString() - fun validate(): Scorer = apply { - if (!validated) { - type() - index() - validated = true - } - } + companion object { - fun toBuilder() = Builder().from(this) + @JvmField val TASK = Type(JsonField.of("task")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) + } - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties - } + enum class Known { + TASK, + } - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) + enum class Value { + TASK, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() } - return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + @JsonDeserialize(builder = Scorer.Builder::class) + @NoAutoDetect + class Scorer + private constructor( + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - companion object { + private var validated: Boolean = false - @JvmStatic fun builder() = Builder() - } + private var hashCode: Int = 0 - class Builder { + fun type(): Type = type.getRequired("type") - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + fun index(): Long = index.getRequired("index") - @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - this.type = scorer.type - this.index = scorer.index - additionalProperties(scorer.additionalProperties) - } + @JsonProperty("type") @ExcludeMissing fun _type() = type - fun type(type: Type) = type(JsonField.of(type)) + @JsonProperty("index") @ExcludeMissing fun _index() = index - @JsonProperty("type") + @JsonAnyGetter @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Scorer = apply { + if (!validated) { + type() + index() + validated = true + } + } - fun index(index: Double) = index(JsonField.of(index)) + fun toBuilder() = Builder().from(this) - @JsonProperty("index") - @ExcludeMissing - fun index(index: JsonField) = apply { - this.index = index - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) } + return hashCode + } + + override fun toString() = + "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + + companion object { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) + @JvmStatic fun builder() = Builder() } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) - } + class Builder { - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: + MutableMap = + mutableMapOf() - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmSynthetic + internal fun from(scorer: Scorer) = apply { + this.type = scorer.type + this.index = scorer.index + additionalProperties(scorer.additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { + this.index = index + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) } - return other is Type && this.value == other.value + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Scorer = + Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - override fun hashCode() = value.hashCode() + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - override fun toString() = value.toString() + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val SCORER = Type(JsonField.of("scorer")) + return other is Type && this.value == other.value + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode() = value.hashCode() - enum class Known { - SCORER, - } + override fun toString() = value.toString() - enum class Value { - SCORER, - _UNKNOWN, - } + companion object { - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN + @JvmField val SCORER = Type(JsonField.of("scorer")) + + @JvmStatic + fun of(value: String) = Type(JsonField.of(value)) } - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) + enum class Known { + SCORER, } - fun asString(): String = _value().asStringOrThrow() + enum class Value { + SCORER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SCORER -> Known.SCORER + else -> + throw BraintrustInvalidDataException( + "Unknown Type: $value" + ) + } + + fun asString(): String = _value().asStringOrThrow() + } } } + + 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 + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + } + + enum class Value { + EXPERIMENT, + _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 asString(): String = _value().asStringOrThrow() + } } - class Type - @JsonCreator + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function private constructor( - private val value: JsonField, - ) : Enum { + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun index(): Long = index.getRequired("index") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("index") @ExcludeMissing fun _index() = index + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + index() + validated = true + } + } + + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Type && this.value == other.value + return other is Function && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode + } - override fun toString() = value.toString() + override fun toString() = + "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { - @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun builder() = Builder() } - enum class Known { - EXPERIMENT, - } + class Builder { - enum class Value { - EXPERIMENT, - _UNKNOWN, + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.index = function.index + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { this.index = index } + + 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(): Function = + Function( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN + 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 + } + + return other is Type && this.value == other.value } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - fun asString(): String = _value().asStringOrThrow() + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _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 asString(): String = _value().asStringOrThrow() + } } } 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 d89a3e0..9d3d9ce 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class GroupListPage private constructor( - private val groupService: GroupService, + private val groupsService: GroupService, private val params: GroupListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is GroupListPage && - this.groupService == other.groupService && + this.groupsService == other.groupsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - groupService, + groupsService, params, response, ) } override fun toString() = - "GroupListPage{groupService=$groupService, params=$params, response=$response}" + "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -72,7 +72,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { groupService.list(it) } + return getNextPageParams().map { groupsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,9 +80,9 @@ private constructor( companion object { @JvmStatic - fun of(groupService: GroupService, params: GroupListParams, response: Response) = + fun of(groupsService: GroupService, params: GroupListParams, response: Response) = GroupListPage( - groupService, + groupsService, params, response, ) 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 7fb2880..cc058b5 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class GroupListPageAsync private constructor( - private val groupService: GroupServiceAsync, + private val groupsService: GroupServiceAsync, private val params: GroupListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is GroupListPageAsync && - this.groupService == other.groupService && + this.groupsService == other.groupsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - groupService, + groupsService, params, response, ) } override fun toString() = - "GroupListPageAsync{groupService=$groupService, params=$params, response=$response}" + "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -74,7 +74,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { groupService.list(it).thenApply { Optional.of(it) } } + .map { groupsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -83,9 +83,9 @@ private constructor( companion object { @JvmStatic - fun of(groupService: GroupServiceAsync, params: GroupListParams, response: Response) = + fun of(groupsService: GroupServiceAsync, params: GroupListParams, response: Response) = GroupListPageAsync( - groupService, + groupsService, params, response, ) 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 4a1646b..ed6d9bd 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class OrganizationListPage private constructor( - private val organizationService: OrganizationService, + private val organizationsService: OrganizationService, private val params: OrganizationListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is OrganizationListPage && - this.organizationService == other.organizationService && + this.organizationsService == other.organizationsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - organizationService, + organizationsService, params, response, ) } override fun toString() = - "OrganizationListPage{organizationService=$organizationService, params=$params, response=$response}" + "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { organizationService.list(it) } + return getNextPageParams().map { organizationsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -87,12 +87,12 @@ private constructor( @JvmStatic fun of( - organizationService: OrganizationService, + organizationsService: OrganizationService, params: OrganizationListParams, response: Response ) = OrganizationListPage( - organizationService, + organizationsService, params, response, ) 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 2b21125..5dc1299 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class OrganizationListPageAsync private constructor( - private val organizationService: OrganizationServiceAsync, + private val organizationsService: OrganizationServiceAsync, private val params: OrganizationListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is OrganizationListPageAsync && - this.organizationService == other.organizationService && + this.organizationsService == other.organizationsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - organizationService, + organizationsService, params, response, ) } override fun toString() = - "OrganizationListPageAsync{organizationService=$organizationService, params=$params, response=$response}" + "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { organizationService.list(it).thenApply { Optional.of(it) } } + .map { organizationsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -90,12 +90,12 @@ private constructor( @JvmStatic fun of( - organizationService: OrganizationServiceAsync, + organizationsService: OrganizationServiceAsync, params: OrganizationListParams, response: Response ) = OrganizationListPageAsync( - organizationService, + organizationsService, params, response, ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectModel.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt similarity index 92% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectModel.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 4e1d580..cb54d37 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectModel.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -16,9 +16,9 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ProjectModel.Builder::class) +@JsonDeserialize(builder = Project.Builder::class) @NoAutoDetect -class ProjectModel +class Project private constructor( private val id: JsonField, private val orgId: JsonField, @@ -79,7 +79,7 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): ProjectModel = apply { + fun validate(): Project = apply { if (!validated) { id() orgId() @@ -99,7 +99,7 @@ private constructor( return true } - return other is ProjectModel && + return other is Project && this.id == other.id && this.orgId == other.orgId && this.name == other.name && @@ -128,7 +128,7 @@ private constructor( } override fun toString() = - "ProjectModel{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" + "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" companion object { @@ -147,15 +147,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectModel: ProjectModel) = apply { - this.id = projectModel.id - this.orgId = projectModel.orgId - this.name = projectModel.name - this.created = projectModel.created - this.deletedAt = projectModel.deletedAt - this.userId = projectModel.userId - this.settings = projectModel.settings - additionalProperties(projectModel.additionalProperties) + internal fun from(project: Project) = apply { + this.id = project.id + this.orgId = project.orgId + this.name = project.name + this.created = project.created + this.deletedAt = project.deletedAt + this.userId = project.userId + this.settings = project.settings + additionalProperties(project.additionalProperties) } /** Unique identifier for the project */ @@ -224,8 +224,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectModel = - ProjectModel( + fun build(): Project = + Project( id, orgId, name, 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 fe3b5cb..11d4f3b 100755 --- 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 @@ -20,14 +20,14 @@ import java.util.stream.StreamSupport class ProjectListPage private constructor( - private val projectService: ProjectService, + private val projectsService: ProjectService, private val params: ProjectListParams, private val response: Response, ) { fun response(): Response = response - fun objects(): List = response().objects() + fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { if (this === other) { @@ -35,21 +35,21 @@ private constructor( } return other is ProjectListPage && - this.projectService == other.projectService && + this.projectsService == other.projectsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - projectService, + projectsService, params, response, ) } override fun toString() = - "ProjectListPage{projectService=$projectService, params=$params, response=$response}" + "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { projectService.list(it) } + return getNextPageParams().map { projectsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -86,9 +86,9 @@ private constructor( companion object { @JvmStatic - fun of(projectService: ProjectService, params: ProjectListParams, response: Response) = + fun of(projectsService: ProjectService, params: ProjectListParams, response: Response) = ProjectListPage( - projectService, + projectsService, params, response, ) @@ -98,16 +98,16 @@ private constructor( @NoAutoDetect class Response constructor( - private val objects: JsonField>, + private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() + fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") - fun _objects(): Optional>> = Optional.ofNullable(objects) + fun _objects(): Optional>> = Optional.ofNullable(objects) @JsonAnyGetter @ExcludeMissing @@ -146,7 +146,7 @@ private constructor( class Builder { - private var objects: JsonField> = JsonMissing.of() + private var objects: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -155,10 +155,10 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun objects(objects: List) = objects(JsonField.of(objects)) + fun objects(objects: List) = objects(JsonField.of(objects)) @JsonProperty("objects") - fun objects(objects: JsonField>) = apply { this.objects = objects } + fun objects(objects: JsonField>) = apply { this.objects = objects } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { @@ -172,9 +172,9 @@ private constructor( class AutoPager constructor( private val firstPage: ProjectListPage, - ) : Iterable { + ) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -186,7 +186,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { 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 896cdd0..15bb897 100755 --- 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 @@ -21,14 +21,14 @@ import java.util.function.Predicate class ProjectListPageAsync private constructor( - private val projectService: ProjectServiceAsync, + private val projectsService: ProjectServiceAsync, private val params: ProjectListParams, private val response: Response, ) { fun response(): Response = response - fun objects(): List = response().objects() + fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { if (this === other) { @@ -36,21 +36,21 @@ private constructor( } return other is ProjectListPageAsync && - this.projectService == other.projectService && + this.projectsService == other.projectsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - projectService, + projectsService, params, response, ) } override fun toString() = - "ProjectListPageAsync{projectService=$projectService, params=$params, response=$response}" + "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { projectService.list(it).thenApply { Optional.of(it) } } + .map { projectsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -89,9 +89,13 @@ private constructor( companion object { @JvmStatic - fun of(projectService: ProjectServiceAsync, params: ProjectListParams, response: Response) = + fun of( + projectsService: ProjectServiceAsync, + params: ProjectListParams, + response: Response + ) = ProjectListPageAsync( - projectService, + projectsService, params, response, ) @@ -101,16 +105,16 @@ private constructor( @NoAutoDetect class Response constructor( - private val objects: JsonField>, + private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() + fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") - fun _objects(): Optional>> = Optional.ofNullable(objects) + fun _objects(): Optional>> = Optional.ofNullable(objects) @JsonAnyGetter @ExcludeMissing @@ -149,7 +153,7 @@ private constructor( class Builder { - private var objects: JsonField> = JsonMissing.of() + private var objects: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -158,10 +162,10 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun objects(objects: List) = objects(JsonField.of(objects)) + fun objects(objects: List) = objects(JsonField.of(objects)) @JsonProperty("objects") - fun objects(objects: JsonField>) = apply { this.objects = objects } + fun objects(objects: JsonField>) = apply { this.objects = objects } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { @@ -177,9 +181,9 @@ private constructor( private val firstPage: ProjectListPageAsync, ) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (ProjectModel) -> Boolean, + action: (Project) -> Boolean, executor: Executor ): CompletableFuture = thenComposeAsync( @@ -195,8 +199,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 6b1b3e0..f638afa 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class ProjectScoreListPage private constructor( - private val projectScoreService: ProjectScoreService, + private val projectScoresService: ProjectScoreService, private val params: ProjectScoreListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is ProjectScoreListPage && - this.projectScoreService == other.projectScoreService && + this.projectScoresService == other.projectScoresService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - projectScoreService, + projectScoresService, params, response, ) } override fun toString() = - "ProjectScoreListPage{projectScoreService=$projectScoreService, params=$params, response=$response}" + "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { projectScoreService.list(it) } + return getNextPageParams().map { projectScoresService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -87,12 +87,12 @@ private constructor( @JvmStatic fun of( - projectScoreService: ProjectScoreService, + projectScoresService: ProjectScoreService, params: ProjectScoreListParams, response: Response ) = ProjectScoreListPage( - projectScoreService, + projectScoresService, params, response, ) 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 2ffe2e6..961d901 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class ProjectScoreListPageAsync private constructor( - private val projectScoreService: ProjectScoreServiceAsync, + private val projectScoresService: ProjectScoreServiceAsync, private val params: ProjectScoreListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is ProjectScoreListPageAsync && - this.projectScoreService == other.projectScoreService && + this.projectScoresService == other.projectScoresService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - projectScoreService, + projectScoresService, params, response, ) } override fun toString() = - "ProjectScoreListPageAsync{projectScoreService=$projectScoreService, params=$params, response=$response}" + "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { projectScoreService.list(it).thenApply { Optional.of(it) } } + .map { projectScoresService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -90,12 +90,12 @@ private constructor( @JvmStatic fun of( - projectScoreService: ProjectScoreServiceAsync, + projectScoresService: ProjectScoreServiceAsync, params: ProjectScoreListParams, response: Response ) = ProjectScoreListPageAsync( - projectScoreService, + projectScoresService, params, response, ) 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 657efac..065e040 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class ProjectTagListPage private constructor( - private val projectTagService: ProjectTagService, + private val projectTagsService: ProjectTagService, private val params: ProjectTagListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is ProjectTagListPage && - this.projectTagService == other.projectTagService && + this.projectTagsService == other.projectTagsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - projectTagService, + projectTagsService, params, response, ) } override fun toString() = - "ProjectTagListPage{projectTagService=$projectTagService, params=$params, response=$response}" + "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -78,7 +78,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { projectTagService.list(it) } + return getNextPageParams().map { projectTagsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -87,12 +87,12 @@ private constructor( @JvmStatic fun of( - projectTagService: ProjectTagService, + projectTagsService: ProjectTagService, params: ProjectTagListParams, response: Response ) = ProjectTagListPage( - projectTagService, + projectTagsService, params, response, ) 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 15814be..403a179 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class ProjectTagListPageAsync private constructor( - private val projectTagService: ProjectTagServiceAsync, + private val projectTagsService: ProjectTagServiceAsync, private val params: ProjectTagListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is ProjectTagListPageAsync && - this.projectTagService == other.projectTagService && + this.projectTagsService == other.projectTagsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - projectTagService, + projectTagsService, params, response, ) } override fun toString() = - "ProjectTagListPageAsync{projectTagService=$projectTagService, params=$params, response=$response}" + "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -80,7 +80,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { projectTagService.list(it).thenApply { Optional.of(it) } } + .map { projectTagsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -90,12 +90,12 @@ private constructor( @JvmStatic fun of( - projectTagService: ProjectTagServiceAsync, + projectTagsService: ProjectTagServiceAsync, params: ProjectTagListParams, response: Response ) = ProjectTagListPageAsync( - projectTagService, + projectTagsService, params, response, ) 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 f578e0f..3805046 100755 --- 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 @@ -459,41 +459,47 @@ private constructor( companion object { - @JvmField val TASK = FunctionType(JsonField.of("task")) - @JvmField val LLM = FunctionType(JsonField.of("llm")) @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val TASK = FunctionType(JsonField.of("task")) + + @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } enum class Known { - TASK, LLM, SCORER, + TASK, + TOOL, } enum class Value { - TASK, LLM, SCORER, + TASK, + TOOL, _UNKNOWN, } fun value(): Value = when (this) { - TASK -> Value.TASK LLM -> Value.LLM SCORER -> Value.SCORER + TASK -> Value.TASK + TOOL -> Value.TOOL else -> Value._UNKNOWN } fun known(): Known = when (this) { - TASK -> Known.TASK LLM -> Known.LLM SCORER -> Known.SCORER + TASK -> Known.TASK + TOOL -> Known.TOOL else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } 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 049be5b..5ed6436 100755 --- 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 @@ -418,41 +418,47 @@ constructor( companion object { - @JvmField val TASK = FunctionType(JsonField.of("task")) - @JvmField val LLM = FunctionType(JsonField.of("llm")) @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val TASK = FunctionType(JsonField.of("task")) + + @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } enum class Known { - TASK, LLM, SCORER, + TASK, + TOOL, } enum class Value { - TASK, LLM, SCORER, + TASK, + TOOL, _UNKNOWN, } fun value(): Value = when (this) { - TASK -> Value.TASK LLM -> Value.LLM SCORER -> Value.SCORER + TASK -> Value.TASK + TOOL -> Value.TOOL else -> Value._UNKNOWN } fun known(): Known = when (this) { - TASK -> Known.TASK LLM -> Known.LLM SCORER -> Known.SCORER + TASK -> Known.TASK + TOOL -> Known.TOOL else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index aa87941..39ea047 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -35,6 +35,7 @@ private constructor( private val prompt: JsonField, private val options: JsonField, private val parser: JsonField, + private val toolFunctions: JsonField>, private val origin: JsonField, private val additionalProperties: Map, ) { @@ -49,6 +50,9 @@ private constructor( fun parser(): Optional = Optional.ofNullable(parser.getNullable("parser")) + fun toolFunctions(): Optional> = + Optional.ofNullable(toolFunctions.getNullable("tool_functions")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt @@ -57,6 +61,8 @@ private constructor( @JsonProperty("parser") @ExcludeMissing fun _parser() = parser + @JsonProperty("tool_functions") @ExcludeMissing fun _toolFunctions() = toolFunctions + @JsonProperty("origin") @ExcludeMissing fun _origin() = origin @JsonAnyGetter @@ -68,6 +74,7 @@ private constructor( prompt() options().map { it.validate() } parser().map { it.validate() } + toolFunctions() origin().map { it.validate() } validated = true } @@ -84,6 +91,7 @@ private constructor( this.prompt == other.prompt && this.options == other.options && this.parser == other.parser && + this.toolFunctions == other.toolFunctions && this.origin == other.origin && this.additionalProperties == other.additionalProperties } @@ -95,6 +103,7 @@ private constructor( prompt, options, parser, + toolFunctions, origin, additionalProperties, ) @@ -103,7 +112,7 @@ private constructor( } override fun toString() = - "PromptData{prompt=$prompt, options=$options, parser=$parser, origin=$origin, additionalProperties=$additionalProperties}" + "PromptData{prompt=$prompt, options=$options, parser=$parser, toolFunctions=$toolFunctions, origin=$origin, additionalProperties=$additionalProperties}" companion object { @@ -115,6 +124,7 @@ private constructor( private var prompt: JsonField = JsonMissing.of() private var options: JsonField = JsonMissing.of() private var parser: JsonField = JsonMissing.of() + private var toolFunctions: JsonField> = JsonMissing.of() private var origin: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -123,6 +133,7 @@ private constructor( this.prompt = promptData.prompt this.options = promptData.options this.parser = promptData.parser + this.toolFunctions = promptData.toolFunctions this.origin = promptData.origin additionalProperties(promptData.additionalProperties) } @@ -145,6 +156,15 @@ private constructor( @ExcludeMissing fun parser(parser: JsonField) = apply { this.parser = parser } + fun toolFunctions(toolFunctions: List) = + toolFunctions(JsonField.of(toolFunctions)) + + @JsonProperty("tool_functions") + @ExcludeMissing + fun toolFunctions(toolFunctions: JsonField>) = apply { + this.toolFunctions = toolFunctions + } + fun origin(origin: Origin) = origin(JsonField.of(origin)) @JsonProperty("origin") @@ -170,6 +190,7 @@ private constructor( prompt, options, parser, + toolFunctions.map { it.toUnmodifiable() }, origin, additionalProperties.toUnmodifiable(), ) @@ -6028,4 +6049,455 @@ private constructor( } } } + + @JsonDeserialize(using = ToolFunction.Deserializer::class) + @JsonSerialize(using = ToolFunction.Serializer::class) + class ToolFunction + private constructor( + private val function: Function? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun function(): Optional = Optional.ofNullable(function) + + fun global(): Optional = Optional.ofNullable(global) + + fun isFunction(): Boolean = function != null + + fun isGlobal(): Boolean = global != null + + fun asFunction(): Function = function.getOrThrow("function") + + fun asGlobal(): Global = global.getOrThrow("global") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + function != null -> visitor.visitFunction(function) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } + } + + fun validate(): ToolFunction = apply { + if (!validated) { + if (function == null && global == null) { + throw BraintrustInvalidDataException("Unknown ToolFunction: $_json") + } + function?.validate() + global?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolFunction && + this.function == other.function && + this.global == other.global + } + + override fun hashCode(): Int { + return Objects.hash(function, global) + } + + override fun toString(): String { + return when { + function != null -> "ToolFunction{function=$function}" + global != null -> "ToolFunction{global=$global}" + _json != null -> "ToolFunction{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolFunction") + } + } + + companion object { + + @JvmStatic fun ofFunction(function: Function) = ToolFunction(function = function) + + @JvmStatic fun ofGlobal(global: Global) = ToolFunction(global = global) + } + + interface Visitor { + + fun visitFunction(function: Function): T + + fun visitGlobal(global: Global): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ToolFunction: $json") + } + } + + class Deserializer : BaseDeserializer(ToolFunction::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolFunction { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolFunction(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolFunction(global = it, _json = json) + } + + return ToolFunction(_json = json) + } + } + + class Serializer : BaseSerializer(ToolFunction::class) { + + override fun serialize( + value: ToolFunction, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.function != null -> generator.writeObject(value.function) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolFunction") + } + } + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val type: JsonField, + private val id: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun id(): String = id.getRequired("id") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("id") @ExcludeMissing fun _id() = id + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + id() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Function && + this.type == other.type && + this.id == other.id && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + type, + id, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.id = function.id + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun id(id: String) = id(JsonField.of(id)) + + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + 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(): Function = + Function( + type, + id, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _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 asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = Global.Builder::class) + @NoAutoDetect + class Global + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun type(): Type = type.getRequired("type") + + fun name(): String = name.getRequired("name") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Global = apply { + if (!validated) { + type() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + 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 + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + 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 name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + 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(): Global = + Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) + } + + 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 + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val GLOBAL = Type(JsonField.of("global")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + GLOBAL, + } + + enum class Value { + GLOBAL, + _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 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 61ac7c4..43cda3c 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class PromptListPage private constructor( - private val promptService: PromptService, + private val promptsService: PromptService, private val params: PromptListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is PromptListPage && - this.promptService == other.promptService && + this.promptsService == other.promptsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - promptService, + promptsService, params, response, ) } override fun toString() = - "PromptListPage{promptService=$promptService, params=$params, response=$response}" + "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -72,7 +72,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { promptService.list(it) } + return getNextPageParams().map { promptsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,9 +80,9 @@ private constructor( companion object { @JvmStatic - fun of(promptService: PromptService, params: PromptListParams, response: Response) = + fun of(promptsService: PromptService, params: PromptListParams, response: Response) = PromptListPage( - promptService, + promptsService, params, response, ) 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 a776f47..31a7d45 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class PromptListPageAsync private constructor( - private val promptService: PromptServiceAsync, + private val promptsService: PromptServiceAsync, private val params: PromptListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is PromptListPageAsync && - this.promptService == other.promptService && + this.promptsService == other.promptsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - promptService, + promptsService, params, response, ) } override fun toString() = - "PromptListPageAsync{promptService=$promptService, params=$params, response=$response}" + "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -74,7 +74,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { promptService.list(it).thenApply { Optional.of(it) } } + .map { promptsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -83,9 +83,9 @@ private constructor( companion object { @JvmStatic - fun of(promptService: PromptServiceAsync, params: PromptListParams, response: Response) = + fun of(promptsService: PromptServiceAsync, params: PromptListParams, response: Response) = PromptListPageAsync( - promptService, + promptsService, params, response, ) 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 594bb40..ae734d5 100755 --- 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 @@ -418,41 +418,47 @@ constructor( companion object { - @JvmField val TASK = FunctionType(JsonField.of("task")) - @JvmField val LLM = FunctionType(JsonField.of("llm")) @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val TASK = FunctionType(JsonField.of("task")) + + @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } enum class Known { - TASK, LLM, SCORER, + TASK, + TOOL, } enum class Value { - TASK, LLM, SCORER, + TASK, + TOOL, _UNKNOWN, } fun value(): Value = when (this) { - TASK -> Value.TASK LLM -> Value.LLM SCORER -> Value.SCORER + TASK -> Value.TASK + TOOL -> Value.TOOL else -> Value._UNKNOWN } fun known(): Known = when (this) { - TASK -> Known.TASK LLM -> Known.LLM SCORER -> Known.SCORER + TASK -> Known.TASK + TOOL -> Known.TOOL else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } 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 0847343..d49ae5d 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class RoleListPage private constructor( - private val roleService: RoleService, + private val rolesService: RoleService, private val params: RoleListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is RoleListPage && - this.roleService == other.roleService && + this.rolesService == other.rolesService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - roleService, + rolesService, params, response, ) } override fun toString() = - "RoleListPage{roleService=$roleService, params=$params, response=$response}" + "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -72,7 +72,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { roleService.list(it) } + return getNextPageParams().map { rolesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,9 +80,9 @@ private constructor( companion object { @JvmStatic - fun of(roleService: RoleService, params: RoleListParams, response: Response) = + fun of(rolesService: RoleService, params: RoleListParams, response: Response) = RoleListPage( - roleService, + rolesService, params, response, ) 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 7f3bc07..a53c7f0 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class RoleListPageAsync private constructor( - private val roleService: RoleServiceAsync, + private val rolesService: RoleServiceAsync, private val params: RoleListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is RoleListPageAsync && - this.roleService == other.roleService && + this.rolesService == other.rolesService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - roleService, + rolesService, params, response, ) } override fun toString() = - "RoleListPageAsync{roleService=$roleService, params=$params, response=$response}" + "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -74,7 +74,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { roleService.list(it).thenApply { Optional.of(it) } } + .map { rolesService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -83,9 +83,9 @@ private constructor( companion object { @JvmStatic - fun of(roleService: RoleServiceAsync, params: RoleListParams, response: Response) = + fun of(rolesService: RoleServiceAsync, params: RoleListParams, response: Response) = RoleListPageAsync( - roleService, + rolesService, params, response, ) 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 77970eb..75c893f 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class UserListPage private constructor( - private val userService: UserService, + private val usersService: UserService, private val params: UserListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is UserListPage && - this.userService == other.userService && + this.usersService == other.usersService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - userService, + usersService, params, response, ) } override fun toString() = - "UserListPage{userService=$userService, params=$params, response=$response}" + "UserListPage{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -72,7 +72,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { userService.list(it) } + return getNextPageParams().map { usersService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,9 +80,9 @@ private constructor( companion object { @JvmStatic - fun of(userService: UserService, params: UserListParams, response: Response) = + fun of(usersService: UserService, params: UserListParams, response: Response) = UserListPage( - userService, + usersService, params, response, ) 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 644d49a..330014e 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class UserListPageAsync private constructor( - private val userService: UserServiceAsync, + private val usersService: UserServiceAsync, private val params: UserListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is UserListPageAsync && - this.userService == other.userService && + this.usersService == other.usersService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - userService, + usersService, params, response, ) } override fun toString() = - "UserListPageAsync{userService=$userService, params=$params, response=$response}" + "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -74,7 +74,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { userService.list(it).thenApply { Optional.of(it) } } + .map { usersService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -83,9 +83,9 @@ private constructor( companion object { @JvmStatic - fun of(userService: UserServiceAsync, params: UserListParams, response: Response) = + fun of(usersService: UserServiceAsync, params: UserListParams, response: Response) = UserListPageAsync( - userService, + usersService, params, response, ) 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 187c846..4fc74c4 100755 --- 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 @@ -20,7 +20,7 @@ import java.util.stream.StreamSupport class ViewListPage private constructor( - private val viewService: ViewService, + private val viewsService: ViewService, private val params: ViewListParams, private val response: Response, ) { @@ -35,21 +35,21 @@ private constructor( } return other is ViewListPage && - this.viewService == other.viewService && + this.viewsService == other.viewsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - viewService, + viewsService, params, response, ) } override fun toString() = - "ViewListPage{viewService=$viewService, params=$params, response=$response}" + "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -72,7 +72,7 @@ private constructor( } fun getNextPage(): Optional { - return getNextPageParams().map { viewService.list(it) } + return getNextPageParams().map { viewsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,9 +80,9 @@ private constructor( companion object { @JvmStatic - fun of(viewService: ViewService, params: ViewListParams, response: Response) = + fun of(viewsService: ViewService, params: ViewListParams, response: Response) = ViewListPage( - viewService, + viewsService, params, response, ) 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 6421b2d..f781d4f 100755 --- 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 @@ -21,7 +21,7 @@ import java.util.function.Predicate class ViewListPageAsync private constructor( - private val viewService: ViewServiceAsync, + private val viewsService: ViewServiceAsync, private val params: ViewListParams, private val response: Response, ) { @@ -36,21 +36,21 @@ private constructor( } return other is ViewListPageAsync && - this.viewService == other.viewService && + this.viewsService == other.viewsService && this.params == other.params && this.response == other.response } override fun hashCode(): Int { return Objects.hash( - viewService, + viewsService, params, response, ) } override fun toString() = - "ViewListPageAsync{viewService=$viewService, params=$params, response=$response}" + "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { return !objects().isEmpty() @@ -74,7 +74,7 @@ private constructor( fun getNextPage(): CompletableFuture> { return getNextPageParams() - .map { viewService.list(it).thenApply { Optional.of(it) } } + .map { viewsService.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } @@ -83,9 +83,9 @@ private constructor( companion object { @JvmStatic - fun of(viewService: ViewServiceAsync, params: ViewListParams, response: Response) = + fun of(viewsService: ViewServiceAsync, params: ViewListParams, response: Response) = ViewListPageAsync( - viewService, + viewsService, params, response, ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt old mode 100755 new mode 100644 similarity index 68% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsync.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index 8de7c0b..3dab404 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -6,15 +6,15 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.models.ApiKeyResourceCreateParams -import com.braintrustdata.api.models.ApiKeyResourceDeleteParams -import com.braintrustdata.api.models.ApiKeyResourceListPageAsync -import com.braintrustdata.api.models.ApiKeyResourceListParams -import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams +import com.braintrustdata.api.models.ApiKeyCreateParams +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.models.CreateApiKeyOutput import java.util.concurrent.CompletableFuture -interface ApiKeyResourceServiceAsync { +interface ApiKeyServiceAsync { /** * Create a new api_key. It is possible to have multiple API keys with the same name. There is @@ -22,14 +22,14 @@ interface ApiKeyResourceServiceAsync { */ @JvmOverloads fun create( - params: ApiKeyResourceCreateParams, + params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none() ): CompletableFuture /** Get an api_key object by its id */ @JvmOverloads fun retrieve( - params: ApiKeyResourceRetrieveParams, + params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none() ): CompletableFuture @@ -39,14 +39,14 @@ interface ApiKeyResourceServiceAsync { */ @JvmOverloads fun list( - params: ApiKeyResourceListParams, + params: ApiKeyListParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Delete an api_key object by its id */ @JvmOverloads fun delete( - params: ApiKeyResourceDeleteParams, + params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none() ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt old mode 100755 new mode 100644 similarity index 86% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsyncImpl.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index 7bb5168..5228efa --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -9,11 +9,11 @@ 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.ApiKeyResourceCreateParams -import com.braintrustdata.api.models.ApiKeyResourceDeleteParams -import com.braintrustdata.api.models.ApiKeyResourceListPageAsync -import com.braintrustdata.api.models.ApiKeyResourceListParams -import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams +import com.braintrustdata.api.models.ApiKeyCreateParams +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.models.CreateApiKeyOutput import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json @@ -21,10 +21,10 @@ import com.braintrustdata.api.services.jsonHandler import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture -class ApiKeyResourceServiceAsyncImpl +class ApiKeyServiceAsyncImpl constructor( private val clientOptions: ClientOptions, -) : ApiKeyResourceServiceAsync { +) : ApiKeyServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -36,7 +36,7 @@ constructor( * no de-duplication */ override fun create( - params: ApiKeyResourceCreateParams, + params: ApiKeyCreateParams, requestOptions: RequestOptions ): CompletableFuture { val request = @@ -66,7 +66,7 @@ constructor( /** Get an api_key object by its id */ override fun retrieve( - params: ApiKeyResourceRetrieveParams, + params: ApiKeyRetrieveParams, requestOptions: RequestOptions ): CompletableFuture { val request = @@ -90,8 +90,8 @@ constructor( } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) /** @@ -99,9 +99,9 @@ constructor( * recently-created api_keys coming first */ override fun list( - params: ApiKeyResourceListParams, + params: ApiKeyListParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -120,7 +120,7 @@ constructor( validate() } } - .let { ApiKeyResourceListPageAsync.of(this, params, it) } + .let { ApiKeyListPageAsync.of(this, params, it) } } } @@ -129,7 +129,7 @@ constructor( /** Delete an api_key object by its id */ override fun delete( - params: ApiKeyResourceDeleteParams, + params: ApiKeyDeleteParams, requestOptions: RequestOptions ): CompletableFuture { val request = 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 b0d82ff..f1cd38e 100755 --- 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 @@ -11,7 +11,7 @@ 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.services.async.organization.MemberServiceAsync +import com.braintrustdata.api.services.async.organizations.MemberServiceAsync import java.util.concurrent.CompletableFuture interface OrganizationServiceAsync { 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 5be7cfb..2ff92c1 100755 --- 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 @@ -14,8 +14,8 @@ 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.services.async.organization.MemberServiceAsync -import com.braintrustdata.api.services.async.organization.MemberServiceAsyncImpl +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 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 f1ed1db..a9b81dd 100755 --- 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 @@ -5,14 +5,14 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams -import com.braintrustdata.api.models.ProjectModel import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.services.async.project.LogServiceAsync +import com.braintrustdata.api.services.async.projects.LogServiceAsync import java.util.concurrent.CompletableFuture interface ProjectServiceAsync { @@ -27,14 +27,14 @@ interface ProjectServiceAsync { fun create( params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Get a project object by its id */ @JvmOverloads fun retrieve( params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * Partially update a project object. Specify the fields to update in the payload. Any @@ -45,7 +45,7 @@ interface ProjectServiceAsync { fun update( params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** * List out all projects. The projects are sorted by creation date, with the most @@ -62,5 +62,5 @@ interface ProjectServiceAsync { fun delete( params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): 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 e85462e..02e1fd7 100755 --- 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 @@ -8,15 +8,15 @@ 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 import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams -import com.braintrustdata.api.models.ProjectModel import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.services.async.project.LogServiceAsync -import com.braintrustdata.api.services.async.project.LogServiceAsyncImpl +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 @@ -34,8 +34,8 @@ constructor( override fun logs(): LogServiceAsync = logs - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Create a new project. If there is an existing project with the same name as the one specified @@ -44,7 +44,7 @@ constructor( override fun create( params: ProjectCreateParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -67,14 +67,14 @@ constructor( } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project object by its id */ override fun retrieve( params: ProjectRetrieveParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -96,8 +96,8 @@ constructor( } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** * Partially update a project object. Specify the fields to update in the payload. Any @@ -107,7 +107,7 @@ constructor( override fun update( params: ProjectUpdateParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.PATCH) @@ -164,14 +164,14 @@ constructor( } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project object by its id */ override fun delete( params: ProjectDeleteParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt old mode 100755 new mode 100644 similarity index 91% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsync.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index 8908f63..435ede1 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -2,7 +2,7 @@ @file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 -package com.braintrustdata.api.services.async.organization +package com.braintrustdata.api.services.async.organizations import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.OrganizationMemberUpdateParams diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt old mode 100755 new mode 100644 similarity index 97% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsyncImpl.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 0ed1ef2..267cbeb --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.braintrustdata.api.services.async.organization +package com.braintrustdata.api.services.async.organizations import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions 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/projects/LogServiceAsync.kt old mode 100755 new mode 100644 similarity index 97% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index fa08e46..e799ba0 --- 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/projects/LogServiceAsync.kt @@ -2,7 +2,7 @@ @file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 -package com.braintrustdata.api.services.async.project +package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema 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/projects/LogServiceAsyncImpl.kt old mode 100755 new mode 100644 similarity index 99% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 436cef4..23037f3 --- 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/projects/LogServiceAsyncImpl.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.braintrustdata.api.services.async.project +package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt old mode 100755 new mode 100644 similarity index 67% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceService.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index 55e8dae..a98e1d7 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -6,14 +6,14 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.models.ApiKeyResourceCreateParams -import com.braintrustdata.api.models.ApiKeyResourceDeleteParams -import com.braintrustdata.api.models.ApiKeyResourceListPage -import com.braintrustdata.api.models.ApiKeyResourceListParams -import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams +import com.braintrustdata.api.models.ApiKeyCreateParams +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.models.CreateApiKeyOutput -interface ApiKeyResourceService { +interface ApiKeyService { /** * Create a new api_key. It is possible to have multiple API keys with the same name. There is @@ -21,14 +21,14 @@ interface ApiKeyResourceService { */ @JvmOverloads fun create( - params: ApiKeyResourceCreateParams, + params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none() ): CreateApiKeyOutput /** Get an api_key object by its id */ @JvmOverloads fun retrieve( - params: ApiKeyResourceRetrieveParams, + params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none() ): ApiKey @@ -38,14 +38,14 @@ interface ApiKeyResourceService { */ @JvmOverloads fun list( - params: ApiKeyResourceListParams, + params: ApiKeyListParams, requestOptions: RequestOptions = RequestOptions.none() - ): ApiKeyResourceListPage + ): ApiKeyListPage /** Delete an api_key object by its id */ @JvmOverloads fun delete( - params: ApiKeyResourceDeleteParams, + params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none() ): ApiKey } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt old mode 100755 new mode 100644 similarity index 83% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceImpl.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 2ccd752..5b705c6 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -9,21 +9,21 @@ 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.ApiKeyResourceCreateParams -import com.braintrustdata.api.models.ApiKeyResourceDeleteParams -import com.braintrustdata.api.models.ApiKeyResourceListPage -import com.braintrustdata.api.models.ApiKeyResourceListParams -import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams +import com.braintrustdata.api.models.ApiKeyCreateParams +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.models.CreateApiKeyOutput 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 ApiKeyResourceServiceImpl +class ApiKeyServiceImpl constructor( private val clientOptions: ClientOptions, -) : ApiKeyResourceService { +) : ApiKeyService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -35,7 +35,7 @@ constructor( * no de-duplication */ override fun create( - params: ApiKeyResourceCreateParams, + params: ApiKeyCreateParams, requestOptions: RequestOptions ): CreateApiKeyOutput { val request = @@ -63,10 +63,7 @@ constructor( jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get an api_key object by its id */ - override fun retrieve( - params: ApiKeyResourceRetrieveParams, - requestOptions: RequestOptions - ): ApiKey { + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): ApiKey { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -87,18 +84,15 @@ constructor( } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + 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: ApiKeyResourceListParams, - requestOptions: RequestOptions - ): ApiKeyResourceListPage { + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): ApiKeyListPage { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -116,7 +110,7 @@ constructor( validate() } } - .let { ApiKeyResourceListPage.of(this, params, it) } + .let { ApiKeyListPage.of(this, params, it) } } } @@ -124,10 +118,7 @@ constructor( jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete an api_key object by its id */ - override fun delete( - params: ApiKeyResourceDeleteParams, - requestOptions: RequestOptions - ): ApiKey { + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): ApiKey { val request = HttpRequest.builder() .method(HttpMethod.DELETE) 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 863042a..f4ca1ae 100755 --- 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 @@ -11,7 +11,7 @@ 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.services.blocking.organization.MemberService +import com.braintrustdata.api.services.blocking.organizations.MemberService interface OrganizationService { 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 b30ba29..786fc86 100755 --- 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 @@ -14,8 +14,8 @@ 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.services.blocking.organization.MemberService -import com.braintrustdata.api.services.blocking.organization.MemberServiceImpl +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 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 a6fe064..3c46992 100755 --- 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 @@ -5,14 +5,14 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListParams -import com.braintrustdata.api.models.ProjectModel import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.services.blocking.project.LogService +import com.braintrustdata.api.services.blocking.projects.LogService interface ProjectService { @@ -26,14 +26,14 @@ interface ProjectService { fun create( params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectModel + ): Project /** Get a project object by its id */ @JvmOverloads fun retrieve( params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectModel + ): Project /** * Partially update a project object. Specify the fields to update in the payload. Any @@ -44,7 +44,7 @@ interface ProjectService { fun update( params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectModel + ): Project /** * List out all projects. The projects are sorted by creation date, with the most @@ -61,5 +61,5 @@ interface ProjectService { fun delete( params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectModel + ): 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 a0b65df..9a16636 100755 --- 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 @@ -8,15 +8,15 @@ 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 import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListParams -import com.braintrustdata.api.models.ProjectModel import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.services.blocking.project.LogService -import com.braintrustdata.api.services.blocking.project.LogServiceImpl +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 @@ -33,14 +33,14 @@ constructor( override fun logs(): LogService = logs - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + 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 */ - override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): ProjectModel { + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): Project { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -62,14 +62,11 @@ constructor( } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Get a project object by its id */ - override fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions - ): ProjectModel { + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): Project { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -90,15 +87,15 @@ constructor( } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + 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. */ - override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): ProjectModel { + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): Project { val request = HttpRequest.builder() .method(HttpMethod.PATCH) @@ -150,11 +147,11 @@ constructor( } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Delete a project object by its id */ - override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): ProjectModel { + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): Project { val request = HttpRequest.builder() .method(HttpMethod.DELETE) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt old mode 100755 new mode 100644 similarity index 90% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberService.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index 0dc6f69..29561e1 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -2,7 +2,7 @@ @file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 -package com.braintrustdata.api.services.blocking.organization +package com.braintrustdata.api.services.blocking.organizations import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.OrganizationMemberUpdateParams diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt old mode 100755 new mode 100644 similarity index 97% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceImpl.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index bad7cfd..b8126ca --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.braintrustdata.api.services.blocking.organization +package com.braintrustdata.api.services.blocking.organizations import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions 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/projects/LogService.kt old mode 100755 new mode 100644 similarity index 96% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index 23c9bb6..796bb9e --- 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/projects/LogService.kt @@ -2,7 +2,7 @@ @file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 -package com.braintrustdata.api.services.blocking.project +package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema 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/projects/LogServiceImpl.kt old mode 100755 new mode 100644 similarity index 99% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index a176052..9f21671 --- 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/projects/LogServiceImpl.kt @@ -1,6 +1,6 @@ // 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.core.ClientOptions import com.braintrustdata.api.core.RequestOptions diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt old mode 100755 new mode 100644 similarity index 64% rename from braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParamsTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index cbb7c68..8c337a4 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -6,16 +6,16 @@ import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyResourceCreateParamsTest { +class ApiKeyCreateParamsTest { @Test - fun createApiKeyResourceCreateParams() { - ApiKeyResourceCreateParams.builder().name("name").orgName("org_name").build() + fun createApiKeyCreateParams() { + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() } @Test fun getBody() { - val params = ApiKeyResourceCreateParams.builder().name("name").orgName("org_name").build() + val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") @@ -24,7 +24,7 @@ class ApiKeyResourceCreateParamsTest { @Test fun getBodyWithoutOptionalFields() { - val params = ApiKeyResourceCreateParams.builder().name("name").build() + 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/ApiKeyResourceDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt old mode 100755 new mode 100644 similarity index 61% rename from braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParamsTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt index d260995..bbcd063 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt @@ -6,21 +6,17 @@ import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyResourceDeleteParamsTest { +class ApiKeyDeleteParamsTest { @Test - fun createApiKeyResourceDeleteParams() { - ApiKeyResourceDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + fun createApiKeyDeleteParams() { + ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { val params = - ApiKeyResourceDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + 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") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt old mode 100755 new mode 100644 similarity index 72% rename from braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParamsTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index f02098f..e749c8e --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -6,14 +6,14 @@ import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyResourceListParamsTest { +class ApiKeyListParamsTest { @Test - fun createApiKeyResourceListParams() { - ApiKeyResourceListParams.builder() + fun createApiKeyListParams() { + ApiKeyListParams.builder() .apiKeyName("api_key_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyResourceListParams.Ids.ofString("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") @@ -23,10 +23,10 @@ class ApiKeyResourceListParamsTest { @Test fun getQueryParams() { val params = - ApiKeyResourceListParams.builder() + ApiKeyListParams.builder() .apiKeyName("api_key_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyResourceListParams.Ids.ofString("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") @@ -36,10 +36,7 @@ class ApiKeyResourceListParamsTest { expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) expected.put( "ids", - listOf( - ApiKeyResourceListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .toString() - ) + listOf(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) ) expected.put("limit", listOf("123")) expected.put("org_name", listOf("org_name")) @@ -49,7 +46,7 @@ class ApiKeyResourceListParamsTest { @Test fun getQueryParamsWithoutOptionalFields() { - val params = ApiKeyResourceListParams.builder().build() + 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/ApiKeyResourceRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt old mode 100755 new mode 100644 similarity index 60% rename from braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParamsTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt index 47b4cff..48a5016 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt @@ -6,21 +6,17 @@ import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyResourceRetrieveParamsTest { +class ApiKeyRetrieveParamsTest { @Test - fun createApiKeyResourceRetrieveParams() { - ApiKeyResourceRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + fun createApiKeyRetrieveParams() { + ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { val params = - ApiKeyResourceRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + 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") 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 index d5ab148..3a0223e 100755 --- 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 @@ -2,6 +2,7 @@ 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 @@ -22,7 +23,13 @@ class FunctionCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(FunctionCreateParams.FunctionType.TASK) + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) .origin( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -104,6 +111,16 @@ class FunctionCreateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -125,7 +142,13 @@ class FunctionCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(FunctionCreateParams.FunctionType.TASK) + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) .origin( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -209,6 +232,16 @@ class FunctionCreateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -227,7 +260,14 @@ class FunctionCreateParamsTest { assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("slug") assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(FunctionCreateParams.FunctionType.TASK) + assertThat(body.functionSchema()) + .isEqualTo( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + assertThat(body.functionType()).isEqualTo(FunctionCreateParams.FunctionType.LLM) assertThat(body.origin()) .isEqualTo( FunctionCreateParams.Origin.builder() @@ -311,6 +351,16 @@ class FunctionCreateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) assertThat(body.tags()).isEqualTo(listOf("string")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index 13772aa..2c0cde6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -14,6 +14,18 @@ class FunctionInvokeParamsTest { FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .input(JsonValue.from(mapOf())) + .messages( + listOf( + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + ) + ) + .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.ofSpanParentStruct( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -46,6 +58,18 @@ class FunctionInvokeParamsTest { FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .input(JsonValue.from(mapOf())) + .messages( + listOf( + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + ) + ) + .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.ofSpanParentStruct( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -74,6 +98,19 @@ class FunctionInvokeParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.messages()) + .isEqualTo( + listOf( + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + ) + ) + assertThat(body.mode()).isEqualTo(FunctionInvokeParams.Mode.AUTO) assertThat(body.parent()) .isEqualTo( FunctionInvokeParams.Parent.ofSpanParentStruct( 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 index 485142e..f03eadb 100755 --- 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 @@ -2,6 +2,7 @@ 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 @@ -22,7 +23,13 @@ class FunctionReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(FunctionReplaceParams.FunctionType.TASK) + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) .origin( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -104,6 +111,16 @@ class FunctionReplaceParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -125,7 +142,13 @@ class FunctionReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(FunctionReplaceParams.FunctionType.TASK) + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) .origin( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -209,6 +232,16 @@ class FunctionReplaceParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -227,7 +260,14 @@ class FunctionReplaceParamsTest { assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("slug") assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(FunctionReplaceParams.FunctionType.TASK) + assertThat(body.functionSchema()) + .isEqualTo( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + assertThat(body.functionType()).isEqualTo(FunctionReplaceParams.FunctionType.LLM) assertThat(body.origin()) .isEqualTo( FunctionReplaceParams.Origin.builder() @@ -311,6 +351,16 @@ class FunctionReplaceParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) assertThat(body.tags()).isEqualTo(listOf("string")) 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 index 7d654a2..4f44ff8 100755 --- 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 @@ -2,6 +2,7 @@ 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 @@ -28,7 +29,13 @@ class FunctionTest { .slug("slug") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .functionType(Function.FunctionType.TASK) + .functionSchema( + Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(Function.FunctionType.LLM) .metadata(Function.Metadata.builder().build()) .origin( Function.Origin.builder() @@ -113,6 +120,16 @@ class FunctionTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -135,7 +152,14 @@ class FunctionTest { assertThat(function.slug()).isEqualTo("slug") assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(function.description()).contains("description") - assertThat(function.functionType()).contains(Function.FunctionType.TASK) + assertThat(function.functionSchema()) + .contains( + Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + assertThat(function.functionType()).contains(Function.FunctionType.LLM) assertThat(function.metadata()).contains(Function.Metadata.builder().build()) assertThat(function.origin()) .contains( @@ -220,6 +244,16 @@ class FunctionTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .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 index c151824..a4047d7 100755 --- 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 @@ -95,6 +95,16 @@ class FunctionUpdateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -191,6 +201,16 @@ class FunctionUpdateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -282,6 +302,16 @@ class FunctionUpdateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) assertThat(body.tags()).isEqualTo(listOf("string")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectModelTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectModelTest.kt deleted file mode 100644 index 2f8e5f4..0000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectModelTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -// 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 ProjectModelTest { - - @Test - fun createProjectModel() { - val projectModel = - ProjectModel.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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(ProjectModel.Settings.builder().comparisonKey("comparison_key").build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(projectModel).isNotNull - assertThat(projectModel.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectModel.name()).isEqualTo("name") - assertThat(projectModel.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectModel.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectModel.deletedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectModel.settings()) - .contains(ProjectModel.Settings.builder().comparisonKey("comparison_key").build()) - assertThat(projectModel.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} 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 new file mode 100644 index 0000000..08b9f5f --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.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 ProjectTest { + + @Test + fun createProject() { + val project = + Project.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .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("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/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 731eec6..54a5664 100755 --- 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 @@ -15,7 +15,7 @@ class PromptCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(PromptCreateParams.FunctionType.TASK) + .functionType(PromptCreateParams.FunctionType.LLM) .promptData( PromptData.builder() .options( @@ -90,6 +90,16 @@ class PromptCreateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -104,7 +114,7 @@ class PromptCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(PromptCreateParams.FunctionType.TASK) + .functionType(PromptCreateParams.FunctionType.LLM) .promptData( PromptData.builder() .options( @@ -181,6 +191,16 @@ class PromptCreateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -191,7 +211,7 @@ class PromptCreateParamsTest { assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("slug") assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(PromptCreateParams.FunctionType.TASK) + assertThat(body.functionType()).isEqualTo(PromptCreateParams.FunctionType.LLM) assertThat(body.promptData()) .isEqualTo( PromptData.builder() @@ -267,6 +287,16 @@ class PromptCreateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) assertThat(body.tags()).isEqualTo(listOf("string")) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 3e88311..8cf2119 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -82,6 +82,16 @@ class PromptDataTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() assertThat(promptData).isNotNull assertThat(promptData.options()) @@ -154,5 +164,14 @@ class PromptDataTest { .build() ) ) + assertThat(promptData.toolFunctions().get()) + .containsExactly( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) } } 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 57fcf3b..8246ec4 100755 --- 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 @@ -15,7 +15,7 @@ class PromptReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(PromptReplaceParams.FunctionType.TASK) + .functionType(PromptReplaceParams.FunctionType.LLM) .promptData( PromptData.builder() .options( @@ -90,6 +90,16 @@ class PromptReplaceParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -104,7 +114,7 @@ class PromptReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(PromptReplaceParams.FunctionType.TASK) + .functionType(PromptReplaceParams.FunctionType.LLM) .promptData( PromptData.builder() .options( @@ -181,6 +191,16 @@ class PromptReplaceParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -191,7 +211,7 @@ class PromptReplaceParamsTest { assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("slug") assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(PromptReplaceParams.FunctionType.TASK) + assertThat(body.functionType()).isEqualTo(PromptReplaceParams.FunctionType.LLM) assertThat(body.promptData()) .isEqualTo( PromptData.builder() @@ -267,6 +287,16 @@ class PromptReplaceParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) assertThat(body.tags()).isEqualTo(listOf("string")) 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 be38a4c..2c5c390 100755 --- 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 @@ -21,7 +21,7 @@ class PromptTest { .slug("slug") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .functionType(Prompt.FunctionType.TASK) + .functionType(Prompt.FunctionType.LLM) .metadata(Prompt.Metadata.builder().build()) .promptData( PromptData.builder() @@ -99,6 +99,16 @@ class PromptTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -113,7 +123,7 @@ class PromptTest { assertThat(prompt.slug()).isEqualTo("slug") assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(prompt.description()).contains("description") - assertThat(prompt.functionType()).contains(Prompt.FunctionType.TASK) + assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) assertThat(prompt.metadata()).contains(Prompt.Metadata.builder().build()) assertThat(prompt.promptData()) .contains( @@ -190,6 +200,16 @@ class PromptTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) assertThat(prompt.tags().get()).containsExactly("string") 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 f649bc3..8fe85bd 100755 --- 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 @@ -88,6 +88,16 @@ class PromptUpdateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .slug("slug") @@ -178,6 +188,16 @@ class PromptUpdateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .slug("slug") @@ -262,6 +282,16 @@ class PromptUpdateParamsTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) assertThat(body.slug()).isEqualTo("slug") 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 3eb8525..e67c569 100755 --- 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 @@ -60,19 +60,19 @@ class ErrorHandlingTest { val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() val expected = - ProjectModel.builder() + Project.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .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(ProjectModel.Settings.builder().comparisonKey("comparison_key").build()) + .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 @@ -84,7 +84,7 @@ class ErrorHandlingTest { .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) }) @@ -99,7 +99,7 @@ class ErrorHandlingTest { .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) }) @@ -114,7 +114,7 @@ class ErrorHandlingTest { .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) }) @@ -129,7 +129,7 @@ class ErrorHandlingTest { .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) }) @@ -144,7 +144,7 @@ class ErrorHandlingTest { .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertUnprocessableEntity( e, @@ -163,7 +163,7 @@ class ErrorHandlingTest { .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) }) @@ -178,7 +178,7 @@ class ErrorHandlingTest { .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) }) @@ -193,7 +193,7 @@ class ErrorHandlingTest { .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) ) - assertThatThrownBy({ client.project().create(params) }) + assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> assertUnexpectedStatusCodeException( e, @@ -210,7 +210,7 @@ class ErrorHandlingTest { 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) @@ -224,7 +224,7 @@ class ErrorHandlingTest { 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 95f7393..f7915e8 100755 --- 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 @@ -65,13 +65,13 @@ class ServiceParamsTest { .build() val apiResponse = - ProjectModel.builder() + Project.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .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(ProjectModel.Settings.builder().comparisonKey("comparison_key").build()) + .settings(Project.Settings.builder().comparisonKey("comparison_key").build()) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -83,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 fcf76e6..60f068b 100755 --- 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() @@ -91,7 +91,7 @@ class AclServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aclService = client.acl() + val aclService = client.acls() val aclBatchUpdateResponse = aclService.batchUpdate( AclBatchUpdateParams.builder() @@ -138,7 +138,7 @@ class AclServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aclService = client.acl() + val aclService = client.acls() val acl = aclService.findAndDelete( AclFindAndDeleteParams.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index 6214ccc..2eb15e8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -19,7 +19,7 @@ class AiSecretServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aiSecretService = client.aiSecret() + val aiSecretService = client.aiSecrets() val aISecret = aiSecretService.create( AiSecretCreateParams.builder() @@ -41,7 +41,7 @@ class AiSecretServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aiSecretService = client.aiSecret() + val aiSecretService = client.aiSecrets() val aISecret = aiSecretService.retrieve( AiSecretRetrieveParams.builder() @@ -59,7 +59,7 @@ class AiSecretServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aiSecretService = client.aiSecret() + val aiSecretService = client.aiSecrets() val aISecret = aiSecretService.update( AiSecretUpdateParams.builder() @@ -81,7 +81,7 @@ class AiSecretServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aiSecretService = client.aiSecret() + val aiSecretService = client.aiSecrets() val response = aiSecretService.list(AiSecretListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -94,7 +94,7 @@ class AiSecretServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aiSecretService = client.aiSecret() + val aiSecretService = client.aiSecrets() val aISecret = aiSecretService.delete( AiSecretDeleteParams.builder() @@ -112,7 +112,7 @@ class AiSecretServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aiSecretService = client.aiSecret() + val aiSecretService = client.aiSecrets() val aISecret = aiSecretService.findAndDelete( AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() @@ -128,7 +128,7 @@ class AiSecretServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val aiSecretService = client.aiSecret() + val aiSecretService = client.aiSecrets() val aISecret = aiSecretService.replace( AiSecretReplaceParams.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt old mode 100755 new mode 100644 similarity index 70% rename from braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index d060e56..bef4662 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -5,12 +5,12 @@ 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.ApiKeyResourceListParams +import com.braintrustdata.api.models.ApiKeyListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ApiKeyResourceServiceTest { +class ApiKeyServiceTest { @Test fun callCreate() { @@ -19,10 +19,10 @@ class ApiKeyResourceServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val apiKeyResourceService = client.apiKeyResource() + val apiKeyService = client.apiKeys() val createApiKeyOutput = - apiKeyResourceService.create( - ApiKeyResourceCreateParams.builder().name("name").orgName("org_name").build() + apiKeyService.create( + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() ) println(createApiKeyOutput) createApiKeyOutput.validate() @@ -35,10 +35,10 @@ class ApiKeyResourceServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val apiKeyResourceService = client.apiKeyResource() + val apiKeyService = client.apiKeys() val apiKey = - apiKeyResourceService.retrieve( - ApiKeyResourceRetrieveParams.builder() + apiKeyService.retrieve( + ApiKeyRetrieveParams.builder() .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -53,8 +53,8 @@ class ApiKeyResourceServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val apiKeyResourceService = client.apiKeyResource() - val response = apiKeyResourceService.list(ApiKeyResourceListParams.builder().build()) + val apiKeyService = client.apiKeys() + val response = apiKeyService.list(ApiKeyListParams.builder().build()) println(response) response.objects().forEach { it.validate() } } @@ -66,10 +66,10 @@ class ApiKeyResourceServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val apiKeyResourceService = client.apiKeyResource() + val apiKeyService = client.apiKeys() val apiKey = - apiKeyResourceService.delete( - ApiKeyResourceDeleteParams.builder() + apiKeyService.delete( + ApiKeyDeleteParams.builder() .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) 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 ccc35c8..538d606 100755 --- 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 @@ -21,7 +21,7 @@ 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() @@ -41,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() @@ -59,7 +59,7 @@ 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() @@ -80,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() } @@ -93,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() @@ -111,7 +111,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val feedbackResponseSchema = datasetService.feedback( DatasetFeedbackParams.builder() @@ -139,7 +139,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val fetchDatasetEventsResponse = datasetService.fetch( DatasetFetchParams.builder() @@ -161,7 +161,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val fetchDatasetEventsResponse = datasetService.fetchPost( DatasetFetchPostParams.builder() @@ -193,7 +193,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val insertEventsResponse = datasetService.insert( DatasetInsertParams.builder() @@ -228,7 +228,7 @@ class DatasetServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val datasetService = client.dataset() + val datasetService = client.datasets() val summarizeDatasetResponse = 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 8bde414..fe9afbe 100755 --- 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 @@ -21,7 +21,7 @@ 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() @@ -60,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() @@ -78,7 +78,7 @@ 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() @@ -116,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() } @@ -129,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() @@ -147,7 +147,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val feedbackResponseSchema = experimentService.feedback( ExperimentFeedbackParams.builder() @@ -177,7 +177,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val fetchExperimentEventsResponse = experimentService.fetch( ExperimentFetchParams.builder() @@ -199,7 +199,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val fetchExperimentEventsResponse = experimentService.fetchPost( ExperimentFetchPostParams.builder() @@ -231,7 +231,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val insertEventsResponse = experimentService.insert( ExperimentInsertParams.builder() @@ -296,7 +296,7 @@ class ExperimentServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val experimentService = client.experiment() + val experimentService = client.experiments() val summarizeExperimentResponse = 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 index 0836c69..3b63010 100755 --- 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 @@ -20,7 +20,7 @@ class FunctionServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val functionService = client.function() + val functionService = client.functions() val function = functionService.create( FunctionCreateParams.builder() @@ -35,7 +35,13 @@ class FunctionServiceTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(FunctionCreateParams.FunctionType.TASK) + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) .origin( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -122,6 +128,16 @@ class FunctionServiceTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -138,7 +154,7 @@ class FunctionServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val functionService = client.function() + val functionService = client.functions() val function = functionService.retrieve( FunctionRetrieveParams.builder() @@ -156,7 +172,7 @@ class FunctionServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val functionService = client.function() + val functionService = client.functions() val function = functionService.update( FunctionUpdateParams.builder() @@ -249,6 +265,16 @@ class FunctionServiceTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -265,7 +291,7 @@ class FunctionServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val functionService = client.function() + val functionService = client.functions() val response = functionService.list(FunctionListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -278,7 +304,7 @@ class FunctionServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val functionService = client.function() + val functionService = client.functions() val function = functionService.delete( FunctionDeleteParams.builder() @@ -296,12 +322,24 @@ class FunctionServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val functionService = client.function() + val functionService = client.functions() val functionInvokeResponse = functionService.invoke( FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .input(JsonValue.from(mapOf())) + .messages( + listOf( + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + ) + ) + .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.ofSpanParentStruct( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -339,7 +377,7 @@ class FunctionServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val functionService = client.function() + val functionService = client.functions() val function = functionService.replace( FunctionReplaceParams.builder() @@ -354,7 +392,13 @@ class FunctionServiceTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(FunctionReplaceParams.FunctionType.TASK) + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) .origin( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -441,6 +485,16 @@ class FunctionServiceTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) 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 d3e0d32..197a689 100755 --- 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,7 +19,7 @@ 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() @@ -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,7 +59,7 @@ 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() @@ -83,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() } @@ -96,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() @@ -112,7 +112,7 @@ 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() 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 index fbc7b44..17bcb9d 100755 --- 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 @@ -19,7 +19,7 @@ class OrganizationServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val organizationService = client.organization() + val organizationService = client.organizations() val organization = organizationService.retrieve( OrganizationRetrieveParams.builder() @@ -37,7 +37,7 @@ class OrganizationServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val organizationService = client.organization() + val organizationService = client.organizations() val organization = organizationService.update( OrganizationUpdateParams.builder() @@ -60,7 +60,7 @@ class OrganizationServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val organizationService = client.organization() + val organizationService = client.organizations() val response = organizationService.list(OrganizationListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -73,7 +73,7 @@ class OrganizationServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val organizationService = client.organization() + val organizationService = client.organizations() val organization = organizationService.delete( OrganizationDeleteParams.builder() 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 index 9139914..b407b2e 100755 --- 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 @@ -19,7 +19,7 @@ class ProjectScoreServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectScoreService = client.projectScore() + val projectScoreService = client.projectScores() val projectScore = projectScoreService.create( ProjectScoreCreateParams.builder() @@ -45,7 +45,7 @@ class ProjectScoreServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectScoreService = client.projectScore() + val projectScoreService = client.projectScores() val projectScore = projectScoreService.retrieve( ProjectScoreRetrieveParams.builder() @@ -63,7 +63,7 @@ class ProjectScoreServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectScoreService = client.projectScore() + val projectScoreService = client.projectScores() val projectScore = projectScoreService.update( ProjectScoreUpdateParams.builder() @@ -89,7 +89,7 @@ class ProjectScoreServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectScoreService = client.projectScore() + val projectScoreService = client.projectScores() val response = projectScoreService.list(ProjectScoreListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -102,7 +102,7 @@ class ProjectScoreServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectScoreService = client.projectScore() + val projectScoreService = client.projectScores() val projectScore = projectScoreService.delete( ProjectScoreDeleteParams.builder() @@ -120,7 +120,7 @@ class ProjectScoreServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectScoreService = client.projectScore() + val projectScoreService = client.projectScores() val projectScore = projectScoreService.replace( ProjectScoreReplaceParams.builder() 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 2b171bc..0dcc9ea 100755 --- 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,13 +19,13 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() - val projectModel = + val projectService = client.projects() + val project = projectService.create( ProjectCreateParams.builder().name("name").orgName("org_name").build() ) - println(projectModel) - projectModel.validate() + println(project) + project.validate() } @Test @@ -35,15 +35,15 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() - val projectModel = + val projectService = client.projects() + val project = projectService.retrieve( ProjectRetrieveParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(projectModel) - projectModel.validate() + println(project) + project.validate() } @Test @@ -53,8 +53,8 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() - val projectModel = + val projectService = client.projects() + val project = projectService.update( ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -66,8 +66,8 @@ class ProjectServiceTest { ) .build() ) - println(projectModel) - projectModel.validate() + println(project) + project.validate() } @Test @@ -77,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() } @@ -90,14 +90,14 @@ class ProjectServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectService = client.project() - val projectModel = + val projectService = client.projects() + val project = projectService.delete( ProjectDeleteParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(projectModel) - projectModel.validate() + 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 index 4bfae10..bffa896 100755 --- 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 @@ -19,7 +19,7 @@ class ProjectTagServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectTagService = client.projectTag() + val projectTagService = client.projectTags() val projectTag = projectTagService.create( ProjectTagCreateParams.builder() @@ -40,7 +40,7 @@ class ProjectTagServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectTagService = client.projectTag() + val projectTagService = client.projectTags() val projectTag = projectTagService.retrieve( ProjectTagRetrieveParams.builder() @@ -58,7 +58,7 @@ class ProjectTagServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectTagService = client.projectTag() + val projectTagService = client.projectTags() val projectTag = projectTagService.update( ProjectTagUpdateParams.builder() @@ -79,7 +79,7 @@ class ProjectTagServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectTagService = client.projectTag() + val projectTagService = client.projectTags() val response = projectTagService.list(ProjectTagListParams.builder().build()) println(response) response.objects().forEach { it.validate() } @@ -92,7 +92,7 @@ class ProjectTagServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectTagService = client.projectTag() + val projectTagService = client.projectTags() val projectTag = projectTagService.delete( ProjectTagDeleteParams.builder() @@ -110,7 +110,7 @@ class ProjectTagServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val projectTagService = client.projectTag() + val projectTagService = client.projectTags() val projectTag = projectTagService.replace( ProjectTagReplaceParams.builder() 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 c852964..8f861cb 100755 --- 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,7 +19,7 @@ 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() @@ -27,7 +27,7 @@ class PromptServiceTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(PromptCreateParams.FunctionType.TASK) + .functionType(PromptCreateParams.FunctionType.LLM) .promptData( PromptData.builder() .options( @@ -107,6 +107,16 @@ class PromptServiceTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) @@ -123,7 +133,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() @@ -141,7 +151,7 @@ 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() @@ -227,6 +237,16 @@ class PromptServiceTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .slug("slug") @@ -244,7 +264,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() } @@ -257,7 +277,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() @@ -275,7 +295,7 @@ 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() @@ -283,7 +303,7 @@ class PromptServiceTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("slug") .description("description") - .functionType(PromptReplaceParams.FunctionType.TASK) + .functionType(PromptReplaceParams.FunctionType.LLM) .promptData( PromptData.builder() .options( @@ -363,6 +383,16 @@ class PromptServiceTest { .build() ) ) + .toolFunctions( + listOf( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) + ) .build() ) .tags(listOf("string")) 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 72b81e0..20cdf59 100755 --- 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,7 +19,7 @@ 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() @@ -51,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() @@ -67,7 +67,7 @@ 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() @@ -113,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() } @@ -126,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() @@ -142,7 +142,7 @@ 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() 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 100755 --- 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 index adfd296..ad9a4cf 100755 --- 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 @@ -21,7 +21,7 @@ class ViewServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val viewService = client.view() + val viewService = client.views() val view = viewService.create( ViewCreateParams.builder() @@ -63,7 +63,7 @@ class ViewServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val viewService = client.view() + val viewService = client.views() val view = viewService.retrieve( ViewRetrieveParams.builder() @@ -83,7 +83,7 @@ class ViewServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val viewService = client.view() + val viewService = client.views() val view = viewService.update( ViewUpdateParams.builder() @@ -125,7 +125,7 @@ class ViewServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val viewService = client.view() + val viewService = client.views() val response = viewService.list( ViewListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() @@ -141,7 +141,7 @@ class ViewServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val viewService = client.view() + val viewService = client.views() val view = viewService.delete( ViewDeleteParams.builder() @@ -161,7 +161,7 @@ class ViewServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val viewService = client.view() + val viewService = client.views() val view = viewService.replace( ViewReplaceParams.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt old mode 100755 new mode 100644 similarity index 93% rename from braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceTest.kt rename to braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt index e85299c..45b4a8a --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.braintrustdata.api.services.blocking.organization +package com.braintrustdata.api.services.blocking.organizations import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient @@ -18,7 +18,7 @@ class MemberServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val memberService = client.organization().members() + val memberService = client.organizations().members() val organizationMemberUpdateResponse = memberService.update( OrganizationMemberUpdateParams.builder() 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 old mode 100755 new mode 100644 similarity index 96% 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 d04dcc5..ec2208d --- 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,6 +1,6 @@ // 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 @@ -20,7 +20,7 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() val feedbackResponseSchema = logService.feedback( ProjectLogFeedbackParams.builder() @@ -50,7 +50,7 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() val fetchProjectLogsEventsResponse = logService.fetch( ProjectLogFetchParams.builder() @@ -72,7 +72,7 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() val fetchProjectLogsEventsResponse = logService.fetchPost( ProjectLogFetchPostParams.builder() @@ -104,7 +104,7 @@ class LogServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val logService = client.project().logs() + val logService = client.projects().logs() val insertEventsResponse = logService.insert( ProjectLogInsertParams.builder()