@stratix/ai-openai 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.
Files changed (2) hide show
  1. package/README.md +64 -141
  2. package/package.json +12 -12
package/README.md CHANGED
@@ -1,163 +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-openai
2
5
 
3
- OpenAI LLM provider for Stratix AI agents.
6
+ **OpenAI LLM provider for Stratix AI agents**
7
+
8
+ [![npm version](https://img.shields.io/npm/v/@stratix/ai-openai.svg)](https://www.npmjs.com/package/@stratix/ai-openai)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
10
+
11
+ [Documentation](https://stratix-dev.github.io/stratix/) | [Getting Started](https://stratix-dev.github.io/stratix/docs/getting-started/quick-start)
12
+
13
+ </div>
14
+
15
+ -
16
+
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)
20
+
21
+ -
22
+
23
+ ## About This Package
24
+
25
+ `@stratix/ai-openai` is a AI provider plugin for the Stratix framework.
26
+
27
+ OpenAI LLM provider for Stratix AI agents
28
+
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)
4
37
 
5
38
  ## Installation
6
39
 
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)
44
+
45
+ **Recommended:** Use the Stratix CLI
7
46
  ```bash
8
- pnpm add @stratix/ai-openai
47
+ stratix add openai
9
48
  ```
10
49
 
11
- ## Features
12
-
13
- - Support for GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, and GPT-4o models
14
- - Function/tool calling support
15
- - Streaming responses
16
- - Embeddings generation
17
- - Automatic cost calculation based on token usage
18
- - Structured output with JSON schemas
19
- - Response format control (JSON object, JSON schema)
20
-
21
- ## Supported Models
22
-
23
- **Chat Models:**
24
- - `gpt-4o` - Latest GPT-4 optimized model
25
- - `gpt-4o-mini` - Smaller, faster GPT-4o
26
- - `gpt-4` - Base GPT-4 model
27
- - `gpt-4-turbo` - GPT-4 Turbo with improved performance
28
- - `gpt-4-turbo-preview` - Preview version of GPT-4 Turbo
29
- - `gpt-3.5-turbo` - Fast and cost-effective model
30
- - `gpt-3.5-turbo-16k` - Extended context version
31
-
32
- **Embedding Models:**
33
- - `text-embedding-3-small` - Small, efficient embeddings
34
- - `text-embedding-3-large` - High-quality embeddings
35
- - `text-embedding-ada-002` - Legacy embedding model
36
-
37
- ## Quick Example
38
-
39
- ```typescript
40
- import { OpenAIProvider } from '@stratix/ai-openai';
41
-
42
- const provider = new OpenAIProvider({
43
- apiKey: process.env.OPENAI_API_KEY!,
44
- organization: 'org-123', // Optional
45
- });
46
-
47
- // Chat completion
48
- const response = await provider.chat({
49
- model: 'gpt-4o',
50
- messages: [
51
- { role: 'system', content: 'You are a helpful assistant.', timestamp: new Date() },
52
- { role: 'user', content: 'Hello!', timestamp: new Date() }
53
- ],
54
- temperature: 0.7,
55
- maxTokens: 1000
56
- });
57
-
58
- console.log(response.content);
59
- console.log('Cost:', provider.calculateCost('gpt-4o', response.usage));
60
-
61
- // Streaming chat
62
- for await (const chunk of provider.streamChat({
63
- model: 'gpt-4o',
64
- messages: [
65
- { role: 'user', content: 'Tell me a story', timestamp: new Date() }
66
- ]
67
- })) {
68
- process.stdout.write(chunk.content);
69
- }
70
-
71
- // Embeddings
72
- const embeddingsResponse = await provider.embeddings({
73
- model: 'text-embedding-3-small',
74
- input: ['Hello world', 'OpenAI embeddings']
75
- });
76
-
77
- console.log(embeddingsResponse.embeddings.length); // 2
50
+ **Manual installation:**
51
+ ```bash
52
+ npm install @stratix/ai-openai
78
53
  ```
79
54
 
80
- ## Tool/Function Calling
81
-
82
- ```typescript
83
- const response = await provider.chat({
84
- model: 'gpt-4o',
85
- messages: [
86
- { role: 'user', content: 'What is the weather in NYC?', timestamp: new Date() }
87
- ],
88
- tools: [
89
- {
90
- name: 'get_weather',
91
- description: 'Get the current weather in a location',
92
- parameters: {
93
- type: 'object',
94
- properties: {
95
- location: { type: 'string', description: 'The city name' }
96
- },
97
- required: ['location']
98
- }
99
- }
100
- ]
101
- });
102
-
103
- if (response.toolCalls) {
104
- console.log('Tool call:', response.toolCalls[0].name);
105
- console.log('Arguments:', response.toolCalls[0].arguments);
106
- }
107
- ```
55
+ ## Related Packages
108
56
 
109
- ## Structured Output
110
-
111
- ```typescript
112
- const response = await provider.chat({
113
- model: 'gpt-4o',
114
- messages: [
115
- { role: 'user', content: 'Extract user info: John Doe, 30 years old', timestamp: new Date() }
116
- ],
117
- responseFormat: {
118
- type: 'json_schema',
119
- schema: {
120
- type: 'object',
121
- properties: {
122
- name: { type: 'string' },
123
- age: { type: 'number' }
124
- },
125
- required: ['name', 'age']
126
- }
127
- }
128
- });
129
-
130
- const userInfo = JSON.parse(response.content);
131
- console.log(userInfo); // { name: 'John Doe', age: 30 }
132
- ```
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
133
61
 
134
- ## Configuration
62
+ [View all plugins](https://stratix-dev.github.io/stratix/docs/plugins/official-plugins)
135
63
 
136
- ```typescript
137
- interface OpenAIProviderConfig {
138
- apiKey: string; // Required: OpenAI API key
139
- organization?: string; // Optional: OpenAI organization ID
140
- baseURL?: string; // Optional: Custom API base URL
141
- }
142
- ```
64
+ ## Documentation
143
65
 
144
- ## Cost Calculation
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/)
145
70
 
146
- The provider automatically tracks token usage and can calculate costs:
71
+ ## Support
147
72
 
148
- ```typescript
149
- const response = await provider.chat({...});
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
150
75
 
