Anything you do to LangChain twice should be automated. This walks the path from a manual install to a repeatable, pipeline-driven setup.
1. Install it reproducibly
pip install langchain langchain-openai langchain-community
export OPENAI_API_KEY=... # keep keys in a secret manager2. Describe the desired state
A tiny RAG chain over local documents.
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_community.vectorstores import FAISS
vs = FAISS.from_texts(docs, OpenAIEmbeddings())
retriever = vs.as_retriever(search_kwargs={'k': 4})
llm = ChatOpenAI(model='gpt-4o-mini', temperature=0)
def answer(q):
ctx = '\n'.join(d.page_content for d in retriever.invoke(q))
return llm.invoke(f'Use only this context:\n{ctx}\n\nQ: {q}').content3. Run it from CI
Run evals against a golden set in CI with LangSmith.
- run: |
pip install langsmith
python evals/run.py # scores answers vs a labelled dataset, fails under thresholdWant senior help putting LangChain to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.