Skip to content

Commit 6ba5039

Browse files
authored
Merge pull request #11 from lippytm/copilot/add-ai-tools-stack
2 parents 1826c72 + 4ac41a4 commit 6ba5039

5 files changed

Lines changed: 270 additions & 9 deletions

File tree

.env.example

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@ TELEMETRY_ENABLED=false
1616
AI_ENABLED=false
1717
# AI_MODEL_NAME=gpt2
1818

19+
# Claude AI Configuration (Optional - requires @anthropic-ai/sdk)
20+
# Set CLAUDE_ENABLED=true to enable Claude AI features
21+
CLAUDE_ENABLED=false
22+
# CLAUDE_API_KEY=your-anthropic-api-key
23+
# CLAUDE_MODEL=claude-3-opus-20240229
24+
# CLAUDE_MAX_TOKENS=4096
25+
# CLAUDE_TEMPERATURE=1.0
26+
27+
# LangChain Configuration (Optional - requires langchain and @langchain/anthropic)
28+
# Set LANGCHAIN_ENABLED=true to enable LangChain integration
29+
LANGCHAIN_ENABLED=false
30+
# LANGCHAIN_TRACING_V2=true
31+
# LANGCHAIN_API_KEY=your-langchain-api-key
32+
# LANGCHAIN_PROJECT=your-project-name
33+
34+
# Multi-AI Provider Configuration (Optional)
35+
# Additional AI providers for multi-model support
36+
# OPENAI_API_KEY=your-openai-api-key
37+
# COHERE_API_KEY=your-cohere-api-key
38+
# For Google AI, install @google/generative-ai separately (peer dependency for ChromaDB)
39+
# GOOGLE_API_KEY=your-google-api-key
40+
1941
# Vector Database Configuration (Optional - requires optional dependencies)
2042
# Set VECTOR_DB_ENABLED=true to enable vector database features
2143
VECTOR_DB_ENABLED=false

README.md

Lines changed: 185 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ The Grand United Fields of Theories
99

1010
## Overview
1111

12-
This project includes comprehensive quality and hardening features:
12+
This project includes comprehensive quality, hardening features, and a full AI Stack:
1313

1414
- **Config Validation**: Type-safe configuration with Zod validation
1515
- **Telemetry**: Optional OpenTelemetry integration (no vendor lock-in)
1616
- **Security Scanning**: Trivy vulnerability scanning and SBOM generation
1717
- **Pre-commit Hooks**: Automatic linting and formatting
1818
- **Dependency Management**: Renovate for automated updates
19+
- **AI Stack**: Comprehensive AI tools and toolkits with Claude, LangChain, and multi-provider support
1920

2021
## Installation
2122

@@ -36,15 +37,188 @@ Heavy AI/ML and vector database dependencies are optional. Install only what you
3637
npm install --include=optional
3738

