[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74YWK3PW23GXBWFG9F3BQM7":3,"skill-same:01M74YWK3PW23GXBWFG9F3BQM7":78},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":37,"ownerDescription":38,"updatedAt":39,"install":40,"resources":53},"01M74YWK3PW23GXBWFG9F3BQM7","langchain",null,"Framework for building LLM-powered applications with agents, chains, and RAG. Supports multiple providers (OpenAI, Anthropic, Google), 500+ integrations, ReAct agents, tool calling, memory management, and vector store retrieval. Use for building chatbots, question-answering systems, autonomous agents, or RAG applications. Best for rapid prototyping and production deployments.","KalarisLabs\u002Fresearch-agent-skills","KalarisLabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F300878568?v=4","01M74Y7MT23GXXC56VM6TVSXZY","Kalarislabs","01M74Y7MTQM9REXZX4SNXWX95C",132,"MIT","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Flangchain\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: langchain\ndescription: Framework for building LLM-powered applications with agents, chains, and RAG. Supports multiple providers (OpenAI, Anthropic, Google), 500+ integrations, ReAct agents, tool calling, memory management, and vector store retrieval. Use for building chatbots, question-answering systems, autonomous agents, or RAG applications. Best for rapid prototyping and production deployments.\nlicense: MIT\nmetadata:\n  version: 1.0.0\n  category: llm-applications\n  maintainer: Kalaris Labs\n  tags: Agents, LangChain, RAG, Tool Calling, ReAct, Memory Management, Vector Stores, LLM Applications, Chatbots, Production\n  dependencies: langchain, langchain-core, langchain-openai, langchain-anthropic\n---\n\n# LangChain - Build LLM Applications with Agents & RAG\n\nThe most popular framework for building LLM-powered applications.\n\n## When to use LangChain\n\n**Use LangChain when:**\n- Building agents with tool calling and reasoning (ReAct pattern)\n- Implementing RAG (retrieval-augmented generation) pipelines\n- Need to swap LLM providers easily (OpenAI, Anthropic, Google)\n- Creating chatbots with conversation memory\n- Rapid prototyping of LLM applications\n- Production deployments with LangSmith observability\n\n**Metrics**:\n- **272,000+ repositories** use LangChain\n- **500+ integrations** (models, vector stores, tools)\n- **3,800+ contributors**\n\n**Use alternatives instead**:\n- **LlamaIndex**: RAG-focused, better for document Q&A\n- **LangGraph**: Complex stateful workflows, more control\n- **Haystack**: Production search pipelines\n- **Semantic Kernel**: Microsoft ecosystem\n\n## Quick start\n\n### Installation\n\n```bash\n# Core library (Python 3.10+)\npip install -U langchain\n\n# With OpenAI\npip install langchain-openai\n\n# With Anthropic\npip install langchain-anthropic\n\n# Common extras\npip install langchain-community  # 500+ integrations\npip install langchain-chroma     # Vector store\n```\n\n### Basic LLM usage\n\n```python\nfrom langchain_anthropic import ChatAnthropic\n\n# Initialize model\nllm = ChatAnthropic(model=\"claude-sonnet-4-5-20250929\")\n\n# Simple completion\nresponse = llm.invoke(\"Explain quantum computing in 2 sentences\")\nprint(response.content)\n```\n\n### Create an agent (ReAct pattern)\n\n```python\nfrom langchain.agents import create_agent\nfrom langchain_anthropic import ChatAnthropic\n\n# Define tools\ndef get_weather(city: str) -> str:\n    \"\"\"Get current weather for a city.\"\"\"\n    return f\"It's sunny in {city}, 72°F\"\n\ndef search_web(query: str) -> str:\n    \"\"\"Search the web for information.\"\"\"\n    return f\"Search results for: {query}\"\n\n# Create agent (\u003C10 lines!)\nagent = create_agent(\n    model=ChatAnthropic(model=\"claude-sonnet-4-5-20250929\"),\n    tools=[get_weather, search_web],\n    system_prompt=\"You are a helpful assistant. Use tools when needed.\"\n)\n\n# Run agent\nresult = agent.invoke({\"messages\": [{\"role\": \"user\", \"content\": \"What's the weather in Paris?\"}]})\nprint(result[\"messages\"][-1].content)\n```\n\n## Core concepts\n\n### 1. Models - LLM abstraction\n\n```python\nfrom langchain_openai import ChatOpenAI\nfrom langchain_anthropic import ChatAnthropic\nfrom langchain_google_genai import ChatGoogleGenerativeAI\n\n# Swap providers easily\nllm = ChatOpenAI(model=\"gpt-4o\")\nllm = ChatAnthropic(model=\"claude-sonnet-4-5-20250929\")\nllm = ChatGoogleGenerativeAI(model=\"gemini-2.0-flash-exp\")\n\n# Streaming\nfor chunk in llm.stream(\"Write a poem\"):\n    print(chunk.content, end=\"\", flush=True)\n```\n\n### 2. Chains - Sequential operations\n\n```python\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\n\n# Define prompt template\nprompt = PromptTemplate(\n    input_variables=[\"topic\"],\n    template=\"Write a 3-sentence summary about {topic}\"\n)\n\n# Create chain\nchain = LLMChain(llm=llm, prompt=prompt)\n\n# Run chain\nresult = chain.run(topic=\"machine learning\")\n```\n\n### 3. Agents - Tool-using reasoning\n\n**ReAct (Reasoning + Acting) pattern:**\n\n```python\nfrom langchain.agents import create_tool_calling_agent, AgentExecutor\nfrom langchain.tools import Tool\nfrom scripts.safe_arithmetic import calculate\n\n# Define custom tool\ncalculator = Tool(\n    name=\"Calculator\",\n    func=lambda x: str(calculate(x)),\n    description=\"Useful for arithmetic with numbers and +, -, *, \u002F.\"\n)\n\n# Create agent with tools\nagent = create_tool_calling_agent(\n    llm=llm,\n    tools=[calculator, search_web],\n    prompt=\"Answer questions using available tools\"\n)\n\n# Create executor\nagent_executor = AgentExecutor(agent=agent, tools=[calculator], verbose=True)\n\n# Run with reasoning\nresult = agent_executor.invoke({\"input\": \"What is 25 * 17 + 142?\"})\n```\n\n### 4. Memory - Conversation history\n\n```python\nfrom langchain.memory import ConversationBufferMemory\nfrom langchain.chains import ConversationChain\n\n# Add memory to track conversation\nmemory = ConversationBufferMemory()\n\nconversation = ConversationChain(\n    llm=llm,\n    memory=memory,\n    verbose=True\n)\n\n# Multi-turn conversation\nconversation.predict(input=\"Hi, I'm Alice\")\nconversation.predict(input=\"What's my name?\")  # Remembers \"Alice\"\n```\n\n## RAG (Retrieval-Augmented Generation)\n\nDetails, code examples and parameter tables: [references\u002Frag-retrieval-augmented-generation.md](references\u002Frag-retrieval-augmented-generation.md). Read it when this step applies.\n\n## Advanced agent patterns\n\n### Structured output\n\n```python\nfrom langchain_core.pydantic_v1 import BaseModel, Field\n\n# Define schema\nclass WeatherReport(BaseModel):\n    city: str = Field(description=\"City name\")\n    temperature: float = Field(description=\"Temperature in Fahrenheit\")\n    condition: str = Field(description=\"Weather condition\")\n\n# Get structured response\nstructured_llm = llm.with_structured_output(WeatherReport)\nresult = structured_llm.invoke(\"What's the weather in SF? It's 65F and sunny\")\nprint(result.city, result.temperature, result.condition)\n```\n\n### Parallel tool execution\n\n```python\nfrom langchain.agents import create_tool_calling_agent\n\n# Agent automatically parallelizes independent tool calls\nagent = create_tool_calling_agent(\n    llm=llm,\n    tools=[get_weather, search_web, calculator]\n)\n\n# This will call get_weather(\"Paris\") and get_weather(\"London\") in parallel\nresult = agent.invoke({\n    \"messages\": [{\"role\": \"user\", \"content\": \"Compare weather in Paris and London\"}]\n})\n```\n\n### Streaming agent execution\n\n```python\n# Stream agent steps\nfor step in agent_executor.stream({\"input\": \"Research AI trends\"}):\n    if \"actions\" in step:\n        print(f\"Tool: {step['actions'][0].tool}\")\n    if \"output\" in step:\n        print(f\"Output: {step['output']}\")\n```\n\n## Common patterns\n\n### Multi-document QA\n\n```python\nfrom langchain.chains.qa_with_sources import load_qa_with_sources_chain\n\n# Load multiple documents\ndocs = [\n    loader.load(\"https:\u002F\u002Fdocs.python.org\"),\n    loader.load(\"https:\u002F\u002Fdocs.numpy.org\")\n]\n\n# QA with source citations\nchain = load_qa_with_sources_chain(llm, chain_type=\"stuff\")\nresult = chain({\"input_documents\": docs, \"question\": \"How to use numpy arrays?\"})\nprint(result[\"output_text\"])  # Includes source citations\n```\n\n### Custom tools with error handling\n\n```python\nfrom langchain.tools import tool\n\n@tool\ndef risky_operation(query: str) -> str:\n    \"\"\"Perform a risky operation that might fail.\"\"\"\n    try:\n        # Your operation here\n        result = perform_operation(query)\n        return f\"Success: {result}\"\n    except Exception as e:\n        return f\"Error: {str(e)}\"\n\n# Agent handles errors gracefully\nagent = create_agent(model=llm, tools=[risky_operation])\n```\n\n### LangSmith observability\n\n```python\nimport os\n\n# Enable tracing\nos.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\nos.environ[\"LANGCHAIN_API_KEY\"] = \"your-api-key\"\nos.environ[\"LANGCHAIN_PROJECT\"] = \"my-project\"\n\n# All chains\u002Fagents automatically traced\nagent = create_agent(model=llm, tools=[calculator])\nresult = agent.invoke({\"input\": \"Calculate 123 * 456\"})\n\n# View traces at smith.langchain.com\n```\n\n## Vector stores\n\n### Chroma (local)\n\n```python\nfrom langchain_chroma import Chroma\n\nvectorstore = Chroma.from_documents(\n    documents=docs,\n    embedding=OpenAIEmbeddings(),\n    persist_directory=\".\u002Fchroma_db\"\n)\n```\n\n### Pinecone (cloud)\n\n```python\nfrom langchain_pinecone import PineconeVectorStore\n\nvectorstore = PineconeVectorStore.from_documents(\n    documents=docs,\n    embedding=OpenAIEmbeddings(),\n    index_name=\"my-index\"\n)\n```\n\n### FAISS (similarity search)\n\n```python\nfrom langchain_community.vectorstores import FAISS\n\nvectorstore = FAISS.from_documents(docs, OpenAIEmbeddings())\nvectorstore.save_local(\"faiss_index\")\n\n# Load later\nvectorstore = FAISS.load_local(\"faiss_index\", OpenAIEmbeddings())\n```\n\n## Document loaders\n\n```python\n# Web pages\nfrom langchain_community.document_loaders import WebBaseLoader\nloader = WebBaseLoader(\"https:\u002F\u002Fexample.com\")\n\n# PDFs\nfrom langchain_community.document_loaders import PyPDFLoader\nloader = PyPDFLoader(\"paper.pdf\")\n\n# GitHub\nfrom langchain_community.document_loaders import GithubFileLoader\nloader = GithubFileLoader(repo=\"user\u002Frepo\", file_filter=lambda x: x.endswith(\".py\"))\n\n# CSV\nfrom langchain_community.document_loaders import CSVLoader\nloader = CSVLoader(\"data.csv\")\n```\n\n## Text splitters\n\n```python\n# Recursive (recommended for general text)\nfrom langchain.text_splitter import RecursiveCharacterTextSplitter\nsplitter = RecursiveCharacterTextSplitter(\n    chunk_size=1000,\n    chunk_overlap=200,\n    separators=[\"\\n\\n\", \"\\n\", \" \", \"\"]\n)\n\n# Code-aware\nfrom langchain.text_splitter import PythonCodeTextSplitter\nsplitter = PythonCodeTextSplitter(chunk_size=500)\n\n# Semantic (by meaning)\nfrom langchain_experimental.text_splitter import SemanticChunker\nsplitter = SemanticChunker(OpenAIEmbeddings())\n```\n\n## Best practices\n\n1. **Start simple** - Use `create_agent()` for most cases\n2. **Enable streaming** - Better UX for long responses\n3. **Add error handling** - Tools can fail, handle gracefully\n4. **Use LangSmith** - Essential for debugging agents\n5. **Optimize chunk size** - 500-1000 chars for RAG\n6. **Version prompts** - Track changes in production\n7. **Cache embeddings** - Expensive, cache when possible\n8. **Monitor costs** - Track token usage with LangSmith\n\n## Performance benchmarks\n\n| Operation | Latency | Notes |\n|-----------|---------|-------|\n| Simple LLM call | ~1-2s | Depends on provider |\n| Agent with 1 tool | ~3-5s | ReAct reasoning overhead |\n| RAG retrieval | ~0.5-1s | Vector search + LLM |\n| Embedding 1000 docs | ~10-30s | Depends on model |\n\n## LangChain vs LangGraph\n\n| Feature | LangChain | LangGraph |\n|---------|-----------|-----------|\n| **Best for** | Quick agents, RAG | Complex workflows |\n| **Abstraction level** | High | Low |\n| **Code to start** | \u003C10 lines | ~30 lines |\n| **Control** | Simple | Full control |\n| **Stateful workflows** | Limited | Native |\n| **Cyclic graphs** | No | Yes |\n| **Human-in-loop** | Basic | Advanced |\n\n**Use LangGraph when:**\n- Need stateful workflows with cycles\n- Require fine-grained control\n- Building multi-agent systems\n- Production apps with complex logic\n\n## References\n\n- **[Agents Guide](references\u002Fagents.md)** - ReAct, tool calling, streaming\n- **[RAG Guide](references\u002Frag.md)** - Document loaders, retrievers, QA chains\n- **[Integration Guide](references\u002Fintegration.md)** - Vector stores, LangSmith, deployment\n\n## Resources\n\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Flangchain-ai\u002Flangchain ⭐ 119,000+\n- **Docs**: https:\u002F\u002Fdocs.langchain.com\n- **API Reference**: https:\u002F\u002Freference.langchain.com\u002Fpython\n- **LangSmith**: https:\u002F\u002Fsmith.langchain.com (observability)\n- **Version**: 0.3+ (stable)\n- **License**: MIT\n\n## Agent operating procedure\n\n1. **Check the environment.** Confirm the framework version, model provider, API keys and rate limits.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Test a single call or chain with a known input and inspect raw outputs.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Evaluate on a small labeled set; check structured outputs against their schema; log prompts and responses.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| Outputs do not match the expected schema | Add validation and retries, tighten the schema, or simplify the prompt. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Never send private or sensitive data to external APIs without the user's consent.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n\n## Related skills\n\n- `llamaindex`: Data framework for building LLM applications with RAG.\n- `autogpt-agents`: Autonomous AI agent platform for building and deploying continuous agents.\n- `chroma`: Open-source embedding database for AI applications.\n","# LangChain - Build LLM Applications with Agents & RAG\n\nThe most popular framework for building LLM-powered applications.\n\n## When to use LangChain\n\n**Use LangChain when:**\n- Building agents with tool calling and reasoning (ReAct pattern)\n- Implementing RAG (retrieval-augmented generation) pipelines\n- Need to swap LLM providers easily (OpenAI, Anthropic, Google)\n- Creating chatbots with conversation memory\n- Rapid prototyping of LLM applications\n- Production deployments with LangSmith observability\n\n**Metrics**:\n- **272,000+ repositories** use LangChain\n- **500+ integrations** (models, vector stores, tools)\n- **3,800+ contributors**\n\n**Use alternatives instead**:\n- **LlamaIndex**: RAG-focused, better for document Q&A\n- **LangGraph**: Complex stateful workflows, more control\n- **Haystack**: Production search pipelines\n- **Semantic Kernel**: Microsoft ecosystem\n\n## Quick start\n\n### Installation\n\n```bash\n# Core library (Python 3.10+)\npip install -U langchain\n\n# With OpenAI\npip install langchain-openai\n\n# With Anthropic\npip install langchain-anthropic\n\n# Common extras\npip install langchain-community  # 500+ integrations\npip install langchain-chroma     # Vector store\n```\n\n### Basic LLM usage\n\n```python\nfrom langchain_anthropic import ChatAnthropic\n\n# Initialize model\nllm = ChatAnthropic(model=\"claude-sonnet-4-5-20250929\")\n\n# Simple completion\nresponse = llm.invoke(\"Explain quantum computing in 2 sentences\")\nprint(response.content)\n```\n\n### Create an agent (ReAct pattern)\n\n```python\nfrom langchain.agents import create_agent\nfrom langchain_anthropic import ChatAnthropic\n\n# Define tools\ndef get_weather(city: str) -> str:\n    \"\"\"Get current weather for a city.\"\"\"\n    return f\"It's sunny in {city}, 72°F\"\n\ndef search_web(query: str) -> str:\n    \"\"\"Search the web for information.\"\"\"\n    return f\"Search results for: {query}\"\n\n# Create agent (\u003C10 lines!)\nagent = create_agent(\n    model=ChatAnthropic(model=\"claude-sonnet-4-5-20250929\"),\n    tools=[get_weather, search_web],\n    system_prompt=\"You are a helpful assistant. Use tools when needed.\"\n)\n\n# Run agent\nresult = agent.invoke({\"messages\": [{\"role\": \"user\", \"content\": \"What's the weather in Paris?\"}]})\nprint(result[\"messages\"][-1].content)\n```\n\n## Core concepts\n\n### 1. Models - LLM abstraction\n\n```python\nfrom langchain_openai import ChatOpenAI\nfrom langchain_anthropic import ChatAnthropic\nfrom langchain_google_genai import ChatGoogleGenerativeAI\n\n# Swap providers easily\nllm = ChatOpenAI(model=\"gpt-4o\")\nllm = ChatAnthropic(model=\"claude-sonnet-4-5-20250929\")\nllm = ChatGoogleGenerativeAI(model=\"gemini-2.0-flash-exp\")\n\n# Streaming\nfor chunk in llm.stream(\"Write a poem\"):\n    print(chunk.content, end=\"\", flush=True)\n```\n\n### 2. Chains - Sequential operations\n\n```python\nfrom langchain.chains import LLMChain\nfrom langchain.prompts import PromptTemplate\n\n# Define prompt template\nprompt = PromptTemplate(\n    input_variables=[\"topic\"],\n    template=\"Write a 3-sentence summary about {topic}\"\n)\n\n# Create chain\nchain = LLMChain(llm=llm, prompt=prompt)\n\n# Run chain\nresult = chain.run(topic=\"machine learning\")\n```\n\n### 3. Agents - Tool-using reasoning\n\n**ReAct (Reasoning + Acting) pattern:**\n\n```python\nfrom langchain.agents import create_tool_calling_agent, AgentExecutor\nfrom langchain.tools import Tool\nfrom scripts.safe_arithmetic import calculate\n\n# Define custom tool\ncalculator = Tool(\n    name=\"Calculator\",\n    func=lambda x: str(calculate(x)),\n    description=\"Useful for arithmetic with numbers and +, -, *, \u002F.\"\n)\n\n# Create agent with tools\nagent = create_tool_calling_agent(\n    llm=llm,\n    tools=[calculator, search_web],\n    prompt=\"Answer questions using available tools\"\n)\n\n# Create executor\nagent_executor = AgentExecutor(agent=agent, tools=[calculator], verbose=True)\n\n# Run with reasoning\nresult = agent_executor.invoke({\"input\": \"What is 25 * 17 + 142?\"})\n```\n\n### 4. Memory - Conversation history\n\n```python\nfrom langchain.memory import ConversationBufferMemory\nfrom langchain.chains import ConversationChain\n\n# Add memory to track conversation\nmemory = ConversationBufferMemory()\n\nconversation = ConversationChain(\n    llm=llm,\n    memory=memory,\n    verbose=True\n)\n\n# Multi-turn conversation\nconversation.predict(input=\"Hi, I'm Alice\")\nconversation.predict(input=\"What's my name?\")  # Remembers \"Alice\"\n```\n\n## RAG (Retrieval-Augmented Generation)\n\nDetails, code examples and parameter tables: [references\u002Frag-retrieval-augmented-generation.md](references\u002Frag-retrieval-augmented-generation.md). Read it when this step applies.\n\n## Advanced agent patterns\n\n### Structured output\n\n```python\nfrom langchain_core.pydantic_v1 import BaseModel, Field\n\n# Define schema\nclass WeatherReport(BaseModel):\n    city: str = Field(description=\"City name\")\n    temperature: float = Field(description=\"Temperature in Fahrenheit\")\n    condition: str = Field(description=\"Weather condition\")\n\n# Get structured response\nstructured_llm = llm.with_structured_output(WeatherReport)\nresult = structured_llm.invoke(\"What's the weather in SF? It's 65F and sunny\")\nprint(result.city, result.temperature, result.condition)\n```\n\n### Parallel tool execution\n\n```python\nfrom langchain.agents import create_tool_calling_agent\n\n# Agent automatically parallelizes independent tool calls\nagent = create_tool_calling_agent(\n    llm=llm,\n    tools=[get_weather, search_web, calculator]\n)\n\n# This will call get_weather(\"Paris\") and get_weather(\"London\") in parallel\nresult = agent.invoke({\n    \"messages\": [{\"role\": \"user\", \"content\": \"Compare weather in Paris and London\"}]\n})\n```\n\n### Streaming agent execution\n\n```python\n# Stream agent steps\nfor step in agent_executor.stream({\"input\": \"Research AI trends\"}):\n    if \"actions\" in step:\n        print(f\"Tool: {step['actions'][0].tool}\")\n    if \"output\" in step:\n        print(f\"Output: {step['output']}\")\n```\n\n## Common patterns\n\n### Multi-document QA\n\n```python\nfrom langchain.chains.qa_with_sources import load_qa_with_sources_chain\n\n# Load multiple documents\ndocs = [\n    loader.load(\"https:\u002F\u002Fdocs.python.org\"),\n    loader.load(\"https:\u002F\u002Fdocs.numpy.org\")\n]\n\n# QA with source citations\nchain = load_qa_with_sources_chain(llm, chain_type=\"stuff\")\nresult = chain({\"input_documents\": docs, \"question\": \"How to use numpy arrays?\"})\nprint(result[\"output_text\"])  # Includes source citations\n```\n\n### Custom tools with error handling\n\n```python\nfrom langchain.tools import tool\n\n@tool\ndef risky_operation(query: str) -> str:\n    \"\"\"Perform a risky operation that might fail.\"\"\"\n    try:\n        # Your operation here\n        result = perform_operation(query)\n        return f\"Success: {result}\"\n    except Exception as e:\n        return f\"Error: {str(e)}\"\n\n# Agent handles errors gracefully\nagent = create_agent(model=llm, tools=[risky_operation])\n```\n\n### LangSmith observability\n\n```python\nimport os\n\n# Enable tracing\nos.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\nos.environ[\"LANGCHAIN_API_KEY\"] = \"your-api-key\"\nos.environ[\"LANGCHAIN_PROJECT\"] = \"my-project\"\n\n# All chains\u002Fagents automatically traced\nagent = create_agent(model=llm, tools=[calculator])\nresult = agent.invoke({\"input\": \"Calculate 123 * 456\"})\n\n# View traces at smith.langchain.com\n```\n\n## Vector stores\n\n### Chroma (local)\n\n```python\nfrom langchain_chroma import Chroma\n\nvectorstore = Chroma.from_documents(\n    documents=docs,\n    embedding=OpenAIEmbeddings(),\n    persist_directory=\".\u002Fchroma_db\"\n)\n```\n\n### Pinecone (cloud)\n\n```python\nfrom langchain_pinecone import PineconeVectorStore\n\nvectorstore = PineconeVectorStore.from_documents(\n    documents=docs,\n    embedding=OpenAIEmbeddings(),\n    index_name=\"my-index\"\n)\n```\n\n### FAISS (similarity search)\n\n```python\nfrom langchain_community.vectorstores import FAISS\n\nvectorstore = FAISS.from_documents(docs, OpenAIEmbeddings())\nvectorstore.save_local(\"faiss_index\")\n\n# Load later\nvectorstore = FAISS.load_local(\"faiss_index\", OpenAIEmbeddings())\n```\n\n## Document loaders\n\n```python\n# Web pages\nfrom langchain_community.document_loaders import WebBaseLoader\nloader = WebBaseLoader(\"https:\u002F\u002Fexample.com\")\n\n# PDFs\nfrom langchain_community.document_loaders import PyPDFLoader\nloader = PyPDFLoader(\"paper.pdf\")\n\n# GitHub\nfrom langchain_community.document_loaders import GithubFileLoader\nloader = GithubFileLoader(repo=\"user\u002Frepo\", file_filter=lambda x: x.endswith(\".py\"))\n\n# CSV\nfrom langchain_community.document_loaders import CSVLoader\nloader = CSVLoader(\"data.csv\")\n```\n\n## Text splitters\n\n```python\n# Recursive (recommended for general text)\nfrom langchain.text_splitter import RecursiveCharacterTextSplitter\nsplitter = RecursiveCharacterTextSplitter(\n    chunk_size=1000,\n    chunk_overlap=200,\n    separators=[\"\\n\\n\", \"\\n\", \" \", \"\"]\n)\n\n# Code-aware\nfrom langchain.text_splitter import PythonCodeTextSplitter\nsplitter = PythonCodeTextSplitter(chunk_size=500)\n\n# Semantic (by meaning)\nfrom langchain_experimental.text_splitter import SemanticChunker\nsplitter = SemanticChunker(OpenAIEmbeddings())\n```\n\n## Best practices\n\n1. **Start simple** - Use `create_agent()` for most cases\n2. **Enable streaming** - Better UX for long responses\n3. **Add error handling** - Tools can fail, handle gracefully\n4. **Use LangSmith** - Essential for debugging agents\n5. **Optimize chunk size** - 500-1000 chars for RAG\n6. **Version prompts** - Track changes in production\n7. **Cache embeddings** - Expensive, cache when possible\n8. **Monitor costs** - Track token usage with LangSmith\n\n## Performance benchmarks\n\n| Operation | Latency | Notes |\n|-----------|---------|-------|\n| Simple LLM call | ~1-2s | Depends on provider |\n| Agent with 1 tool | ~3-5s | ReAct reasoning overhead |\n| RAG retrieval | ~0.5-1s | Vector search + LLM |\n| Embedding 1000 docs | ~10-30s | Depends on model |\n\n## LangChain vs LangGraph\n\n| Feature | LangChain | LangGraph |\n|---------|-----------|-----------|\n| **Best for** | Quick agents, RAG | Complex workflows |\n| **Abstraction level** | High | Low |\n| **Code to start** | \u003C10 lines | ~30 lines |\n| **Control** | Simple | Full control |\n| **Stateful workflows** | Limited | Native |\n| **Cyclic graphs** | No | Yes |\n| **Human-in-loop** | Basic | Advanced |\n\n**Use LangGraph when:**\n- Need stateful workflows with cycles\n- Require fine-grained control\n- Building multi-agent systems\n- Production apps with complex logic\n\n## References\n\n- **[Agents Guide](references\u002Fagents.md)** - ReAct, tool calling, streaming\n- **[RAG Guide](references\u002Frag.md)** - Document loaders, retrievers, QA chains\n- **[Integration Guide](references\u002Fintegration.md)** - Vector stores, LangSmith, deployment\n\n## Resources\n\n- **GitHub**: https:\u002F\u002Fgithub.com\u002Flangchain-ai\u002Flangchain ⭐ 119,000+\n- **Docs**: https:\u002F\u002Fdocs.langchain.com\n- **API Reference**: https:\u002F\u002Freference.langchain.com\u002Fpython\n- **LangSmith**: https:\u002F\u002Fsmith.langchain.com (observability)\n- **Version**: 0.3+ (stable)\n- **License**: MIT\n\n## Agent operating procedure\n\n1. **Check the environment.** Confirm the framework version, model provider, API keys and rate limits.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Test a single call or chain with a known input and inspect raw outputs.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Evaluate on a small labeled set; check structured outputs against their schema; log prompts and responses.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| Outputs do not match the expected schema | Add validation and retries, tighten the schema, or simplify the prompt. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Never send private or sensitive data to external APIs without the user's consent.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n\n## Related skills\n\n- `llamaindex`: Data framework for building LLM applications with RAG.\n- `autogpt-agents`: Autonomous AI agent platform for building and deploying continuous agents.\n- `chroma`: Open-source embedding database for AI applications.\n",{"name":5,"license":15,"metadata":24,"description":7},{"tags":25,"version":26,"category":27,"maintainer":28,"dependencies":29},"Agents, LangChain, RAG, Tool Calling, ReAct, Memory Management, Vector Stores, LLM Applications, Chatbots, Production","1.0.0","llm-applications","Kalaris Labs","langchain, langchain-core, langchain-openai, langchain-anthropic","main","29fe36d26127205057d5e0ed8425f6b0e9a8c13a","skills\u002Flangchain",16,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills","https:\u002F\u002Fdocs.kalarislabs.com\u002Fresearch-agent-skills","https:\u002F\u002Fgithub.com\u002FKalarisLabs","kalarislabs.com","Applied AI lab building the infrastructure for the agentic era","2026-11-14 17:49:08",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add KalarisLabs\u002Fresearch-agent-skills --skill langchain",{"tool":46,"command":47},"bunx","bunx skills add KalarisLabs\u002Fresearch-agent-skills --skill langchain",{"tool":49,"command":50},"pnpm","pnpm dlx skills add KalarisLabs\u002Fresearch-agent-skills --skill langchain","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Flangchain\u002FSKILL.md",true,[54,60,64,68,72],{"path":55,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":58,"sourceHtmlUrl":59},"references\u002Fagents.md","REFERENCE","参考文档",12712,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Flangchain\u002Freferences\u002Fagents.md",{"path":61,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":62,"sourceHtmlUrl":63},"references\u002Fintegration.md",11832,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Flangchain\u002Freferences\u002Fintegration.md",{"path":65,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Frag-retrieval-augmented-generation.md",1569,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Flangchain\u002Freferences\u002Frag-retrieval-augmented-generation.md",{"path":69,"resourceType":56,"resourceTypeDesc":57,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Frag.md",14490,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Flangchain\u002Freferences\u002Frag.md",{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"scripts\u002Fsafe_arithmetic.py","SCRIPT","脚本",1343,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Flangchain\u002Fscripts\u002Fsafe_arithmetic.py",[79,86,93,100,107,114],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M74Z8MGT305R11SNY5G28QH5","plos","Prepare manuscripts for PLOS journals (PLOS ONE, PLOS Biology, PLOS Computational Biology, PLOS Genetics, PLOS Medicine, PLOS Pathogens, PLOS Neglected Tropical Diseases, PLOS Global Public Health and others), covering structure, abstract and author summary, Vancouver-style references, the mandatory data availability policy, ethics and financial disclosure statements, figure requirements (PACE), the PLOS LaTeX template, reporting guidelines and PLOS ONE's publication criteria. Use when targeting any PLOS journal or checking compliance with PLOS policies.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fplos\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M74Z8CCN9APXYHNQ95V1EBGT","pkpd-modeling","Pharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK\u002FPD and exposure-response, TMDD, PBPK orientation, bioequivalence, allometric scaling and first-in-human dose, drug interaction prediction, and Bayesian therapeutic drug monitoring. Use when analysing concentration-time data, deriving exposure metrics, fitting PK or PD models, or evaluating dosing regimens. Triggers include \"pharmacokinetics\", \"pharmacodynamics\", \"PK\u002FPD\", \"NCA\", \"non-compartmental\", \"AUC\", \"Cmax\", \"lambda z\", \"half-life\", \"clearance\", \"volume of distribution\", \"compartmental model\", \"population PK\", \"popPK\", \"NONMEM\", \"nlmixr2\", \"Pharmpy\", \"Monolix\", \"exposure-response\", \"Emax\", \"EC50\", \"indirect response\", \"effect compartment\", \"TMDD\", \"PBPK\", \"bioequivalence\", \"RSABE\", \"ABEL\", \"allometric scaling\", \"first-in-human\", \"MABEL\", \"drug-drug interaction\", \"DDI\", \"ICH M12\", \"concentration-QTc\", \"therapeutic drug monitoring\", \"MIPD\", and \"dosing regimen\".","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpkpd-modeling\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M74Z86YHJJ1FM3X87BHN76KZ","pinecone","Guides use of Pinecone, a managed serverless vector database, through its Python client and the LangChain and LlamaIndex integrations. Covers creating indexes, upserting and querying vectors, metadata filtering, namespaces, hybrid dense and sparse search, index management, and deleting vectors. Use when building a production RAG system on a hosted vector store, adding semantic search or recommendations without running infrastructure, isolating per-user or per-tenant data with namespaces, combining dense and sparse vectors in one query, or filtering results by metadata. Do not use for self-hosted or local stores (Chroma, Weaviate) or offline similarity search (FAISS).","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpinecone\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":19},"01M74Z80T6E89SAJ8MYDD0767Q","pi-agent","Build with and use Pi, the minimal terminal coding harness. Use for installing Pi, configuring providers\u002Fmodels\u002Fsettings\u002Fenvironment variables, creating Pi skills\u002Fextensions\u002Fpackages\u002Fthemes\u002Fprompt templates, embedding Pi through the SDK, integrating over RPC or JSON event streams, parsing sessions, running local models through the llama.cpp router, developing custom Pi providers and TUI components, or using ecosystem packages such as pi-subagents (delegation\u002Forchestration), pi-mcp-adapter (MCP servers), pi-interview (interactive forms), and pi-web-access (web search, fetching, video understanding).","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpi-agent\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":19},"01M74Z7WF1Y8Q3VFAQPPPRAFMV","phoenix-observability","Open-source AI observability platform for LLM tracing, evaluation, and monitoring. Use when debugging LLM applications with detailed traces, running evaluations on datasets, or monitoring production AI systems with real-time insights.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fphoenix-observability\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":19},"01M74Z7HNEH1A2AVYR3G1X2QV6","peft-fine-tuning","Fine-tunes LLMs with Hugging Face PEFT, using LoRA, QLoRA, IA3, AdaLoRA, prefix tuning, and prompt tuning so that under 1% of parameters are trained. Covers rank, alpha, and target module selection, loading and merging adapters, multi-adapter serving, and integration with TRL SFTTrainer, Axolotl, and vLLM. Use when fine-tuning 7B-70B models on limited GPU memory, when running QLoRA on a single 24GB GPU, when choosing LoRA rank and alpha, when merging or swapping adapters on one base model, or when debugging CUDA OOM or an adapter that does not apply. Not for full fine-tuning of small models under 1B parameters or cases needing all weights updated.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpeft-fine-tuning\u002FSKILL.md",[],[]]