This project has been archived by its maintainers, and is no longer receiving any updates.
Dartmouth LangChain
LangChain components for Dartmouth-hosted models.
⚠️⚠️⚠️⚠️ Deprecation Notice ⚠️⚠️⚠️⚠️
The dartmouth_langchain package has been renamed to langchain_dartmouth, to conform with the existing third-party packages in the LangChain ecosystem. Versions higher than 0.2.7 will only be released under the new name.
Getting started
- Install the package:
pip install dartmouth-langchain
- Obtain a Dartmouth API key from developer.dartmouth.edu
- Store the API key as an environment variable called
DARTMOUTH_API_KEY:
export DARTMOUTH_API_KEY=<your_key_here>
What is this?
This library provides an integration of Darmouth-hosted generative AI resources with the LangChain framework.
There are three main components currently implemened:
- 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 two kinds of Large Language Models (LLMs) hosted by Dartmouth:
- Base models without instruction tuning (require no special prompt format)
- Instruction-tuned models (also known as Chat models) requiring specific prompt formats
Using a Dartmouth-hosted base language model:
from dartmouth_langchain.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 dartmouth_langchain.llms import ChatDartmouth
llm = ChatDartmouth(model_name="llama-3-8b-instruct")
response = llm.invoke("Hi there!")
print(response.content)
Note: The required prompt format is enforced automatically when you are using
ChatDartmouth.
Embeddings model
Using a Dartmouth-hosted embeddings model:
from dartmouth_langchain import DartmouthEmbeddingsModel
embeddings = DartmouthEmbeddingsModel()
embeddings.embed_query("Hello? Is there anybody in there?")
Reranking
Using a Dartmouth-hosted reranking model:
from dartmouth_langchain.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 documentation of the RESTful Dartmouth AI API.
License
|
Created by Simon Stone for Dartmouth College Libraries under Creative Commons CC BY-NC 4.0 License. For questions, comments, or improvements, email Research Data Services. |
Except where otherwise noted, the example programs are made available under the OSI-approved MIT license.
Metadata
Release files for dartmouth-langchain 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dartmouth_langchain-0.2.7.tar.gz | 9.9 kB | Without provenance | Details for dartmouth_langchain-0.2.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dartmouth_langchain-0.2.7-py3-none-any.whl | Python 3 | none | any | Details for dartmouth_langchain-0.2.7-py3-none-any.whl |
Total release size: 26.3 kB
Release files / dartmouth_langchain-0.2.7.tar.gz
| Download URL | dartmouth_langchain-0.2.7.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b2ecf269982887ff142655a7f59a935ba2ac6f183ae5b865b9ab2fc4ea6a968
|
|
BLAKE2b-256 checksum How to use checksums |
083acce4e7682a8a7373c6ac07bfbfc1f297d2ead156bb7b9a2d88d10f752b3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / dartmouth_langchain-0.2.7-py3-none-any.whl
| Download URL | dartmouth_langchain-0.2.7-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f93293726f5dcfc1f0727cac5c5717f198f2cab3ade589bfe0cba40698edfc99
|
|
BLAKE2b-256 checksum How to use checksums |
50372d12ad348f3f399f39d48f6fc168de4dd37e9afdf6b77b836e5cb3a0e3d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for dartmouth-langchain 0.2.7
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.