This repository contains sample code demonstrating how to use LangChain, LangGraph, and WRITER's Palmyra family of models for building AI-powered applications.
This repository includes the following examples:
-
/financial-assistant– A data analysis agent that combines internal documents with external market data to generate structured research briefs- Ingests internal documents (PDFs, reports, memos) into WRITER's Knowledge Graph for structured retrieval
- Retrieves external market data from SEC filings, financial news feeds, historical stock data, and web sources
- Uses LangGraph to orchestrate a multi-step workflow: knowledge graph retrieval, external data gathering, summarization, and brief generation
- Uses middleware to generate role-specific briefs (e.g., detailed for Junior Analysts, concise for Portfolio Managers) with key drivers, risks, and metrics
- Powered by WRITER's Palmyra X5 model for content generation
-
/article-research-creation– Converts voice dictation notes into publication-ready articles- Analyzes and organizes spoken notes into a structured outline
- Conducts targeted web research from provided URLs
- Generates article sections in parallel using LangGraph and WRITER's Palmyra X5 model
-
/customer-facing-chat-assistant– A customer support agent for handling customer inquiries- Handles customer questions using specialized tools for billing, refunds, products, FAQs, and escalation
- Uses middleware for conversation management, context loading, and personalized responses (automatically detects and saves user preferences)
- Integrates with WRITER's developer documentation MCP client for research capabilities
- Powered by WRITER's Palmyra X5 model with LangChain agents
-
/human-in-the-loop-agent– Demonstrates human-in-the-loop patterns for LangChain agents requiring human approval- Reads customer messages and extracts refund or action requests using specialized tools
- Supports multiple decision flows:
approve,reject, oreditactions - Uses HumanInTheLoopMiddleware to require human approval for sensitive actions
- Maintains conversation memory and state using
InMemorySaverfor context-aware interactions - Powered by WRITER's Palmyra X5 model with LangChain agents
-
/deep-agents– A multi-agent research system for producing comprehensive research reports- Uses an orchestrator agent to coordinate specialized research and critique agents
- Performs web searches, data analysis, and peer-style review of report quality
- Decomposes complex topics into parallel sub-questions via the deepagents framework
- Powered by WRITER's Palmyra X5 model
Ensure you have the following before starting:
- Python 3.11 or higher installed
Follow these steps to set up the project:
-
Clone the repository
git clone https://github.com/writer/langchain-examples.git cd langchain-examples -
Create and activate a virtual environment
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
Copy the
.env.templatefile to a.envfile in the project root with your credentials (if available):cp .env.template .env
WRITER credentials
Required for all examples.
WRITER_API_KEY=your WRITER API key
Note: see WRITER developer documentation for info on how to get your API key.
(optional) LangSmith observability
LANGSMITH_TRACING=true #set to false to disable tracing LANGSMITH_API_KEY=your_langsmith_api_key_here LANGSMITH_PROJECT=langchain-examplesNote: See LangSmith documentation on environment variables for additional configuration options
SEC credentials (for
financial-assistant)Required only for the financial assistant example.
SEC_IDENTITY_EMAIL=your email address
Note: You can find more information on how to set up these credentials in each example's README.
Each example runs independently. Navigate to the example directory and follow the instructions below.
Run the financial assistant:
cd financial-assistant/src
python main.pyRun the article research and creation agent:
cd article-research-creation/src
python main.pyThe generated article will be saved to article-research-creation/src/results/ with a timestamp.
Run the customer-facing chat assistant:
cd customer-facing-chat-assistant/src
python main.pycd human-in-the-loop-agent/src
python main.pyDemonstrates human-in-the-loop patterns for agents requiring human approval before executing critical actions.
Run the deep agents research system:
cd deep-agents
python research_agent.pyWRITER is the full-stack generative AI platform for enterprises. Build and deploy AI apps with a suite of developer tools fully integrated with LLMs, graph-based RAG, AI guardrails, and more. To learn more, visit our website.
If you encounter any issues or have questions, please file an issue on this repository.