|
1 | | -plugins { |
2 | | - id 'java' |
3 | | - id 'application' |
4 | | -} |
5 | | - |
6 | | -java { |
7 | | - toolchain { |
8 | | - languageVersion = JavaLanguageVersion.of(17) |
9 | | - vendor = JvmVendorSpec.ADOPTIUM // eclipse JVM |
10 | | - } |
11 | | - withJavadocJar() |
12 | | - withSourcesJar() |
13 | | -} |
14 | | - |
15 | | -repositories { |
16 | | - mavenCentral() |
17 | | -} |
18 | | - |
19 | | -def braintrustLogLevel = System.getenv('BRAINTRUST_LOG_LEVEL') ?: 'info' |
20 | | - |
21 | | -dependencies { |
22 | | - implementation project(':braintrust-sdk') |
23 | | - implementation project(':braintrust-sdk:instrumentation:openai_2_15_0') |
24 | | - implementation project(':braintrust-sdk:instrumentation:anthropic_2_2_0') |
25 | | - implementation project(':braintrust-sdk:instrumentation:genai_1_18_0') |
26 | | - implementation project(':braintrust-sdk:instrumentation:langchain_1_8_0') |
27 | | - implementation project(':braintrust-sdk:instrumentation:springai_1_0_0') |
28 | | - implementation project(':braintrust-sdk:instrumentation:aws_bedrock_2_30_0') |
29 | | - runtimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}" |
30 | | - // To run otel examples |
31 | | - implementation "io.opentelemetry:opentelemetry-exporter-otlp:${otelVersion}" |
32 | | - // to run OAI instrumentation examples |
33 | | - implementation 'com.openai:openai-java:2.8.1' |
34 | | - // to run anthropic examples |
35 | | - implementation "com.anthropic:anthropic-java:2.8.1" |
36 | | - // to run gemini examples |
37 | | - implementation 'com.google.genai:google-genai:1.20.0' |
38 | | - // spring ai examples |
39 | | - implementation 'org.springframework.ai:spring-ai-anthropic:1.1.0' |
40 | | - implementation 'org.springframework.ai:spring-ai-bedrock-converse:1.1.0' |
41 | | - implementation 'org.springframework.ai:spring-ai-google-genai:1.1.0' |
42 | | - implementation 'org.springframework.ai:spring-ai-openai:1.1.0' |
43 | | - // spring-ai-openai requires spring-webflux (WebClient) at runtime |
44 | | - implementation 'org.springframework:spring-webflux:6.2.3' |
45 | | - // spring boot for SpringAIExample (exclude logback, use slf4j-simple like other examples) |
46 | | - implementation('org.springframework.boot:spring-boot-starter:3.4.1') { |
47 | | - exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' |
48 | | - } |
49 | | - // to run langchain4j examples |
50 | | - implementation 'dev.langchain4j:langchain4j:1.9.1' |
51 | | - implementation 'dev.langchain4j:langchain4j-open-ai:1.9.1' |
52 | | - |
53 | | -} |
54 | | - |
55 | | -application { |
56 | | - mainClass = 'dev.braintrust.examples.SimpleOpenTelemetryExample' |
57 | | -} |
58 | | - |
59 | | -task runSimpleOpenTelemetry(type: JavaExec) { |
60 | | - group = 'Braintrust SDK Examples' |
61 | | - description = 'Run the simple OpenTelemetry example' |
62 | | - classpath = sourceSets.main.runtimeClasspath |
63 | | - mainClass = 'dev.braintrust.examples.SimpleOpenTelemetryExample' |
64 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
65 | | -} |
66 | | - |
67 | | -task runCustomOpenTelemetry(type: JavaExec) { |
68 | | - group = 'Braintrust SDK Examples' |
69 | | - description = 'Run the custom OpenTelemetry example' |
70 | | - classpath = sourceSets.main.runtimeClasspath |
71 | | - mainClass = 'dev.braintrust.examples.CustomOpenTelemetryExample' |
72 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
73 | | -} |
| 1 | +// Shared convention for all example subprojects. |
| 2 | +// |
| 3 | +// Each example lives in its own subproject under examples/ and applies the |
| 4 | +// 'application' plugin so it can be launched with: |
| 5 | +// |
| 6 | +// ./gradlew :examples:<example-name>:run |
| 7 | +// |
| 8 | +// List every example via: |
| 9 | +// |
| 10 | +// ./gradlew projects |
| 11 | +// |
| 12 | +// Per-example build.gradle files only declare their mainClass, extra |
| 13 | +// dependencies, and (optionally) a description / debugOptions block on the |
| 14 | +// inherited 'run' task. |
74 | 15 |
|
75 | | -task runOpenAIInstrumentation(type: JavaExec) { |
76 | | - group = 'Braintrust SDK Examples' |
77 | | - description = 'Run the OpenAI instrumentation example. NOTE: this requires OPENAI_API_KEY to be exported and will make a small call to openai, using your tokens' |
78 | | - classpath = sourceSets.main.runtimeClasspath |
79 | | - mainClass = 'dev.braintrust.examples.OpenAIInstrumentationExample' |
80 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
81 | | - debugOptions { |
82 | | - enabled = true |
83 | | - port = 5566 |
84 | | - server = true |
85 | | - suspend = false |
86 | | - } |
87 | | -} |
| 16 | +subprojects { |
| 17 | + apply plugin: 'java' |
| 18 | + apply plugin: 'application' |
88 | 19 |
|
89 | | -task runExperiment(type: JavaExec) { |
90 | | - group = 'Braintrust SDK Examples' |
91 | | - description = 'Run the experiment example' |
92 | | - classpath = sourceSets.main.runtimeClasspath |
93 | | - mainClass = 'dev.braintrust.examples.ExperimentExample' |
94 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
95 | | - debugOptions { |
96 | | - enabled = true |
97 | | - port = 5566 |
98 | | - server = true |
99 | | - suspend = false |
100 | | - } |
101 | | -} |
| 20 | + group = rootProject.group |
| 21 | + version = rootProject.version |
102 | 22 |
|
103 | | -task runAnthropicInstrumentation(type: JavaExec) { |
104 | | - group = 'Braintrust SDK Examples' |
105 | | - description = 'Run the Anthropic instrumentation example. NOTE: this requires ANTHROPIC_API_KEY to be exported and will make a small call to anthropic, using your tokens' |
106 | | - classpath = sourceSets.main.runtimeClasspath |
107 | | - mainClass = 'dev.braintrust.examples.AnthropicInstrumentationExample' |
108 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
109 | | - debugOptions { |
110 | | - enabled = true |
111 | | - port = 5566 |
112 | | - server = true |
113 | | - suspend = false |
| 23 | + java { |
| 24 | + toolchain { |
| 25 | + languageVersion = JavaLanguageVersion.of(17) |
| 26 | + vendor = JvmVendorSpec.ADOPTIUM // eclipse JVM |
| 27 | + } |
114 | 28 | } |
115 | | -} |
116 | 29 |
|
117 | | - |
118 | | -task runPromptFetching(type: JavaExec) { |
119 | | - group = 'Braintrust SDK Examples' |
120 | | - description = 'Run the prompt fetching example' |
121 | | - classpath = sourceSets.main.runtimeClasspath |
122 | | - mainClass = 'dev.braintrust.examples.PromptFetchingExample' |
123 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
124 | | - debugOptions { |
125 | | - enabled = true |
126 | | - port = 5566 |
127 | | - server = true |
128 | | - suspend = false |
| 30 | + repositories { |
| 31 | + mavenCentral() |
129 | 32 | } |
130 | | -} |
131 | 33 |
|
132 | | -task runGeminiInstrumentation(type: JavaExec) { |
133 | | - group = 'Braintrust SDK Examples' |
134 | | - description = 'Run the Gemini instrumentation example. NOTE: this requires GOOGLE_API_KEY or GEMINI_API_KEY to be exported and will make a small call to google, using your tokens' |
135 | | - classpath = sourceSets.main.runtimeClasspath |
136 | | - mainClass = 'dev.braintrust.examples.GeminiInstrumentationExample' |
137 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
138 | | - debugOptions { |
139 | | - enabled = true |
140 | | - port = 5566 |
141 | | - server = true |
142 | | - suspend = false |
143 | | - } |
144 | | -} |
| 34 | + def braintrustLogLevel = System.getenv('BRAINTRUST_LOG_LEVEL') ?: 'info' |
145 | 35 |
|
146 | | -task runSpringAI(type: JavaExec) { |
147 | | - group = 'Braintrust SDK Examples' |
148 | | - description = 'Run the Spring Boot + Spring AI example' |
149 | | - classpath = sourceSets.main.runtimeClasspath |
150 | | - mainClass = 'dev.braintrust.examples.SpringAIExample' |
151 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
152 | | - |
153 | | - debugOptions { |
154 | | - enabled = true |
155 | | - port = 5566 |
156 | | - server = true |
157 | | - suspend = false |
158 | | - } |
159 | | -} |
160 | | - |
161 | | -task runRemoteEval(type: JavaExec) { |
162 | | - group = 'Braintrust SDK Examples' |
163 | | - description = 'Run the remote eval example' |
164 | | - classpath = sourceSets.main.runtimeClasspath |
165 | | - mainClass = 'dev.braintrust.examples.RemoteEvalExample' |
166 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
167 | | - debugOptions { |
168 | | - enabled = true |
169 | | - port = 5566 |
170 | | - server = true |
171 | | - suspend = false |
| 36 | + dependencies { |
| 37 | + implementation project(':braintrust-sdk') |
| 38 | + runtimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}" |
172 | 39 | } |
173 | | -} |
174 | | - |
175 | | -task runLangchainSimple(type: JavaExec) { |
176 | | - group = 'Braintrust SDK Examples' |
177 | | - description = 'Run the LangChain4j instrumentation example. NOTE: this requires OPENAI_API_KEY to be exported and will make a small call to openai, using your tokens' |
178 | | - classpath = sourceSets.main.runtimeClasspath |
179 | | - mainClass = 'dev.braintrust.examples.LangchainSimpleExample' |
180 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
181 | | - debugOptions { |
182 | | - enabled = true |
183 | | - port = 5566 |
184 | | - server = true |
185 | | - suspend = false |
186 | | - } |
187 | | -} |
188 | 40 |
|
189 | | -task runLangchainAIServices(type: JavaExec) { |
190 | | - group = 'Braintrust SDK Examples' |
191 | | - description = 'Run the LangChain4j AI Services example. NOTE: this requires OPENAI_API_KEY to be exported and will make a small call to openai, using your tokens' |
192 | | - classpath = sourceSets.main.runtimeClasspath |
193 | | - mainClass = 'dev.braintrust.examples.LangchainAIServicesExample' |
194 | | - systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
195 | | - debugOptions { |
196 | | - enabled = true |
197 | | - port = 5566 |
198 | | - server = true |
199 | | - suspend = false |
| 41 | + tasks.named('run') { |
| 42 | + group = 'Braintrust SDK Examples' |
| 43 | + systemProperty 'org.slf4j.simpleLogger.log.dev.braintrust', braintrustLogLevel |
200 | 44 | } |
201 | 45 | } |
0 commit comments