Skip to content

Commit 0ba1894

Browse files
committed
feat: update client to 3.140.0 compatibility
1 parent dc32f72 commit 0ba1894

85 files changed

Lines changed: 8858 additions & 282 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/com/langfuse/client/LangfuseClient.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
import com.langfuse.client.core.Suppliers;
99
import java.util.function.Supplier;
1010
import com.langfuse.client.resources.annotationqueues.AnnotationQueuesClient;
11+
import com.langfuse.client.resources.blobstorageintegrations.BlobStorageIntegrationsClient;
1112
import com.langfuse.client.resources.comments.CommentsClient;
1213
import com.langfuse.client.resources.datasetitems.DatasetItemsClient;
1314
import com.langfuse.client.resources.datasetrunitems.DatasetRunItemsClient;
1415
import com.langfuse.client.resources.datasets.DatasetsClient;
1516
import com.langfuse.client.resources.health.HealthClient;
1617
import com.langfuse.client.resources.ingestion.IngestionClient;
18+
import com.langfuse.client.resources.llmconnections.LlmConnectionsClient;
1719
import com.langfuse.client.resources.media.MediaClient;
1820
import com.langfuse.client.resources.metrics.MetricsClient;
1921
import com.langfuse.client.resources.models.ModelsClient;
2022
import com.langfuse.client.resources.observations.ObservationsClient;
23+
import com.langfuse.client.resources.opentelemetry.OpentelemetryClient;
2124
import com.langfuse.client.resources.organizations.OrganizationsClient;
2225
import com.langfuse.client.resources.projects.ProjectsClient;
2326
import com.langfuse.client.resources.prompts.PromptsClient;
@@ -34,6 +37,8 @@ public class LangfuseClient {
3437

3538
protected final Supplier<AnnotationQueuesClient> annotationQueuesClient;
3639

40+
protected final Supplier<BlobStorageIntegrationsClient> blobStorageIntegrationsClient;
41+
3742
protected final Supplier<CommentsClient> commentsClient;
3843

3944
protected final Supplier<DatasetItemsClient> datasetItemsClient;
@@ -46,6 +51,8 @@ public class LangfuseClient {
4651

4752
protected final Supplier<IngestionClient> ingestionClient;
4853

54+
protected final Supplier<LlmConnectionsClient> llmConnectionsClient;
55+
4956
protected final Supplier<MediaClient> mediaClient;
5057

5158
protected final Supplier<MetricsClient> metricsClient;
@@ -54,6 +61,8 @@ public class LangfuseClient {
5461

5562
protected final Supplier<ObservationsClient> observationsClient;
5663

64+
protected final Supplier<OpentelemetryClient> opentelemetryClient;
65+
5766
protected final Supplier<OrganizationsClient> organizationsClient;
5867

5968
protected final Supplier<ProjectsClient> projectsClient;
@@ -77,16 +86,19 @@ public class LangfuseClient {
7786
public LangfuseClient(ClientOptions clientOptions) {
7887
this.clientOptions = clientOptions;
7988
this.annotationQueuesClient = Suppliers.memoize(() -> new AnnotationQueuesClient(clientOptions));
89+
this.blobStorageIntegrationsClient = Suppliers.memoize(() -> new BlobStorageIntegrationsClient(clientOptions));
8090
this.commentsClient = Suppliers.memoize(() -> new CommentsClient(clientOptions));
8191
this.datasetItemsClient = Suppliers.memoize(() -> new DatasetItemsClient(clientOptions));
8292
this.datasetRunItemsClient = Suppliers.memoize(() -> new DatasetRunItemsClient(clientOptions));
8393
this.datasetsClient = Suppliers.memoize(() -> new DatasetsClient(clientOptions));
8494
this.healthClient = Suppliers.memoize(() -> new HealthClient(clientOptions));
8595
this.ingestionClient = Suppliers.memoize(() -> new IngestionClient(clientOptions));
96+
this.llmConnectionsClient = Suppliers.memoize(() -> new LlmConnectionsClient(clientOptions));
8697
this.mediaClient = Suppliers.memoize(() -> new MediaClient(clientOptions));
8798
this.metricsClient = Suppliers.memoize(() -> new MetricsClient(clientOptions));
8899
this.modelsClient = Suppliers.memoize(() -> new ModelsClient(clientOptions));
89100
this.observationsClient = Suppliers.memoize(() -> new ObservationsClient(clientOptions));
101+
this.opentelemetryClient = Suppliers.memoize(() -> new OpentelemetryClient(clientOptions));
90102
this.organizationsClient = Suppliers.memoize(() -> new OrganizationsClient(clientOptions));
91103
this.projectsClient = Suppliers.memoize(() -> new ProjectsClient(clientOptions));
92104
this.promptVersionClient = Suppliers.memoize(() -> new PromptVersionClient(clientOptions));
@@ -103,6 +115,10 @@ public AnnotationQueuesClient annotationQueues() {
103115
return this.annotationQueuesClient.get();
104116
}
105117

118+
public BlobStorageIntegrationsClient blobStorageIntegrations() {
119+
return this.blobStorageIntegrationsClient.get();
120+
}
121+
106122
public CommentsClient comments() {
107123
return this.commentsClient.get();
108124
}
@@ -127,6 +143,10 @@ public IngestionClient ingestion() {
127143
return this.ingestionClient.get();
128144
}
129145

146+
public LlmConnectionsClient llmConnections() {
147+
return this.llmConnectionsClient.get();
148+
}
149+
130150
public MediaClient media() {
131151
return this.mediaClient.get();
132152
}
@@ -143,6 +163,10 @@ public ObservationsClient observations() {
143163
return this.observationsClient.get();
144164
}
145165

166+
public OpentelemetryClient opentelemetry() {
167+
return this.opentelemetryClient.get();
168+
}
169+
146170
public OrganizationsClient organizations() {
147171
return this.organizationsClient.get();
148172
}

src/main/java/com/langfuse/client/core/ClientOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private ClientOptions(Environment environment, Map<String, String> headers,
2727
this.environment = environment;
2828
this.headers = new HashMap<>();
2929
this.headers.putAll(headers);
30-
this.headers.putAll(new HashMap<String,String>() {{put("X-Fern-Language", "JAVA");put("X-Fern-SDK-Name", "com.langfuse.fern:langfuse-sdk");put("X-Fern-SDK-Version", "0.0.169");}});
30+
this.headers.putAll(new HashMap<String,String>() {{put("X-Fern-Language", "JAVA");put("X-Fern-SDK-Name", "com.langfuse.fern:langfuse-sdk");put("X-Fern-SDK-Version", "0.0.2565");}});
3131
this.headerSuppliers = headerSuppliers;
3232
this.httpClient = httpClient;
3333
this.timeout = timeout;

src/main/java/com/langfuse/client/resources/annotationqueues/AnnotationQueuesClient.java

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@
2525
import com.langfuse.client.resources.annotationqueues.requests.GetAnnotationQueueItemsRequest;
2626
import com.langfuse.client.resources.annotationqueues.requests.GetAnnotationQueuesRequest;
2727
import com.langfuse.client.resources.annotationqueues.types.AnnotationQueue;
28+
import com.langfuse.client.resources.annotationqueues.types.AnnotationQueueAssignmentRequest;
2829
import com.langfuse.client.resources.annotationqueues.types.AnnotationQueueItem;
30+
import com.langfuse.client.resources.annotationqueues.types.CreateAnnotationQueueAssignmentResponse;
2931
import com.langfuse.client.resources.annotationqueues.types.CreateAnnotationQueueItemRequest;
32+
import com.langfuse.client.resources.annotationqueues.types.CreateAnnotationQueueRequest;
33+
import com.langfuse.client.resources.annotationqueues.types.DeleteAnnotationQueueAssignmentResponse;
3034
import com.langfuse.client.resources.annotationqueues.types.DeleteAnnotationQueueItemResponse;
3135
import com.langfuse.client.resources.annotationqueues.types.PaginatedAnnotationQueueItems;
3236
import com.langfuse.client.resources.annotationqueues.types.PaginatedAnnotationQueues;
@@ -107,6 +111,65 @@ public PaginatedAnnotationQueues listQueues(GetAnnotationQueuesRequest request,
107111
}
108112
}
109113

114+
/**
115+
* Create an annotation queue
116+
*/
117+
public AnnotationQueue createQueue(CreateAnnotationQueueRequest request) {
118+
return createQueue(request,null);
119+
}
120+
121+
/**
122+
* Create an annotation queue
123+
*/
124+
public AnnotationQueue createQueue(CreateAnnotationQueueRequest request,
125+
RequestOptions requestOptions) {
126+
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()
127+
.addPathSegments("api/public")
128+
.addPathSegments("annotation-queues")
129+
.build();
130+
RequestBody body;
131+
try {
132+
body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
133+
}
134+
catch(JsonProcessingException e) {
135+
throw new LangfuseClientException("Failed to serialize request", e);
136+
}
137+
Request okhttpRequest = new Request.Builder()
138+
.url(httpUrl)
139+
.method("POST", body)
140+
.headers(Headers.of(clientOptions.headers(requestOptions)))
141+
.addHeader("Content-Type", "application/json")
142+
.addHeader("Accept", "application/json")
143+
.build();
144+
OkHttpClient client = clientOptions.httpClient();
145+
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
146+
client = clientOptions.httpClientWithTimeout(requestOptions);
147+
}
148+
try (Response response = client.newCall(okhttpRequest).execute()) {
149+
ResponseBody responseBody = response.body();
150+
if (response.isSuccessful()) {
151+
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AnnotationQueue.class);
152+
}
153+
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
154+
try {
155+
switch (response.code()) {
156+
case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
157+
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
158+
case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
159+
case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
160+
case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
161+
}
162+
}
163+
catch (JsonProcessingException ignored) {
164+
// unable to map error response, throwing generic error
165+
}
166+
throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
167+
}
168+
catch (IOException e) {
169+
throw new LangfuseClientException("Network error executing HTTP request", e);
170+
}
171+
}
172+
110173
/**
111174
* Get an annotation queue by ID
112175
*/
@@ -469,4 +532,128 @@ public DeleteAnnotationQueueItemResponse deleteQueueItem(String queueId, String
469532
throw new LangfuseClientException("Network error executing HTTP request", e);
470533
}
471534
}
535+
536+
/**
537+
* Create an assignment for a user to an annotation queue
538+
*/
539+
public CreateAnnotationQueueAssignmentResponse createQueueAssignment(String queueId,
540+
AnnotationQueueAssignmentRequest request) {
541+
return createQueueAssignment(queueId,request,null);
542+
}
543+
544+
/**
545+
* Create an assignment for a user to an annotation queue
546+
*/
547+
public CreateAnnotationQueueAssignmentResponse createQueueAssignment(String queueId,
548+
AnnotationQueueAssignmentRequest request, RequestOptions requestOptions) {
549+
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()
550+
.addPathSegments("api/public")
551+
.addPathSegments("annotation-queues")
552+
.addPathSegment(queueId)
553+
.addPathSegments("assignments")
554+
.build();
555+
RequestBody body;
556+
try {
557+
body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
558+
}
559+
catch(JsonProcessingException e) {
560+
throw new LangfuseClientException("Failed to serialize request", e);
561+
}
562+
Request okhttpRequest = new Request.Builder()
563+
.url(httpUrl)
564+
.method("POST", body)
565+
.headers(Headers.of(clientOptions.headers(requestOptions)))
566+
.addHeader("Content-Type", "application/json")
567+
.addHeader("Accept", "application/json")
568+
.build();
569+
OkHttpClient client = clientOptions.httpClient();
570+
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
571+
client = clientOptions.httpClientWithTimeout(requestOptions);
572+
}
573+
try (Response response = client.newCall(okhttpRequest).execute()) {
574+
ResponseBody responseBody = response.body();
575+
if (response.isSuccessful()) {
576+
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CreateAnnotationQueueAssignmentResponse.class);
577+
}
578+
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
579+
try {
580+
switch (response.code()) {
581+
case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
582+
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
583+
case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
584+
case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
585+
case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
586+
}
587+
}
588+
catch (JsonProcessingException ignored) {
589+
// unable to map error response, throwing generic error
590+
}
591+
throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
592+
}
593+
catch (IOException e) {
594+
throw new LangfuseClientException("Network error executing HTTP request", e);
595+
}
596+
}
597+
598+
/**
599+
* Delete an assignment for a user to an annotation queue
600+
*/
601+
public DeleteAnnotationQueueAssignmentResponse deleteQueueAssignment(String queueId,
602+
AnnotationQueueAssignmentRequest request) {
603+
return deleteQueueAssignment(queueId,request,null);
604+
}
605+
606+
/**
607+
* Delete an assignment for a user to an annotation queue
608+
*/
609+
public DeleteAnnotationQueueAssignmentResponse deleteQueueAssignment(String queueId,
610+
AnnotationQueueAssignmentRequest request, RequestOptions requestOptions) {
611+
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()
612+
.addPathSegments("api/public")
613+
.addPathSegments("annotation-queues")
614+
.addPathSegment(queueId)
615+
.addPathSegments("assignments")
616+
.build();
617+
RequestBody body;
618+
try {
619+
body = RequestBody.create(ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
620+
}
621+
catch(JsonProcessingException e) {
622+
throw new LangfuseClientException("Failed to serialize request", e);
623+
}
624+
Request okhttpRequest = new Request.Builder()
625+
.url(httpUrl)
626+
.method("DELETE", body)
627+
.headers(Headers.of(clientOptions.headers(requestOptions)))
628+
.addHeader("Content-Type", "application/json")
629+
.addHeader("Accept", "application/json")
630+
.build();
631+
OkHttpClient client = clientOptions.httpClient();
632+
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
633+
client = clientOptions.httpClientWithTimeout(requestOptions);
634+
}
635+
try (Response response = client.newCall(okhttpRequest).execute()) {
636+
ResponseBody responseBody = response.body();
637+
if (response.isSuccessful()) {
638+
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteAnnotationQueueAssignmentResponse.class);
639+
}
640+
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
641+
try {
642+
switch (response.code()) {
643+
case 400:throw new Error(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
644+
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
645+
case 403:throw new AccessDeniedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
646+
case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
647+
case 405:throw new MethodNotAllowedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
648+
}
649+
}
650+
catch (JsonProcessingException ignored) {
651+
// unable to map error response, throwing generic error
652+
}
653+
throw new LangfuseClientApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
654+
}
655+
catch (IOException e) {
656+
throw new LangfuseClientException("Network error executing HTTP request", e);
657+
}
658+
}
472659
}

0 commit comments

Comments
 (0)