Skip to content

bleskowsky/langsmith-in-code

 
 

Repository files navigation

LangSmith in Code

This repository contains comprehensive tutorials and examples for implementing evaluations and tracing in code for LangSmith. Enjoy!

Pre-work

Clone the LangSmith Workshops repo

git clone https://github.com/achan-circle/langsmith-in-code

Install pip and python - skip if already installed

# Install brew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install python
$ brew install python

Create an environment and install dependencies

# Ensure you have a recent version of pip and python installed
$ cd langsmith-in-code
$ pip install uv
$ uv sync
$ uv venv

Create a .env file in the root repo folder using .env.example as an example.

Create .env file

$ cp .env.example .env
open .env

  1. fill in LANGSMITH_ENDPOINT, LANGSMITH_API_KEY, OPENAI_BASE_URL, and OPENAI_API_KEY as instructed.

Running notebooks

Make sure the following command works and opens the relevant notebooks

$ uv run jupyter notebook

The notebooks you should use are in the notebooks folder, which cover evaluations and tracing. Evaluations are in the evaluations.ipynb notebook and Tracing is in the tracing.ipynb notebook.

Adding CICD

There are two CICD modules included as part of this package

  1. Running offline evaluations using Github Actions. The relevant files are
    • .github/workflows/evaluate.yml: Contains the Github Action.
      • Requires you to create a fork of this repo and to create an environment called production which you configure secrets on.
      • This Github Action will trigger evaluations on pull request
    • cicd/test_evaluator.py: Simple pytest evaluation that will run through the Github Action
    • cicd/report_eval.py: Packages evaluation results to be attached to a pull request as a comment
  2. Configuring Prompt Commit Webhooks. The relevant files are
    • cicd/prompthook.py: Spins up a server to receive webhook notifications from LangSmith.
      • Can be spun up locally by running uvicorn cicd.prompthook:app --reload in the root directory of this repo.
      • Requires deployment to an external service like Render to connect to LangSmith see detailed instructions here

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 68.8%
  • Python 31.2%