@stratix/ai-anthropic 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -125
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -1,151 +1,86 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/stratix-dev/stratix/main/public/logo-no-bg.png" alt="Stratix Logo" width="200"/>
|
|
3
|
+
|
|
1
4
|
# @stratix/ai-anthropic
|
|
2
5
|
|
|
3
|
-
Anthropic Claude LLM provider for Stratix AI agents
|
|
6
|
+
**Anthropic Claude LLM provider for Stratix AI agents**
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
[](https://www.npmjs.com/package/@stratix/ai-anthropic)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
pnpm add @stratix/ai-anthropic
|
|
9
|
-
```
|
|
11
|
+
[Documentation](https://stratix-dev.github.io/stratix/) | [Getting Started](https://stratix-dev.github.io/stratix/docs/getting-started/quick-start)
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- Support for Claude 3 Opus, Sonnet, Haiku, and Claude 3.5 Sonnet
|
|
14
|
-
- Tool use (function calling) support
|
|
15
|
-
- Streaming responses
|
|
16
|
-
- Automatic cost calculation based on token usage
|
|
17
|
-
- System message support
|
|
18
|
-
- Proper message role handling (system messages separated from conversation)
|
|
19
|
-
|
|
20
|
-
## Supported Models
|
|
21
|
-
|
|
22
|
-
- `claude-3-5-sonnet-20241022` - Latest Claude 3.5 Sonnet (most capable)
|
|
23
|
-
- `claude-3-opus-20240229` - Claude 3 Opus (highest intelligence)
|
|
24
|
-
- `claude-3-sonnet-20240229` - Claude 3 Sonnet (balanced performance)
|
|
25
|
-
- `claude-3-haiku-20240307` - Claude 3 Haiku (fastest and most cost-effective)
|
|
26
|
-
|
|
27
|
-
## Quick Example
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import { AnthropicProvider } from '@stratix/ai-anthropic';
|
|
31
|
-
|
|
32
|
-
const provider = new AnthropicProvider({
|
|
33
|
-
apiKey: process.env.ANTHROPIC_API_KEY!,
|
|
34
|
-
baseURL: 'https://api.anthropic.com', // Optional
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Chat completion
|
|
38
|
-
const response = await provider.chat({
|
|
39
|
-
model: 'claude-3-5-sonnet-20241022',
|
|
40
|
-
messages: [
|
|
41
|
-
{ role: 'system', content: 'You are a helpful assistant.', timestamp: new Date() },
|
|
42
|
-
{ role: 'user', content: 'Hello!', timestamp: new Date() }
|
|
43
|
-
],
|
|
44
|
-
temperature: 0.7,
|
|
45
|
-
maxTokens: 1024
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
console.log(response.content);
|
|
49
|
-
console.log('Cost:', provider.calculateCost('claude-3-5-sonnet-20241022', response.usage));
|
|
50
|
-
|
|
51
|
-
// Streaming chat
|
|
52
|
-
for await (const chunk of provider.streamChat({
|
|
53
|
-
model: 'claude-3-5-sonnet-20241022',
|
|
54
|
-
messages: [
|
|
55
|
-
{ role: 'user', content: 'Tell me a story', timestamp: new Date() }
|
|
56
|
-
]
|
|
57
|
-
})) {
|
|
58
|
-
process.stdout.write(chunk.content);
|
|
59
|
-
if (chunk.isComplete) {
|
|
60
|
-
console.log('\nStream completed');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
```
|
|
13
|
+
</div>
|
|
64
14
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
const response = await provider.chat({
|
|
69
|
-
model: 'claude-3-5-sonnet-20241022',
|
|
70
|
-
messages: [
|
|
71
|
-
{ role: 'user', content: 'What is the weather in NYC?', timestamp: new Date() }
|
|
72
|
-
],
|
|
73
|
-
tools: [
|
|
74
|
-
{
|
|
75
|
-
name: 'get_weather',
|
|
76
|
-
description: 'Get the current weather in a location',
|
|
77
|
-
parameters: {
|
|
78
|
-
type: 'object',
|
|
79
|
-
properties: {
|
|
80
|
-
location: { type: 'string', description: 'The city name' }
|
|
81
|
-
},
|
|
82
|
-
required: ['location']
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (response.toolCalls) {
|
|
89
|
-
console.log('Tool call:', response.toolCalls[0].name);
|
|
90
|
-
console.log('Arguments:', response.toolCalls[0].arguments);
|
|
91
|
-
}
|
|
92
|
-
```
|
|
15
|
+
-
|
|
93
16
|
|
|
94
|
-
|
|
17
|
+
> Part of **[Stratix Framework](https://stratix-dev.github.io/stratix/)** - A TypeScript framework for building scalable applications with Domain-Driven Design, Hexagonal Architecture, and CQRS patterns.
|
|
18
|
+
>
|
|
19
|
+
> **New to Stratix?** Start with the [Getting Started Guide](https://stratix-dev.github.io/stratix/docs/getting-started/quick-start)
|
|
95
20
|
|
|
96
|
-
|
|
21
|
+
-
|
|
97
22
|
|
|
98
|
-
|
|
99
|
-
const response = await provider.chat({
|
|
100
|
-
model: 'claude-3-5-sonnet-20241022',
|
|
101
|
-
messages: [
|
|
102
|
-
{ role: 'system', content: 'You are an expert in TypeScript.', timestamp: new Date() },
|
|
103
|
-
{ role: 'system', content: 'Always provide code examples.', timestamp: new Date() },
|
|
104
|
-
{ role: 'user', content: 'How do I create a class?', timestamp: new Date() }
|
|
105
|
-
]
|
|
106
|
-
});
|
|
23
|
+
## About This Package
|
|
107
24
|
|
|
108
|
-
|
|
109
|
-
```
|
|
25
|
+
`@stratix/ai-anthropic` is a AI provider plugin for the Stratix framework.
|
|
110
26
|
|
|
111
|
-
|
|
27
|
+
Anthropic Claude LLM provider for Stratix AI agents
|
|
112
28
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
29
|
+
## About Stratix
|
|
30
|
+
|
|
31
|
+
Stratix is an AI-first TypeScript framework combining Domain-Driven Design, Hexagonal Architecture, and CQRS. It provides production-ready patterns for building scalable, maintainable applications with AI agents as first-class citizens.
|
|
32
|
+
|
|
33
|
+
**Key Resources:**
|
|
34
|
+
- [Documentation](https://stratix-dev.github.io/stratix/)
|
|
35
|
+
- [Quick Start](https://stratix-dev.github.io/stratix/docs/getting-started/quick-start)
|
|
36
|
+
- [Report Issues](https://github.com/stratix-dev/stratix/issues)
|
|
119
37
|
|
|
120
|
-
##
|
|
38
|
+
## Installation
|
|
121
39
|
|
|
122
|
-
|
|
40
|
+
**Prerequisites:**
|
|
41
|
+
- Node.js 18.0.0 or higher
|
|
42
|
+
- `@stratix/core` and `@stratix/runtime` installed
|
|
43
|
+
- Basic understanding of [Stratix architecture](https://stratix-dev.github.io/stratix/docs/core-concepts/architecture-overview)
|
|
123
44
|
|
|
124
|
-
|
|
125
|
-
|
|
45
|
+
**Recommended:** Use the Stratix CLI
|
|
46
|
+
```bash
|
|
47
|
+
stratix add anthropic
|
|
48
|
+
```
|
|
126
49
|
|
|
127
|
-
|
|
128
|
-
|
|
50
|
+
**Manual installation:**
|
|
51
|
+
```bash
|
|
52
|
+
npm install @stratix/ai-anthropic
|
|
129
53
|
```
|
|
130
54
|
|
|
131
|
-
|
|
55
|
+
## Related Packages
|
|
132
56
|
|
|
133
|
-
|
|
57
|
+
**Essential:**
|
|
58
|
+
- [`@stratix/core`](https://www.npmjs.com/package/@stratix/core) - Core primitives and abstractions
|
|
59
|
+
- [`@stratix/runtime`](https://www.npmjs.com/package/@stratix/runtime) - Application runtime and plugin system
|
|
60
|
+
- [`@stratix/cli`](https://www.npmjs.com/package/@stratix/cli) - Code generation and scaffolding
|
|
134
61
|
|
|
135
|
-
|
|
62
|
+
[View all plugins](https://stratix-dev.github.io/stratix/docs/plugins/official-plugins)
|
|
136
63
|
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
await provider.embeddings({...});
|
|
140
|
-
} catch (error) {
|
|
141
|
-
console.error('Anthropic does not support embeddings');
|
|
142
|
-
}
|
|
143
|
-
```
|
|
64
|
+
## Documentation
|
|
144
65
|
|
|
145
|
-
|
|
66
|
+
- [Getting Started](https://stratix-dev.github.io/stratix/docs/getting-started/quick-start)
|
|
67
|
+
- [Core Concepts](https://stratix-dev.github.io/stratix/docs/core-concepts/architecture-overview)
|
|
68
|
+
- [Plugin Architecture](https://stratix-dev.github.io/stratix/docs/plugins/plugin-architecture)
|
|
69
|
+
- [Complete Documentation](https://stratix-dev.github.io/stratix/)
|
|
146
70
|
|
|
147
|
-
|
|
71
|
+
## Support
|
|
72
|
+
|
|
73
|
+
- [GitHub Issues](https://github.com/stratix-dev/stratix/issues) - Report bugs and request features
|
|
74
|
+
- [Documentation](https://stratix-dev.github.io/stratix/) - Comprehensive guides and tutorials
|
|
148
75
|
|
|
149
76
|
## License
|
|
150
77
|
|
|
151
|
-
MIT
|
|
78
|
+
MIT - See [LICENSE](https://github.com/stratix-dev/stratix/blob/main/LICENSE) for details.
|
|
79
|
+
|
|
80
|
+
-
|
|
81
|
+
|
|
82
|
+
<div align="center">
|
|
83
|
+
|
|
84
|
+
**[Stratix Framework](https://stratix-dev.github.io/stratix/)** - Build better software with proven patterns
|
|
85
|
+
|
|
86
|
+
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratix/ai-anthropic",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Stratix AI Agents - Anthropic Provider",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,6 +11,14 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"lint": "eslint src --ignore-pattern '**/*.test.ts' --ignore-pattern '**/__tests__/**'",
|
|
20
|
+
"clean": "rm -rf dist"
|
|
21
|
+
},
|
|
14
22
|
"files": [
|
|
15
23
|
"dist"
|
|
16
24
|
],
|
|
@@ -31,7 +39,7 @@
|
|
|
31
39
|
},
|
|
32
40
|
"dependencies": {
|
|
33
41
|
"@anthropic-ai/sdk": "^0.35.0",
|
|
34
|
-
"@stratix/core": "
|
|
42
|
+
"@stratix/core": "workspace:*"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
45
|
"@types/node": "^20.0.0",
|
|
@@ -44,19 +52,11 @@
|
|
|
44
52
|
"url": "https://github.com/stratix-dev/stratix.git",
|
|
45
53
|
"directory": "packages/plugins/ai/anthropic"
|
|
46
54
|
},
|
|
47
|
-
"homepage": "https://github.
|
|
55
|
+
"homepage": "https://stratix-dev.github.io/stratix/",
|
|
48
56
|
"bugs": {
|
|
49
57
|
"url": "https://github.com/stratix-dev/stratix/issues"
|
|
50
58
|
},
|
|
51
59
|
"engines": {
|
|
52
60
|
"node": ">=18.0.0"
|
|
53
|
-
},
|
|
54
|
-
"scripts": {
|
|
55
|
-
"build": "tsc",
|
|
56
|
-
"test": "vitest run",
|
|
57
|
-
"test:watch": "vitest",
|
|
58
|
-
"typecheck": "tsc --noEmit",
|
|
59
|
-
"lint": "eslint src --ignore-pattern '**/*.test.ts' --ignore-pattern '**/__tests__/**'",
|
|
60
|
-
"clean": "rm -rf dist"
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
}
|