A high-level client for pulling prompts from the LangSmith hub.
public class PromptClientA high-level client for pulling prompts from the LangSmith hub. This wraps the lower-level [LangsmithClient.commits] service and provides a convenient interface that mirrors the Python and TypeScript SDKs' prompt pulling experience.
import com.langchain.smith.client.okhttp.LangsmithOkHttpClient;
import com.langchain.smith.prompts.PromptClient;
import static com.langchain.smith.prompts.PromptConverters.convertToOpenAIParams;
import static com.langchain.smith.prompts.PromptConverters.convertToAnthropicParams;
LangsmithClient client = LangsmithOkHttpClient.fromEnv();
PromptClient promptClient = PromptClient.create(client);
Prompt prompt = promptClient.pull("my-org/joke-generator");
PromptValue formattedPrompt = prompt.invoke(Map.of("topic", "cats"));
ChatCompletion completion = openai.chat().completions().create(
convertToOpenAIParams(formattedPrompt)
.model(ChatModel.GPT_4_1_MINI)
.build());
The prompt identifier can be in any of these formats:
"name" — uses the default owner ("-") and latest commit"owner/name" — specifies the owner"name:commit_or_tag" — specifies a commit hash or tag"owner/name:commit_or_tag" — specifies both owner and commit/tagPulls a prompt from the LangSmith hub and returns a [Prompt] that can be invoked with input variables.
Pulls the raw prompt commit from the LangSmith hub.
Creates a [PromptClient] wrapping the given [LangsmithClient]..
Parses a prompt identifier string into its component parts.