AI Coding Agent using LangChain with SQLite checkpoint - React project generation and management
npm install @cloudbase/agent-examples-langchain-ai-codingA LangChain-based AI coding assistant with SQLite persistent conversation history. This example demonstrates how to use LangChain agents with AG-Kit tools and SQLite checkpoint for conversation persistence.
- π€ LangChain Integration - Built on LangChain with AG-Kit tool conversion
- πΎ SQLite Persistence - Conversation history stored in SQLite database
- π§ AG-Kit Tools - Full access to AG-Kit's React coding tools
- π Interactive CLI - Simple command-line interface for testing
- π Memory Management - Persistent conversation state across sessions
- Node.js 18+
- OpenAI API key
1. Install and run:
``bash`
npm install
npm run interactive
Create a .env file with:
`bash`OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key
OPENAI_MODEL=gpt-4o-mini
OPENAI_BASE_URL=https://api.openai.com/v1
Start the interactive CLI:
`bash`
npm run interactive
Example conversation:
`
π¬ You: Create a React component for a todo list
π€ Assistant:
I'll help you create a React todo list component. Let me create a new component file...
π¬ You: Add TypeScript support to this component
π€ Assistant:
I'll convert the component to TypeScript with proper type definitions...
`
`typescript
import { createAgent } from '@cloudbase/agent-examples-langchain-ai-coding';
const agent = createAgent({
baseProjectPath: '/path/to/projects',
projectName: 'my-react-app',
autoInstallDependencies: true,
});
const response = await agent.invoke({
messages: [{ role: 'user', content: 'Create a React component' }]
});
console.log(response.content);
`
This example demonstrates:
1. LangChain Agent Creation - Using the existing agent.ts implementation
2. AG-Kit Tool Integration - Converting AG-Kit tools to LangChain format
3. SQLite Checkpoint - Persistent conversation storage using LangChain's SQLite checkpoint
4. Interactive CLI - Simple readline-based interface for testing
``
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β User Input βββββΆβ LangChain Agent βββββΆβ AG-Kit Tools β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ βββββββββββββββββββ
β SQLite Checkpointβ β React Coding β
ββββββββββββββββββββ βββββββββββββββββββ
`
src/
βββ agent.ts # LangChain agent implementation
βββ index.ts # Main exports
examples/
βββ full-workflow.ts # Interactive CLI example
`
- npm run build - Build the projectnpm run interactive
- - Start interactive CLI
- Verify your API key is correct
- Check you have sufficient credits
- Ensure the model name is supported
The SQLite database (checkpoints.db`) will be created automatically in the project directory when you first run the agent.
This example is part of the AG-Kit project. Please refer to the main project's contributing guidelines.
MIT License - see the main AG-Kit project for details.