Skip to content

simon-langchain/pulledprompts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LangSmith Prompt Puller

This is a TypeScript project that demonstrates how to pull prompts from LangSmith using the LangChain library with the langchain/hub/node entrypoint.

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • LangSmith API key

Setup

  1. Install dependencies:

    npm install
  2. Set up your LangSmith API key as an environment variable:

    export LANGSMITH_API_KEY=your_api_key_here

    (Create an API key in LangSmith Settings > API Keys)

Usage

To pull a prompt from LangSmith:

  1. Set the prompt identifier in an environment variable:

    export LANGSMITH_PROMPT_ID=your-prompt-name
  2. Run the project:

    npm run dev

Examples

# Pull the latest version of a prompt
export LANGSMITH_PROMPT_ID=my-chat-prompt
npm run dev

# Pull a specific commit version of a prompt
export LANGSMITH_PROMPT_ID=my-chat-prompt:abc12345
npm run dev

How It Works

The script uses langchain/hub/node to:

  1. Pull prompts from your LangSmith workspace
  2. Attempt to deserialize models included in the prompt (with fallback)
  3. Display the prompt structure as JSON
  4. Run validation checks on the pulled prompt (version extraction, prompt info)

Features

  • Uses langchain/hub/node entrypoint for Node.js
  • Automatically handles API authentication via LANGSMITH_API_KEY
  • Graceful fallback when prompt includes serialized models that can't be deserialized
  • Clear error messages with debugging information
  • JSON output of retrieved prompts
  • Validation checks including prompt version extraction and metadata inspection
  • Single consolidated module (checks.ts) for all prompt validation logic

Project Structure

  • src/index.ts - Main entry point that pulls prompts from LangSmith
  • src/checks.ts - Prompt validation and version extraction logic
  • tsconfig.json - TypeScript configuration with Node16 module resolution
  • package.json - Dependencies and scripts
  • dist/ - Compiled JavaScript output

Development

For development with automatic TypeScript compilation:

npm run dev

Building for Production

npm run build

This will compile the TypeScript code to JavaScript in the dist directory.

Then run:

node dist/index.js

Documentation

For more information about pulling prompts from LangSmith, visit: https://docs.langchain.com/langsmith/manage-prompts-programmatically

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published