LangChain Python

1 min read python, llm, genai

Lab note What I wrote down while learning this by building with it. Short by design; the code is in pfeilbr/langchain-python-playground.

learn LangChain (python)

concepts

  • Agents - use an LLM to determine which actions to take and in what order. An action can either be using a tool and observing its output, or returning to the user.

the llm is used to select the tool to use

langchain/agents/agent.py - _call method has main logic langchain/agents/types.py langchain/agents/mrkl/prompt.py langchain/agents/**/*prompt.py - these contain all the prompts for different agents

demo

pipenv shell
export OPENAI_API_KEY=...
export SERPAPI_API_KEY=...
jupyter lab
# visit `main.ipynb`

resources

Keep learning

Get new guides and courses by email

An occasional email when I publish a new guide, course or post. No spam, and you can unsubscribe any time.

Sent with Buttondown. I never share your address. Prefer a feed? Use the RSS feed.