Skip to content

Commit dc1d7b7

Browse files
committed
chore: add new files to code
1 parent 2b5d36a commit dc1d7b7

File tree

4 files changed

+322
-0
lines changed

4 files changed

+322
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
package com.langfuse.client;
6+
7+
import com.langfuse.client.core.ClientOptions;
8+
import com.langfuse.client.core.Suppliers;
9+
import java.util.function.Supplier;
10+
import com.langfuse.client.resources.comments.CommentsClient;
11+
import com.langfuse.client.resources.datasetitems.DatasetItemsClient;
12+
import com.langfuse.client.resources.datasetrunitems.DatasetRunItemsClient;
13+
import com.langfuse.client.resources.datasets.DatasetsClient;
14+
import com.langfuse.client.resources.health.HealthClient;
15+
import com.langfuse.client.resources.ingestion.IngestionClient;
16+
import com.langfuse.client.resources.media.MediaClient;
17+
import com.langfuse.client.resources.metrics.MetricsClient;
18+
import com.langfuse.client.resources.models.ModelsClient;
19+
import com.langfuse.client.resources.observations.ObservationsClient;
20+
import com.langfuse.client.resources.projects.ProjectsClient;
21+
import com.langfuse.client.resources.prompts.PromptsClient;
22+
import com.langfuse.client.resources.promptversion.PromptVersionClient;
23+
import com.langfuse.client.resources.score.ScoreClient;
24+
import com.langfuse.client.resources.scoreconfigs.ScoreConfigsClient;
25+
import com.langfuse.client.resources.sessions.SessionsClient;
26+
import com.langfuse.client.resources.trace.TraceClient;
27+
28+
public class LangfuseClient {
29+
protected final ClientOptions clientOptions;
30+
31+
protected final Supplier<CommentsClient> commentsClient;
32+
33+
protected final Supplier<DatasetItemsClient> datasetItemsClient;
34+
35+
protected final Supplier<DatasetRunItemsClient> datasetRunItemsClient;
36+
37+
protected final Supplier<DatasetsClient> datasetsClient;
38+
39+
protected final Supplier<HealthClient> healthClient;
40+
41+
protected final Supplier<IngestionClient> ingestionClient;
42+
43+
protected final Supplier<MediaClient> mediaClient;
44+
45+
protected final Supplier<MetricsClient> metricsClient;
46+
47+
protected final Supplier<ModelsClient> modelsClient;
48+
49+
protected final Supplier<ObservationsClient> observationsClient;
50+
51+
protected final Supplier<ProjectsClient> projectsClient;
52+
53+
protected final Supplier<PromptVersionClient> promptVersionClient;
54+
55+
protected final Supplier<PromptsClient> promptsClient;
56+
57+
protected final Supplier<ScoreConfigsClient> scoreConfigsClient;
58+
59+
protected final Supplier<ScoreClient> scoreClient;
60+
61+
protected final Supplier<SessionsClient> sessionsClient;
62+
63+
protected final Supplier<TraceClient> traceClient;
64+
65+
public LangfuseClient(ClientOptions clientOptions) {
66+
this.clientOptions = clientOptions;
67+
this.commentsClient = Suppliers.memoize(() -> new CommentsClient(clientOptions));
68+
this.datasetItemsClient = Suppliers.memoize(() -> new DatasetItemsClient(clientOptions));
69+
this.datasetRunItemsClient = Suppliers.memoize(() -> new DatasetRunItemsClient(clientOptions));
70+
this.datasetsClient = Suppliers.memoize(() -> new DatasetsClient(clientOptions));
71+
this.healthClient = Suppliers.memoize(() -> new HealthClient(clientOptions));
72+
this.ingestionClient = Suppliers.memoize(() -> new IngestionClient(clientOptions));
73+
this.mediaClient = Suppliers.memoize(() -> new MediaClient(clientOptions));
74+
this.metricsClient = Suppliers.memoize(() -> new MetricsClient(clientOptions));
75+
this.modelsClient = Suppliers.memoize(() -> new ModelsClient(clientOptions));
76+
this.observationsClient = Suppliers.memoize(() -> new ObservationsClient(clientOptions));
77+
this.projectsClient = Suppliers.memoize(() -> new ProjectsClient(clientOptions));
78+
this.promptVersionClient = Suppliers.memoize(() -> new PromptVersionClient(clientOptions));
79+
this.promptsClient = Suppliers.memoize(() -> new PromptsClient(clientOptions));
80+
this.scoreConfigsClient = Suppliers.memoize(() -> new ScoreConfigsClient(clientOptions));
81+
this.scoreClient = Suppliers.memoize(() -> new ScoreClient(clientOptions));
82+
this.sessionsClient = Suppliers.memoize(() -> new SessionsClient(clientOptions));
83+
this.traceClient = Suppliers.memoize(() -> new TraceClient(clientOptions));
84+
}
85+
86+
public CommentsClient comments() {
87+
return this.commentsClient.get();
88+
}
89+
90+
public DatasetItemsClient datasetItems() {
91+
return this.datasetItemsClient.get();
92+
}
93+
94+
public DatasetRunItemsClient datasetRunItems() {
95+
return this.datasetRunItemsClient.get();
96+
}
97+
98+
public DatasetsClient datasets() {
99+
return this.datasetsClient.get();
100+
}
101+
102+
public HealthClient health() {
103+
return this.healthClient.get();
104+
}
105+
106+
public IngestionClient ingestion() {
107+
return this.ingestionClient.get();
108+
}
109+
110+
public MediaClient media() {
111+
return this.mediaClient.get();
112+
}
113+
114+
public MetricsClient metrics() {
115+
return this.metricsClient.get();
116+
}
117+
118+
public ModelsClient models() {
119+
return this.modelsClient.get();
120+
}
121+
122+
public ObservationsClient observations() {
123+
return this.observationsClient.get();
124+
}
125+
126+
public ProjectsClient projects() {
127+
return this.projectsClient.get();
128+
}
129+
130+
public PromptVersionClient promptVersion() {
131+
return this.promptVersionClient.get();
132+
}
133+
134+
public PromptsClient prompts() {
135+
return this.promptsClient.get();
136+
}
137+
138+
public ScoreConfigsClient scoreConfigs() {
139+
return this.scoreConfigsClient.get();
140+
}
141+
142+
public ScoreClient score() {
143+
return this.scoreClient.get();
144+
}
145+
146+
public SessionsClient sessions() {
147+
return this.sessionsClient.get();
148+
}
149+
150+
public TraceClient trace() {
151+
return this.traceClient.get();
152+
}
153+
154+
public static LangfuseClientBuilder builder() {
155+
return new LangfuseClientBuilder();
156+
}
157+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
package com.langfuse.client;
6+
7+
import com.langfuse.client.core.ClientOptions;
8+
import com.langfuse.client.core.Environment;
9+
import java.lang.String;
10+
import java.util.Base64;
11+
import okhttp3.OkHttpClient;
12+
13+
public final class LangfuseClientBuilder {
14+
private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder();
15+
16+
private String username = null;
17+
18+
private String password = null;
19+
20+
private String xLangfuseSdkName = null;
21+
22+
private String xLangfuseSdkVersion = null;
23+
24+
private String xLangfusePublicKey = null;
25+
26+
private Environment environment;
27+
28+
public LangfuseClientBuilder credentials(String username, String password) {
29+
this.username = username;
30+
this.password = password;
31+
return this;
32+
}
33+
34+
/**
35+
* Sets xLangfuseSdkName
36+
*/
37+
public LangfuseClientBuilder xLangfuseSdkName(String xLangfuseSdkName) {
38+
this.xLangfuseSdkName = xLangfuseSdkName;
39+
return this;
40+
}
41+
42+
/**
43+
* Sets xLangfuseSdkVersion
44+
*/
45+
public LangfuseClientBuilder xLangfuseSdkVersion(String xLangfuseSdkVersion) {
46+
this.xLangfuseSdkVersion = xLangfuseSdkVersion;
47+
return this;
48+
}
49+
50+
/**
51+
* Sets xLangfusePublicKey
52+
*/
53+
public LangfuseClientBuilder xLangfusePublicKey(String xLangfusePublicKey) {
54+
this.xLangfusePublicKey = xLangfusePublicKey;
55+
return this;
56+
}
57+
58+
public LangfuseClientBuilder url(String url) {
59+
this.environment = Environment.custom(url);
60+
return this;
61+
}
62+
63+
/**
64+
* Sets the timeout (in seconds) for the client
65+
*/
66+
public LangfuseClientBuilder timeout(int timeout) {
67+
this.clientOptionsBuilder.timeout(timeout);
68+
return this;
69+
}
70+
71+
/**
72+
* Sets the underlying OkHttp client
73+
*/
74+
public LangfuseClientBuilder httpClient(OkHttpClient httpClient) {
75+
this.clientOptionsBuilder.httpClient(httpClient);
76+
return this;
77+
}
78+
79+
public LangfuseClient build() {
80+
String unencodedToken = username + ":" + password;
81+
String encodedToken = Base64.getEncoder().encodeToString(unencodedToken.getBytes());
82+
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + encodedToken);
83+
if (xLangfuseSdkName != null) {
84+
this.clientOptionsBuilder.addHeader("X-Langfuse-Sdk-Name", this.xLangfuseSdkName);
85+
}
86+
if (xLangfuseSdkVersion != null) {
87+
this.clientOptionsBuilder.addHeader("X-Langfuse-Sdk-Version", this.xLangfuseSdkVersion);
88+
}
89+
if (xLangfusePublicKey != null) {
90+
this.clientOptionsBuilder.addHeader("X-Langfuse-Public-Key", this.xLangfusePublicKey);
91+
}
92+
clientOptionsBuilder.environment(this.environment);
93+
return new LangfuseClient(clientOptionsBuilder.build());
94+
}
95+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
package com.langfuse.client.core;
6+
7+
import java.lang.Object;
8+
import java.lang.String;
9+
10+
/**
11+
* This exception type will be thrown for any non-2XX API responses.
12+
*/
13+
public class LangfuseClientApiException extends LangfuseClientException {
14+
/**
15+
* The error code of the response that triggered the exception.
16+
*/
17+
private final int statusCode;
18+
19+
/**
20+
* The body of the response that triggered the exception.
21+
*/
22+
private final Object body;
23+
24+
public LangfuseClientApiException(String message, int statusCode, Object body) {
25+
super(message);
26+
this.statusCode = statusCode;
27+
this.body = body;
28+
}
29+
30+
/**
31+
* @return the statusCode
32+
*/
33+
public int statusCode() {
34+
return this.statusCode;
35+
}
36+
37+
/**
38+
* @return the body
39+
*/
40+
public Object body() {
41+
return this.body;
42+
}
43+
44+
@java.lang.Override
45+
public String toString() {
46+
return "LangfuseClientApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body + "}";
47+
}
48+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
package com.langfuse.client.core;
6+
7+
import java.lang.Exception;
8+
import java.lang.RuntimeException;
9+
import java.lang.String;
10+
11+
/**
12+
* This class serves as the base exception for all errors in the SDK.
13+
*/
14+
public class LangfuseClientException extends RuntimeException {
15+
public LangfuseClientException(String message) {
16+
super(message);
17+
}
18+
19+
public LangfuseClientException(String message, Exception e) {
20+
super(message, e);
21+
}
22+
}

0 commit comments

Comments
 (0)