confused-ai-core 0.1.0 → 0.1.1
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/{FEATURES.md → Readme.md} +20 -11
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
## Quick Start Examples
|
|
16
16
|
|
|
17
17
|
### 🔧 Circuit Breaker
|
|
18
|
+
|
|
18
19
|
```typescript
|
|
19
20
|
import { createLLMCircuitBreaker } from '@confused-ai/core/production';
|
|
20
21
|
|
|
@@ -33,6 +34,7 @@ if (result.success) {
|
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
### ⏱️ Rate Limiter
|
|
37
|
+
|
|
36
38
|
```typescript
|
|
37
39
|
import { createOpenAIRateLimiter } from '@confused-ai/core/production';
|
|
38
40
|
|
|
@@ -45,6 +47,7 @@ await limiter.execute(async () => {
|
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
### 🏥 Health Checks
|
|
50
|
+
|
|
48
51
|
```typescript
|
|
49
52
|
import { HealthCheckManager, createLLMHealthCheck } from '@confused-ai/core/production';
|
|
50
53
|
|
|
@@ -59,6 +62,7 @@ app.get('/health', async (req, res) => {
|
|
|
59
62
|
```
|
|
60
63
|
|
|
61
64
|
### 💾 LLM Response Cache
|
|
65
|
+
|
|
62
66
|
```typescript
|
|
63
67
|
import { LLMCache, withCache } from '@confused-ai/core/llm';
|
|
64
68
|
|
|
@@ -70,36 +74,36 @@ const response = await cachedLLM.generateText({ messages });
|
|
|
70
74
|
```
|
|
71
75
|
|
|
72
76
|
### 📦 Artifacts
|
|
77
|
+
|
|
73
78
|
```typescript
|
|
74
79
|
import { InMemoryArtifactStorage, createPlanArtifact } from '@confused-ai/core/artifacts';
|
|
75
80
|
|
|
76
81
|
const storage = new InMemoryArtifactStorage();
|
|
77
82
|
|
|
78
83
|
// Create a plan artifact
|
|
79
|
-
const plan = await storage.save(
|
|
80
|
-
'project-plan',
|
|
81
|
-
'Build a chatbot',
|
|
82
|
-
[
|
|
84
|
+
const plan = await storage.save(
|
|
85
|
+
createPlanArtifact('project-plan', 'Build a chatbot', [
|
|
83
86
|
{ description: 'Design conversation flows' },
|
|
84
87
|
{ description: 'Implement intent detection' },
|
|
85
88
|
{ description: 'Add response generation' },
|
|
86
|
-
]
|
|
87
|
-
)
|
|
89
|
+
])
|
|
90
|
+
);
|
|
88
91
|
|
|
89
92
|
// Retrieve with versioning
|
|
90
93
|
const retrieved = await storage.get(plan.id);
|
|
91
94
|
```
|
|
92
95
|
|
|
93
96
|
### 🎤 Voice (TTS/STT)
|
|
97
|
+
|
|
94
98
|
```typescript
|
|
95
99
|
import { OpenAIVoiceProvider } from '@confused-ai/core/voice';
|
|
96
100
|
|
|
97
101
|
const voice = new OpenAIVoiceProvider();
|
|
98
102
|
|
|
99
103
|
// Text-to-Speech
|
|
100
|
-
const { audio } = await voice.textToSpeech('Hello, world!', {
|
|
104
|
+
const { audio } = await voice.textToSpeech('Hello, world!', {
|
|
101
105
|
voiceId: 'nova',
|
|
102
|
-
speed: 1.0
|
|
106
|
+
speed: 1.0,
|
|
103
107
|
});
|
|
104
108
|
|
|
105
109
|
// Speech-to-Text
|
|
@@ -107,6 +111,7 @@ const { text } = await voice.speechToText(audioBuffer);
|
|
|
107
111
|
```
|
|
108
112
|
|
|
109
113
|
### 🔄 Resumable Streaming
|
|
114
|
+
|
|
110
115
|
```typescript
|
|
111
116
|
import { ResumableStreamManager, formatSSE } from '@confused-ai/core/production';
|
|
112
117
|
|
|
@@ -128,6 +133,7 @@ for (const chunk of missed) {
|
|
|
128
133
|
```
|
|
129
134
|
|
|
130
135
|
### 🛡️ Graceful Shutdown
|
|
136
|
+
|
|
131
137
|
```typescript
|
|
132
138
|
import { GracefulShutdown } from '@confused-ai/core/production';
|
|
133
139
|
|
|
@@ -150,9 +156,12 @@ shutdown.listen(); // Handles SIGTERM/SIGINT
|
|
|
150
156
|
|
|
151
157
|
```typescript
|
|
152
158
|
// Production resilience
|
|
153
|
-
import {
|
|
154
|
-
CircuitBreaker,
|
|
155
|
-
|
|
159
|
+
import {
|
|
160
|
+
CircuitBreaker,
|
|
161
|
+
RateLimiter,
|
|
162
|
+
HealthCheckManager,
|
|
163
|
+
GracefulShutdown,
|
|
164
|
+
ResumableStreamManager,
|
|
156
165
|
} from '@confused-ai/core/production';
|
|
157
166
|
|
|
158
167
|
// Observability
|