agentleFS
thehumanworksthehumanworks/langchain-claude-code/.cursor/rules/index.mdc

langchain-claude-code / rules

Cursor rule1 starsChanged 12 months agoMITView on GitHub

LangChain custom chat model integration project conventions

The file

Files
index.mdc
---
description: LangChain custom chat model integration project conventions
alwaysApply: true
---

# LangChain Custom Chat Model Integration

## Overview

This project creates custom LangChain chat model integrations that wrap proprietary or private LLM APIs while maintaining full compatibility with LangChain and LangGraph ecosystems.

## Core Architecture

✓ Inherit from `BaseChatModel` for full LangChain compatibility
✓ Use Pydantic for configuration and validation
✓ Implement async-first with sync fallbacks
✓ Support callbacks for observability and tracing

### Required Imports

```python
from langchain_core.language_models import BaseChatModel
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage, SystemMessage, ToolMessage
from langchain_core.outputs import ChatGeneration, ChatResult
from langchain_core.callbacks import CallbackManagerForLLMRun, AsyncCallbackManagerForLLMRun
```

## Implementation Checklist

✓ Implement `_generate()` method (required)
✓ Define `_llm_type` property (required)
✓ Implement `_agenerate()` for native async
✓ Implement `_stream()` for streaming support
✓ Implement `bind_tools()` for tool calling

## See Also

- [Custom Chat Model](mdc:langchain/custom-chat-model.mdc)
- [Tool Calling](mdc:langchain/tool-calling.mdc)
- [Streaming](mdc:langchain/streaming.mdc)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.