Skip to content

Commit 3805fa4

Browse files
authored
chore: add prompt serialization test cases and regenerate client (#20)
* chore: add prompt serialization test cases * chore: push newly generated sdk (#22)
1 parent bed7202 commit 3805fa4

File tree

372 files changed

+39405
-7390
lines changed

Some content is hidden

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

372 files changed

+39405
-7390
lines changed

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Langfuse API credentials for integration tests.
2+
# Copy this file to .env and fill in your values.
3+
#
4+
# Required prompts in the Langfuse project:
5+
# - "test-chat-prompt" : chat type, at least one message with role + content
6+
# - "test-text-prompt" : text type, non-empty prompt text
7+
LANGFUSE_PUBLIC_KEY=pk-lf-...
8+
LANGFUSE_SECRET_KEY=sk-lf-...
9+
LANGFUSE_HOST=https://cloud.langfuse.com

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ build/
3636
.vscode/
3737

3838
### Mac OS ###
39-
.DS_Store
39+
.DS_Store
40+
41+
### Environment ###
42+
.env

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,41 @@ try {
4848
}
4949
```
5050

51+
## Testing
52+
53+
### Unit tests
54+
55+
Unit tests (deserialization, query string mapping) run without any credentials:
56+
57+
```bash
58+
mvn test
59+
```
60+
61+
### Integration tests
62+
63+
Integration tests connect to a real Langfuse project. They require credentials and are excluded from `mvn test`.
64+
65+
1. Copy `.env.example` to `.env` and fill in your API keys:
66+
```bash
67+
cp .env.example .env
68+
```
69+
70+
2. Ensure your Langfuse project contains the following prompts:
71+
- `test-chat-prompt` — chat type, at least one message with `role` and `content`
72+
- `test-text-prompt` — text type, non-empty prompt text
73+
74+
3. Run all tests (unit + integration):
75+
```bash
76+
mvn verify
77+
```
78+
79+
Or run only integration tests:
80+
```bash
81+
mvn failsafe:integration-test
82+
```
83+
84+
Integration tests skip gracefully when credentials are absent.
85+
5186
## Drafting a Release
5287

5388
Run `./mvnw release:prepare -DreleaseVersion=` with the version you want to create.
@@ -78,6 +113,6 @@ To publish to Maven Central, you need to configure the following secrets in your
78113
```
79114
3. Generate the new client code using `npx fern-api generate --api server`.
80115
4. Manually set the `package` across all files to `com.langfuse.client`.
81-
5. Overwrite `this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + encodedToken);` to `Basic` in LangfuseClientBuilder.java.
116+
5. Overwrite `this.clientOptionsBuilder.addHeader("Authorization", "Basic " + encodedToken);` to `Basic` in com.langfuse.client.LangfuseClientBuilder.java.
82117
6. Adjust Javadoc strings with HTML properties as the apidocs package does not support them.
83118
7. Commit the changes in langfuse-java and push them to the repository.

pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,37 @@
118118
</execution>
119119
</executions>
120120
</plugin>
121+
122+
<!-- Surefire: runs unit tests (mvn test), excludes integration -->
123+
<plugin>
124+
<groupId>org.apache.maven.plugins</groupId>
125+
<artifactId>maven-surefire-plugin</artifactId>
126+
<version>3.2.5</version>
127+
<configuration>
128+
<excludedGroups>integration</excludedGroups>
129+
</configuration>
130+
</plugin>
131+
132+
<!-- Failsafe: runs integration tests (mvn verify) -->
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-failsafe-plugin</artifactId>
136+
<version>3.2.5</version>
137+
<configuration>
138+
<groups>integration</groups>
139+
<includes>
140+
<include>**/*Test.java</include>
141+
</includes>
142+
</configuration>
143+
<executions>
144+
<execution>
145+
<goals>
146+
<goal>integration-test</goal>
147+
<goal>verify</goal>
148+
</goals>
149+
</execution>
150+
</executions>
151+
</plugin>
121152
</plugins>
122153
</build>
123154

@@ -157,5 +188,29 @@
157188
<artifactId>junit-jupiter-api</artifactId>
158189
<version>${junit.version}</version>
159190
</dependency>
191+
192+
<!-- JUnit Jupiter Engine (required to run tests) -->
193+
<dependency>
194+
<groupId>org.junit.jupiter</groupId>
195+
<artifactId>junit-jupiter-engine</artifactId>
196+
<version>${junit.version}</version>
197+
<scope>test</scope>
198+
</dependency>
199+
200+
<!-- AssertJ -->
201+
<dependency>
202+
<groupId>org.assertj</groupId>
203+
<artifactId>assertj-core</artifactId>
204+
<version>3.25.3</version>
205+
<scope>test</scope>
206+
</dependency>
207+
208+
<!-- dotenv-java for loading .env files -->
209+
<dependency>
210+
<groupId>io.github.cdimascio</groupId>
211+
<artifactId>dotenv-java</artifactId>
212+
<version>3.0.2</version>
213+
<scope>test</scope>
214+
</dependency>
160215
</dependencies>
161216
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"cliVersion": "3.88.0",
3+
"generatorName": "fernapi/fern-java-sdk",
4+
"generatorVersion": "3.38.1",
5+
"generatorConfig": {
6+
"client-class-name": "LangfuseClient"
7+
}
8+
}
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
package com.langfuse.client; /**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
import com.langfuse.client.core.ClientOptions;
6+
import com.langfuse.client.core.Suppliers;
7+
import java.util.function.Supplier;
8+
import com.langfuse.client.resources.annotationqueues.AsyncAnnotationQueuesClient;
9+
import com.langfuse.client.resources.blobstorageintegrations.AsyncBlobStorageIntegrationsClient;
10+
import com.langfuse.client.resources.comments.AsyncCommentsClient;
11+
import com.langfuse.client.resources.datasetitems.AsyncDatasetItemsClient;
12+
import com.langfuse.client.resources.datasetrunitems.AsyncDatasetRunItemsClient;
13+
import com.langfuse.client.resources.datasets.AsyncDatasetsClient;
14+
import com.langfuse.client.resources.health.AsyncHealthClient;
15+
import com.langfuse.client.resources.ingestion.AsyncIngestionClient;
16+
import com.langfuse.client.resources.llmconnections.AsyncLlmConnectionsClient;
17+
import com.langfuse.client.resources.media.AsyncMediaClient;
18+
import com.langfuse.client.resources.metrics.AsyncMetricsClient;
19+
import com.langfuse.client.resources.metricsv2.AsyncMetricsV2Client;
20+
import com.langfuse.client.resources.models.AsyncModelsClient;
21+
import com.langfuse.client.resources.observations.AsyncObservationsClient;
22+
import com.langfuse.client.resources.observationsv2.AsyncObservationsV2Client;
23+
import com.langfuse.client.resources.opentelemetry.AsyncOpentelemetryClient;
24+
import com.langfuse.client.resources.organizations.AsyncOrganizationsClient;
25+
import com.langfuse.client.resources.projects.AsyncProjectsClient;
26+
import com.langfuse.client.resources.prompts.AsyncPromptsClient;
27+
import com.langfuse.client.resources.promptversion.AsyncPromptVersionClient;
28+
import com.langfuse.client.resources.scim.AsyncScimClient;
29+
import com.langfuse.client.resources.score.AsyncScoreClient;
30+
import com.langfuse.client.resources.scoreconfigs.AsyncScoreConfigsClient;
31+
import com.langfuse.client.resources.scorev2.AsyncScoreV2Client;
32+
import com.langfuse.client.resources.sessions.AsyncSessionsClient;
33+
import com.langfuse.client.resources.trace.AsyncTraceClient;
34+
35+
public class AsyncLangfuseClient {
36+
protected final ClientOptions clientOptions;
37+
38+
protected final Supplier<AsyncAnnotationQueuesClient> annotationQueuesClient;
39+
40+
protected final Supplier<AsyncBlobStorageIntegrationsClient> blobStorageIntegrationsClient;
41+
42+
protected final Supplier<AsyncCommentsClient> commentsClient;
43+
44+
protected final Supplier<AsyncDatasetItemsClient> datasetItemsClient;
45+
46+
protected final Supplier<AsyncDatasetRunItemsClient> datasetRunItemsClient;
47+
48+
protected final Supplier<AsyncDatasetsClient> datasetsClient;
49+
50+
protected final Supplier<AsyncHealthClient> healthClient;
51+
52+
protected final Supplier<AsyncIngestionClient> ingestionClient;
53+
54+
protected final Supplier<AsyncLlmConnectionsClient> llmConnectionsClient;
55+
56+
protected final Supplier<AsyncMediaClient> mediaClient;
57+
58+
protected final Supplier<AsyncMetricsV2Client> metricsV2Client;
59+
60+
protected final Supplier<AsyncMetricsClient> metricsClient;
61+
62+
protected final Supplier<AsyncModelsClient> modelsClient;
63+
64+
protected final Supplier<AsyncObservationsV2Client> observationsV2Client;
65+
66+
protected final Supplier<AsyncObservationsClient> observationsClient;
67+
68+
protected final Supplier<AsyncOpentelemetryClient> opentelemetryClient;
69+
70+
protected final Supplier<AsyncOrganizationsClient> organizationsClient;
71+
72+
protected final Supplier<AsyncProjectsClient> projectsClient;
73+
74+
protected final Supplier<AsyncPromptVersionClient> promptVersionClient;
75+
76+
protected final Supplier<AsyncPromptsClient> promptsClient;
77+
78+
protected final Supplier<AsyncScimClient> scimClient;
79+
80+
protected final Supplier<AsyncScoreConfigsClient> scoreConfigsClient;
81+
82+
protected final Supplier<AsyncScoreV2Client> scoreV2Client;
83+
84+
protected final Supplier<AsyncScoreClient> scoreClient;
85+
86+
protected final Supplier<AsyncSessionsClient> sessionsClient;
87+
88+
protected final Supplier<AsyncTraceClient> traceClient;
89+
90+
public AsyncLangfuseClient(ClientOptions clientOptions) {
91+
this.clientOptions = clientOptions;
92+
this.annotationQueuesClient = Suppliers.memoize(() -> new AsyncAnnotationQueuesClient(clientOptions));
93+
this.blobStorageIntegrationsClient = Suppliers.memoize(() -> new AsyncBlobStorageIntegrationsClient(clientOptions));
94+
this.commentsClient = Suppliers.memoize(() -> new AsyncCommentsClient(clientOptions));
95+
this.datasetItemsClient = Suppliers.memoize(() -> new AsyncDatasetItemsClient(clientOptions));
96+
this.datasetRunItemsClient = Suppliers.memoize(() -> new AsyncDatasetRunItemsClient(clientOptions));
97+
this.datasetsClient = Suppliers.memoize(() -> new AsyncDatasetsClient(clientOptions));
98+
this.healthClient = Suppliers.memoize(() -> new AsyncHealthClient(clientOptions));
99+
this.ingestionClient = Suppliers.memoize(() -> new AsyncIngestionClient(clientOptions));
100+
this.llmConnectionsClient = Suppliers.memoize(() -> new AsyncLlmConnectionsClient(clientOptions));
101+
this.mediaClient = Suppliers.memoize(() -> new AsyncMediaClient(clientOptions));
102+
this.metricsV2Client = Suppliers.memoize(() -> new AsyncMetricsV2Client(clientOptions));
103+
this.metricsClient = Suppliers.memoize(() -> new AsyncMetricsClient(clientOptions));
104+
this.modelsClient = Suppliers.memoize(() -> new AsyncModelsClient(clientOptions));
105+
this.observationsV2Client = Suppliers.memoize(() -> new AsyncObservationsV2Client(clientOptions));
106+
this.observationsClient = Suppliers.memoize(() -> new AsyncObservationsClient(clientOptions));
107+
this.opentelemetryClient = Suppliers.memoize(() -> new AsyncOpentelemetryClient(clientOptions));
108+
this.organizationsClient = Suppliers.memoize(() -> new AsyncOrganizationsClient(clientOptions));
109+
this.projectsClient = Suppliers.memoize(() -> new AsyncProjectsClient(clientOptions));
110+
this.promptVersionClient = Suppliers.memoize(() -> new AsyncPromptVersionClient(clientOptions));
111+
this.promptsClient = Suppliers.memoize(() -> new AsyncPromptsClient(clientOptions));
112+
this.scimClient = Suppliers.memoize(() -> new AsyncScimClient(clientOptions));
113+
this.scoreConfigsClient = Suppliers.memoize(() -> new AsyncScoreConfigsClient(clientOptions));
114+
this.scoreV2Client = Suppliers.memoize(() -> new AsyncScoreV2Client(clientOptions));
115+
this.scoreClient = Suppliers.memoize(() -> new AsyncScoreClient(clientOptions));
116+
this.sessionsClient = Suppliers.memoize(() -> new AsyncSessionsClient(clientOptions));
117+
this.traceClient = Suppliers.memoize(() -> new AsyncTraceClient(clientOptions));
118+
}
119+
120+
public AsyncAnnotationQueuesClient annotationQueues() {
121+
return this.annotationQueuesClient.get();
122+
}
123+
124+
public AsyncBlobStorageIntegrationsClient blobStorageIntegrations() {
125+
return this.blobStorageIntegrationsClient.get();
126+
}
127+
128+
public AsyncCommentsClient comments() {
129+
return this.commentsClient.get();
130+
}
131+
132+
public AsyncDatasetItemsClient datasetItems() {
133+
return this.datasetItemsClient.get();
134+
}
135+
136+
public AsyncDatasetRunItemsClient datasetRunItems() {
137+
return this.datasetRunItemsClient.get();
138+
}
139+
140+
public AsyncDatasetsClient datasets() {
141+
return this.datasetsClient.get();
142+
}
143+
144+
public AsyncHealthClient health() {
145+
return this.healthClient.get();
146+
}
147+
148+
public AsyncIngestionClient ingestion() {
149+
return this.ingestionClient.get();
150+
}
151+
152+
public AsyncLlmConnectionsClient llmConnections() {
153+
return this.llmConnectionsClient.get();
154+
}
155+
156+
public AsyncMediaClient media() {
157+
return this.mediaClient.get();
158+
}
159+
160+
public AsyncMetricsV2Client metricsV2() {
161+
return this.metricsV2Client.get();
162+
}
163+
164+
public AsyncMetricsClient metrics() {
165+
return this.metricsClient.get();
166+
}
167+
168+
public AsyncModelsClient models() {
169+
return this.modelsClient.get();
170+
}
171+
172+
public AsyncObservationsV2Client observationsV2() {
173+
return this.observationsV2Client.get();
174+
}
175+
176+
public AsyncObservationsClient observations() {
177+
return this.observationsClient.get();
178+
}
179+
180+
public AsyncOpentelemetryClient opentelemetry() {
181+
return this.opentelemetryClient.get();
182+
}
183+
184+
public AsyncOrganizationsClient organizations() {
185+
return this.organizationsClient.get();
186+
}
187+
188+
public AsyncProjectsClient projects() {
189+
return this.projectsClient.get();
190+
}
191+
192+
public AsyncPromptVersionClient promptVersion() {
193+
return this.promptVersionClient.get();
194+
}
195+
196+
public AsyncPromptsClient prompts() {
197+
return this.promptsClient.get();
198+
}
199+
200+
public AsyncScimClient scim() {
201+
return this.scimClient.get();
202+
}
203+
204+
public AsyncScoreConfigsClient scoreConfigs() {
205+
return this.scoreConfigsClient.get();
206+
}
207+
208+
public AsyncScoreV2Client scoreV2() {
209+
return this.scoreV2Client.get();
210+
}
211+
212+
public AsyncScoreClient score() {
213+
return this.scoreClient.get();
214+
}
215+
216+
public AsyncSessionsClient sessions() {
217+
return this.sessionsClient.get();
218+
}
219+
220+
public AsyncTraceClient trace() {
221+
return this.traceClient.get();
222+
}
223+
224+
public static AsyncLangfuseClientBuilder builder() {
225+
return new AsyncLangfuseClientBuilder();
226+
}
227+
}

0 commit comments

Comments
 (0)