Skip to content

Commit 17c829f

Browse files
committed
java setup
1 parent da6df94 commit 17c829f

File tree

4 files changed

+82
-99
lines changed

4 files changed

+82
-99
lines changed

β€Žsrc/docs.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@
11681168
"langsmith/setup-app-requirements-txt",
11691169
"langsmith/setup-pyproject",
11701170
"langsmith/setup-javascript",
1171+
"langsmith/setup-java",
11711172
"langsmith/monorepo-support"
11721173
]
11731174
},

β€Žsrc/langsmith/setup-app-requirements-txt.mdxβ€Ž

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -42,104 +42,6 @@ You can also set up with:
4242
- `pyproject.toml`: If you prefer using poetry for dependency management, check out [this how-to guide](/langsmith/setup-pyproject) on using `pyproject.toml` for LangSmith.
4343
- a monorepo: If you are interested in deploying a graph located inside a monorepo, take a look at [this repository](https://github.com/langchain-ai/langgraph-example-monorepo) for an example of how to do so.
4444

45-
## Java Setup {#java-setup}
46-
47-
For Java applications, use Maven or Gradle for dependency management.
48-
49-
### Maven Setup
50-
51-
Example `pom.xml` file:
52-
53-
```xml
54-
<?xml version="1.0" encoding="UTF-8"?>
55-
<project xmlns="http://maven.apache.org/POM/4.0.0"
56-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
57-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
58-
http://maven.apache.org/xsd/maven-4.0.0.xsd">
59-
<modelVersion>4.0.0</modelVersion>
60-
61-
<groupId>com.example</groupId>
62-
<artifactId>my-langsmith-app</artifactId>
63-
<version>1.0.0</version>
64-
65-
<properties>
66-
<maven.compiler.source>11</maven.compiler.source>
67-
<maven.compiler.target>11</maven.compiler.target>
68-
<langsmith.version>0.1.0-alpha.17</langsmith.version>
69-
</properties>
70-
71-
<dependencies>
72-
<dependency>
73-
<groupId>com.langchain.smith</groupId>
74-
<artifactId>langsmith-java</artifactId>
75-
<version>${langsmith.version}</version>
76-
</dependency>
77-
<dependency>
78-
<groupId>com.openai</groupId>
79-
<artifactId>openai-java</artifactId>
80-
<version>0.20.2</version>
81-
</dependency>
82-
<dependency>
83-
<groupId>io.opentelemetry</groupId>
84-
<artifactId>opentelemetry-sdk</artifactId>
85-
<version>1.34.1</version>
86-
</dependency>
87-
</dependencies>
88-
</project>
89-
```
90-
91-
### Gradle Setup
92-
93-
Example `build.gradle.kts` file:
94-
95-
```kotlin
96-
plugins {
97-
java
98-
application
99-
}
100-
101-
group = "com.example"
102-
version = "1.0.0"
103-
104-
java {
105-
sourceCompatibility = JavaVersion.VERSION_11
106-
targetCompatibility = JavaVersion.VERSION_11
107-
}
108-
109-
repositories {
110-
mavenCentral()
111-
}
112-
113-
dependencies {
114-
implementation("com.langchain.smith:langsmith-java:0.1.0-alpha.17")
115-
implementation("com.openai:openai-java:0.20.2")
116-
implementation("io.opentelemetry:opentelemetry-sdk:1.34.1")
117-
}
118-
119-
application {
120-
mainClass.set("com.example.Main")
121-
}
122-
```
123-
124-
### Java Project Structure
125-
126-
```bash
127-
my-app/
128-
β”œβ”€β”€ src/
129-
β”‚ └── main/
130-
β”‚ └── java/
131-
β”‚ └── com/
132-
β”‚ └── example/
133-
β”‚ β”œβ”€β”€ Main.java
134-
β”‚ └── agent/
135-
β”‚ β”œβ”€β”€ Agent.java
136-
β”‚ └── tools/
137-
β”‚ └── Tools.java
138-
β”œβ”€β”€ .env # environment variables
139-
β”œβ”€β”€ pom.xml # Maven dependencies
140-
└── build.gradle.kts # Or Gradle dependencies
141-
```
142-
14345
After each step, an example file directory is provided to demonstrate how code can be organized.
14446

14547
## Specify dependencies

β€Žsrc/langsmith/setup-java.mdxβ€Ž

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: How to set up a Java application
3+
sidebarTitle: Set up a Java application
4+
---
5+
6+
This guide covers the basic configuration files needed to use the LangSmith Java SDK in your application.
7+
8+
## Specify dependencies
9+
10+
Dependencies can be specified using either Maven or Gradle. The LangSmith Java SDK requires **Java 8 or later**.
11+
12+
### Maven
13+
14+
Add the LangSmith Java SDK to your `pom.xml`:
15+
16+
```xml
17+
<dependency>
18+
<groupId>com.langchain.smith</groupId>
19+
<artifactId>langsmith-java</artifactId>
20+
<version>0.1.0-alpha.17</version>
21+
</dependency>
22+
```
23+
24+
Example file directory:
25+
26+
```bash
27+
my-app/
28+
└── pom.xml # Maven dependencies
29+
```
30+
31+
### Gradle
32+
33+
Add the LangSmith Java SDK to your `build.gradle.kts` or `build.gradle`:
34+
35+
```kotlin
36+
implementation("com.langchain.smith:langsmith-java:0.1.0-alpha.17")
37+
```
38+
39+
Example file directory:
40+
41+
```bash
42+
my-app/
43+
└── build.gradle.kts # Gradle dependencies
44+
```
45+
46+
## Specify environment variables
47+
48+
The LangSmith Java SDK configures itself through environment variables. See the [Environment Variables reference](/langsmith/env-var) to configure additional variables for tracing.
49+
50+
Example `.env` file:
51+
52+
```bash
53+
# Required: LangSmith API Key
54+
LANGSMITH_API_KEY=lsv2_...
55+
56+
# Optional: Custom LangSmith API endpoint
57+
# LANGSMITH_ENDPOINT=https://api.smith.langchain.com
58+
59+
# Optional: Organization and tenant settings
60+
# LANGSMITH_ORGANIZATION_ID=your-org-id
61+
# LANGSMITH_TENANT_ID=your-tenant-id
62+
```
63+
64+
The SDK will automatically read these environment variables when you initialize the client using `LangsmithOkHttpClient.fromEnv()`.
65+
66+
Example file directory:
67+
68+
```bash
69+
my-app/
70+
β”œβ”€β”€ pom.xml # or build.gradle.kts
71+
└── .env # environment variables
72+
```
73+
74+
## Next
75+
76+
After you configure your Java application with the LangSmith SDK, you can:
77+
- [Log traces to a specific project](/langsmith/log-traces-to-project)
78+
- [Track costs and usage](/langsmith/cost-tracking)
79+
- [Create and manage datasets](/langsmith/manage-datasets-programmatically)
80+
- [Query and export traces](/langsmith/export-traces)
81+
- [Manage prompts programmatically](/langsmith/manage-prompts-programmatically)

β€Žsrc/langsmith/setup-pyproject.mdxβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ You can also set up with:
4040

4141
- `requirements.txt`: for dependency management, check out [this how-to guide](/langsmith/setup-app-requirements-txt) on using `requirements.txt` for LangSmith.
4242
- a monorepo: To deploy a graph located inside a monorepo, take a look at [this repository](https://github.com/langchain-ai/langgraph-example-monorepo) for an example of how to do so.
43-
- **Java**: For Java applications, use Maven's `pom.xml` or Gradle's `build.gradle.kts` for dependency management. See [setup with Maven/Gradle](/langsmith/setup-app-requirements-txt#java-setup) for Java-specific configuration.
4443

4544
After each step, an example file directory is provided to demonstrate how code can be organized.
4645

0 commit comments

Comments
Β (0)