Skip to main content

Dartmouth LangChain

documentation tests

LangChain components for Dartmouth-hosted models.

Getting started

  1. Install the package:
pip install langchain_dartmouth
  1. Obtain a Dartmouth API key from developer.dartmouth.edu
  2. Store the API key as an environment variable called DARTMOUTH_API_KEY:
export DARTMOUTH_API_KEY=<your_key_here>
  1. Obtain a Dartmouth Chat API key
  2. Store the API key as an environment variable called DARTMOUTH_CHAT_API_KEY
export DARTMOUTH_CHAT_API_KEY=<your_key_here>

What is this?

This library provides an integration of Darmouth-provided generative AI resources with the LangChain framework.

There are three main components currently implemented:

  • Large Language Models
  • Embedding models
  • Reranking models

All of these components are based on corresponding LangChain base classes and can be used seamlessly wherever the corresponding LangChain objects can be used.

Using the library

Large Language Models

There are three kinds of Large Language Models (LLMs) provided by Dartmouth:

  • On-premises:
    • Base models without instruction tuning (require no special prompt format)
    • Instruction-tuned models (also known as Chat models) requiring specific prompt formats
  • Cloud:
    • Third-party, pay-as-you-go chat models (e.g., OpenAI's GPT 4.1, Google Gemini)

Using a Dartmouth-hosted base language model:

from langchain_dartmouth.llms import DartmouthLLM

llm = DartmouthLLM(model_name="codellama-13b-hf")

response = llm.invoke("Write a Python script to swap two variables.")
print(response)

Using a Dartmouth-hosted chat model:

from langchain_dartmouth.llms import ChatDartmouth


llm = ChatDartmouth(model_name="meta.llama-3-2-11b-vision-instruct")

response = llm.invoke("Hi there!")

print(response.content)

Using a Dartmouth-provided third-party chat model:

from langchain_dartmouth.llms import ChatDartmouth


llm = ChatDartmouth(model_name="openai.gpt-4.1-mini-2025-04-14")

response = llm.invoke("Hi there!")

Embeddings model

Using a Dartmouth-hosted embeddings model:

from langchain_dartmouth.embeddings import DartmouthEmbeddings


embeddings = DartmouthEmbeddings()

embeddings.embed_query("Hello? Is there anybody in there?")

print(response)

Reranking

Using a Dartmouth-hosted reranking model:

from langchain_dartmouth.retrievers.document_compressors import DartmouthReranker
from langchain.docstore.document import Document


docs = [
    Document(page_content="Deep Learning is not..."),
    Document(page_content="Deep learning is..."),
    ]

query = "What is Deep Learning?"
reranker = DartmouthReranker(model_name="bge-reranker-v2-m3")
ranked_docs = reranker.compress_documents(query=query, documents=docs)

print(ranked_docs)

Available models

For a list of available models, check the respective list() method of each class.

How to cite

If you are using langchain_dartmouth as part of a scientific publication, we would greatly appreciate a citation of the following paper:

@inproceedings{10.1145/3708035.3736076,
  author = {Stone, Simon and Crossett, Jonathan and Luker, Tivon and Leligdon, Lora and Cowen, William and Darabos, Christian},
  title = {Dartmouth Chat - Deploying an Open-Source LLM Stack at Scale},
  year = {2025},
  isbn = {9798400713989},
  publisher = {Association for Computing Machinery},
  address = {New York, NY, USA},
  doi = {10.1145/3708035.3736076},
  booktitle = {Practice and Experience in Advanced Research Computing 2025: The Power of Collaboration},
  articleno = {43},
  numpages = {5}
}

License

Created by Simon Stone for Dartmouth College under Creative Commons CC BY-NC 4.0 License.
For questions, comments, or improvements, email Research Computing.
Creative Commons License

Except where otherwise noted, the example programs are made available under the OSI-approved MIT license.

Metadata

Release files for langchain-dartmouth 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-dartmouth 0.3.2
File Size Uploaded Provenance Actions
langchain_dartmouth-0.3.2.tar.gz 6.1 MB With provenance Details for langchain_dartmouth-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-dartmouth 0.3.2
File Interpreter ABI Platform Actions
langchain_dartmouth-0.3.2-py3-none-any.whl Python 3 none any Details for langchain_dartmouth-0.3.2-py3-none-any.whl

Total release size: 6.1 MB

Release files / langchain_dartmouth-0.3.2.tar.gz

Download URL langchain_dartmouth-0.3.2.tar.gz
Size 6.1 MB
Tags Source
SHA-256 checksum
How to use checksums
418de115f9c9f11bbaa0f9e0cdb85349641e0bb3601584b63b8b0290c2a54867
BLAKE2b-256 checksum
How to use checksums
7309819d0ec36d899c519094113b16a1eef8f36f3b7ff54774fc1f74d5350fcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.

Transparency log

Release files / langchain_dartmouth-0.3.2-py3-none-any.whl

Download URL langchain_dartmouth-0.3.2-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35c3c3472eab3baf06a88d2715d1d50d4b76501af4e8e4f3a9b7c4308f062446
BLAKE2b-256 checksum
How to use checksums
02c5daa76345655b221c0a6445918002d6796f3f94154a9b8992bea78d5fa0e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.

Transparency log

Security for langchain-dartmouth 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_dartmouth-0.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page