3839
# Or install specific optional dependencies:
39-
npm install @huggingface/transformers # HuggingFace Transformers
40-
npm install pinecone-client # Pinecone vector database
41-
npm install weaviate-ts-client # Weaviate vector database
42-
npm install chromadb # Chroma vector database
43-
npm install @anchordotdev/anchor # Anchor.dev
40+
npm install @anthropic-ai/sdk # Anthropic Claude AI SDK
41+
npm install langchain @langchain/anthropic # LangChain with Claude integration
42+
npm install openai # OpenAI SDK
43+
npm install cohere-ai # Cohere AI SDK
44+
npm install ai # Vercel AI SDK
45+
npm install @huggingface/transformers # HuggingFace Transformers
46+
npm install pinecone-client # Pinecone vector database
47+
npm install weaviate-ts-client # Weaviate vector database
48+
npm install chromadb # Chroma vector database
49+
npm install @google/generative-ai # Google AI SDK (peer dependency for ChromaDB)
50+
npm install @anchordotdev/anchor # Anchor.dev
4451
```
4552

4653
**Why optional?** These packages are large and not needed for basic functionality. Install only what your use case requires.
4754

55+
## AI Stack
56+
57+
### Full AI Toolkit with Claude
58+
59+
This project includes a comprehensive AI Stack with support for multiple AI providers and toolkits. The stack is designed to be modular and flexible, allowing you to use only the components you need.
60+
61+
**Key Features:**
62+
63+
- **Claude AI Integration**: Full support for Anthropic's Claude models (Opus, Sonnet, Haiku)
64+
- **LangChain Integration**: Build complex AI applications with LangChain and Claude
65+
- **Multi-Provider Support**: OpenAI, Cohere, Google AI, and more
66+
- **Vector Databases**: Pinecone, Weaviate, and ChromaDB support
67+
- **Type-Safe Configuration**: Zod validation for all AI settings
68+
- **Modular Design**: Install only the AI tools you need
69+
70+
### Claude AI Configuration
71+
72+
Claude is Anthropic's family of state-of-the-art AI models. This project supports all Claude models with full configuration options.
73+
74+
**Available Models:**
75+
76+
- `claude-3-opus-20240229` - Most capable model for complex tasks
77+
- `claude-3-sonnet-20240229` - Balanced performance and speed
78+
- `claude-3-haiku-20240307` - Fastest model for simple tasks
79+
80+
**Configuration:**
81+
82+
```bash
83+
# Enable Claude AI
84+
CLAUDE_ENABLED=true
85+
CLAUDE_API_KEY=your-anthropic-api-key
86+
CLAUDE_MODEL=claude-3-opus-20240229
87+
CLAUDE_MAX_TOKENS=4096
88+
CLAUDE_TEMPERATURE=1.0
89+
```
90+
91+
**Usage Example:**
92+
93+
```typescript
94+
import Anthropic from '@anthropic-ai/sdk';
95+
import { loadConfig } from './config';
96+
97+
const config = loadConfig();
98+
99+
if (config.claude?.enabled && config.claude.apiKey) {
100+
const anthropic = new Anthropic({
101+
apiKey: config.claude.apiKey,
102+
});
103+
104+
const message = await anthropic.messages.create({
105+
model: config.claude.model,
106+
max_tokens: config.claude.maxTokens,
107+
temperature: config.claude.temperature,
108+
messages: [
109+
{
110+
role: 'user',
111+
content: 'Hello, Claude!',
112+
},
113+
],
114+
});
115+
116+
console.log(message.content);
117+
}
118+
```
119+
120+
### LangChain Integration
121+
122+
LangChain is a framework for developing applications powered by language models. This project includes LangChain with Claude integration.
123+
124+
**Configuration:**
125+
126+
```bash
127+
# Enable LangChain
128+
LANGCHAIN_ENABLED=true
129+
LANGCHAIN_TRACING_V2=true
130+
LANGCHAIN_API_KEY=your-langchain-api-key
131+
LANGCHAIN_PROJECT=your-project-name
132+
```
133+
134+
**Usage Example:**
135+
136+
```typescript
137+
import { ChatAnthropic } from '@langchain/anthropic';
138+
import { loadConfig } from './config';
139+
140+
const config = loadConfig();
141+
142+
if (config.langchain?.enabled && config.claude?.apiKey) {
143+
const model = new ChatAnthropic({
144+
anthropicApiKey: config.claude.apiKey,
145+
modelName: config.claude.model,
146+
temperature: config.claude.temperature,
147+
});
148+
149+
const response = await model.invoke([
150+
{
151+
role: 'user',
152+
content: 'What is LangChain?',
153+
},
154+
]);
155+
156+
console.log(response.content);
157+
}
158+
```
159+
160+
### Multi-Provider AI Support
161+
162+
The AI Stack supports multiple AI providers for flexibility and fallback options.
163+
164+
**Supported Providers:**
165+
166+
- **Anthropic Claude**: State-of-the-art conversational AI
167+
- **OpenAI**: GPT-4, GPT-3.5, and embeddings
168+
- **Cohere**: Generate, embed, and classify text
169+
- **Google AI**: Gemini models (peer dependency for ChromaDB - install separately if needed)
170+
- **HuggingFace**: Open-source transformers and models
171+
172+
**Configuration:**
173+
174+
```bash
175+
# Multi-provider API keys
176+
OPENAI_API_KEY=your-openai-api-key
177+
COHERE_API_KEY=your-cohere-api-key
178+
# Note: For Google AI, install @google/generative-ai separately (peer dependency for ChromaDB)
179+
# GOOGLE_API_KEY=your-google-api-key
180+
```
181+
182+
### Vector Databases
183+
184+
Vector databases are essential for AI applications that require semantic search and retrieval.
185+
186+
**Supported Vector Databases:**
187+
188+
- **Pinecone**: Managed vector database with high performance
189+
- **Weaviate**: Open-source vector search engine
190+
- **ChromaDB**: AI-native embedding database
191+
192+
**Configuration:**
193+
194+
```bash
195+
VECTOR_DB_ENABLED=true
196+
VECTOR_DB_TYPE=pinecone
197+
VECTOR_DB_API_KEY=your-api-key
198+
VECTOR_DB_ENDPOINT=https://your-instance.vectordb.com
199+
```
200+
201+
### AI Stack Installation
202+
203+
Install the complete AI Stack or individual components:
204+
205+
```bash
206+
# Complete AI Stack
207+
npm install --include=optional
208+
209+
# Claude AI only
210+
npm install @anthropic-ai/sdk
211+
212+
# LangChain with Claude
213+
npm install langchain @langchain/anthropic
214+
215+
# Vector databases
216+
npm install pinecone-client weaviate-ts-client chromadb
217+
218+
# Multi-provider support
219+
npm install openai cohere-ai
220+
```
221+
48222
## Configuration
49223

50224
### Configuration Validation
@@ -58,7 +232,11 @@ The project uses Zod for runtime configuration validation. Configuration is load
58232
- `PORT`: Server port (default: 3000)
59233
- `LOG_LEVEL`: Logging level (debug|info|warn|error, default: info)
60234
- `TELEMETRY_*`: Optional telemetry settings
61-
- `AI_*`: Optional AI/ML settings
235+
- `AI_*`: Optional AI/ML settings (HuggingFace)
236+
- `CLAUDE_*`: Optional Claude AI settings (Anthropic)
237+
- `LANGCHAIN_*`: Optional LangChain settings
238+
- `OPENAI_API_KEY`: Optional OpenAI API key
239+
- `COHERE_API_KEY`: Optional Cohere API key
62240
- `VECTOR_DB_*`: Optional vector database settings
63241

64242
**Example:**

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,18 @@
4141
"zod": "^3.22.0"
4242
},
4343
"optionalDependencies": {
44+
"@anthropic-ai/sdk": "^0.20.0",
4445
"@huggingface/transformers": "^2.6.0",
46+
"langchain": "^0.3.80",
47+
"@langchain/anthropic": "^0.3.0",
48+
"@langchain/community": "^0.3.0",
4549
"pinecone-client": "^1.1.0",
4650
"weaviate-ts-client": "^1.4.0",
4751
"chromadb": "^1.7.0",
48-
"@anchordotdev/anchor": "^0.1.0"
52+
"@anchordotdev/anchor": "^0.1.0",
53+
"openai": "^4.28.0",
54+
"cohere-ai": "^7.7.0",
55+
"ai": "^6.0.49"
4956
},
5057
"lint-staged": {
5158
"*.{ts,js}": [

renovate.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@
1616
{
1717
"description": "Group heavy AI/ML dependencies separately",
1818
"matchPackageNames": [
19+
"@anthropic-ai/sdk",
20+
"langchain",
21+
"@langchain/anthropic",
22+
"@langchain/community",
23+
"openai",
24+
"cohere-ai",
25+
"@google/generative-ai",
26+
"ai",
1927
"@huggingface/transformers",
2028
"pinecone-client",
2129
"weaviate-ts-client",
2230
"chromadb",
2331
"@anchordotdev/anchor"
2432
],
25-
"groupName": "heavy AI/ML dependencies",
33+
"groupName": "AI Stack and ML dependencies",
2634
"schedule": ["before 5am on the first day of the month"]
2735
},
2836
{

src/config/index.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,35 @@ export const ConfigSchema = z.object({
3030
})
3131
.optional(),
3232

33+
// Claude AI configuration (optional)
34+
claude: z
35+
.object({
36+
enabled: z.coerce.boolean().default(false),
37+
apiKey: z.string().optional(),
38+
model: z.string().default('claude-3-opus-20240229'),
39+
maxTokens: z.coerce.number().int().positive().default(4096),
40+
temperature: z.coerce.number().min(0).max(2).default(1.0),
41+
})
42+
.optional(),
43+
44+
// LangChain configuration (optional)
45+
langchain: z
46+
.object({
47+
enabled: z.coerce.boolean().default(false),
48+
tracingV2: z.coerce.boolean().default(false),
49+
apiKey: z.string().optional(),
50+
project: z.string().optional(),
51+
})
52+
.optional(),
53+
54+
// Multi-AI provider configuration (optional)
55+
aiProviders: z
56+
.object({
57+
openaiApiKey: z.string().optional(),
58+
cohereApiKey: z.string().optional(),
59+
})
60+
.optional(),
61+
3362
vectorDb: z
3463
.object({
3564
enabled: z.coerce.boolean().default(false),
@@ -64,6 +93,23 @@ export function loadConfig(): Config {
6493
enabled: process.env.AI_ENABLED,
6594
modelName: process.env.AI_MODEL_NAME,
6695
},
96+
claude: {
97+
enabled: process.env.CLAUDE_ENABLED,
98+
apiKey: process.env.CLAUDE_API_KEY,
99+
model: process.env.CLAUDE_MODEL,
100+
maxTokens: process.env.CLAUDE_MAX_TOKENS,
101+
temperature: process.env.CLAUDE_TEMPERATURE,
102+
},
103+
langchain: {
104+
enabled: process.env.LANGCHAIN_ENABLED,
105+
tracingV2: process.env.LANGCHAIN_TRACING_V2,
106+
apiKey: process.env.LANGCHAIN_API_KEY,
107+
project: process.env.LANGCHAIN_PROJECT,
108+
},
109+
aiProviders: {
110+
openaiApiKey: process.env.OPENAI_API_KEY,
111+
cohereApiKey: process.env.COHERE_API_KEY,
112+
},
67113
vectorDb: {
68114
enabled: process.env.VECTOR_DB_ENABLED,
69115
type: process.env.VECTOR_DB_TYPE,

0 commit comments

Comments
 (0)