151
- const cost = provider.calculateCost('gpt-4o', response.usage);
152
- console.log(`Cost: $${cost.toFixed(4)}`);
153
- ```
76
+ ## License
154
77
 
155
- Pricing is based on January 2025 rates and included in the provider.
78
+ MIT - See [LICENSE](https://github.com/stratix-dev/stratix/blob/main/LICENSE) for details.
156
79
 
157
- ## Exports
80
+ -
158
81
 
159
- - `OpenAIProvider` - Main provider class implementing `LLMProvider` interface
82
+ <div align="center">
160
83
 
161
- ## License
84
+ **[Stratix Framework](https://stratix-dev.github.io/stratix/)** - Build better software with proven patterns
162
85
 
163
- MIT
86
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stratix/ai-openai",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Stratix AI Agents - OpenAI 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
  ],
@@ -32,7 +40,7 @@
32
40
  },
33
41
  "dependencies": {
34
42
  "openai": "^4.75.0",
35
- "@stratix/core": "0.4.0"
43
+ "@stratix/core": "workspace:*"
36
44
  },
37
45
  "devDependencies": {
38
46
  "@types/node": "^20.0.0",
@@ -45,19 +53,11 @@
45
53
  "url": "https://github.com/stratix-dev/stratix.git",
46
54
  "directory": "packages/plugins/ai/openai"
47
55
  },
48
- "homepage": "https://github.com/stratix-dev/stratix#readme",
56
+ "homepage": "https://stratix-dev.github.io/stratix/",
49
57
  "bugs": {
50
58
  "url": "https://github.com/stratix-dev/stratix/issues"
51
59
  },
52
60
  "engines": {
53
61
  "node": ">=18.0.0"
54
- },
55
- "scripts": {
56
- "build": "tsc",
57
- "test": "vitest run",
58
- "test:watch": "vitest",
59
- "typecheck": "tsc --noEmit",
60
- "lint": "eslint src --ignore-pattern '**/*.test.ts' --ignore-pattern '**/__tests__/**'",
61
- "clean": "rm -rf dist"
62
62
  }
63
- }
63
+ }