agentic-kit 0.1.0 → 0.1.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 +101 -5
- package/esm/index.js +18 -2
- package/index.d.ts +1 -0
- package/index.js +18 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,12 +1,108 @@
|
|
|
1
1
|
# Agentic Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Agentic Kit is the core library providing a unified, streaming-capable interface for multiple LLM providers. It lets you plug in any supported adapter and switch between them at runtime.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
+
```bash
|
|
8
|
+
npm install agentic-kit
|
|
9
|
+
# or
|
|
10
|
+
yarn add agentic-kit
|
|
11
|
+
```
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
Agentic Kit includes adapters for Ollama and Bradie out of the box.
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
## Quick Start
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
```typescript
|
|
18
|
+
import {
|
|
19
|
+
// Adapters
|
|
20
|
+
OllamaAdapter,
|
|
21
|
+
BradieAdapter,
|
|
22
|
+
|
|
23
|
+
// Factory functions
|
|
24
|
+
createOllamaKit,
|
|
25
|
+
createBradieKit,
|
|
26
|
+
createMultiProviderKit,
|
|
27
|
+
|
|
28
|
+
// Core type
|
|
29
|
+
AgentKit
|
|
30
|
+
} from 'agentic-kit';
|
|
31
|
+
|
|
32
|
+
// Ollama-only client
|
|
33
|
+
const ollamaKit: AgentKit = createOllamaKit('http://localhost:11434');
|
|
34
|
+
const text = await ollamaKit.generate({ model: 'mistral', prompt: 'Hello' });
|
|
35
|
+
console.log(text);
|
|
36
|
+
|
|
37
|
+
// Bradie-only client
|
|
38
|
+
const bradieKit: AgentKit = createBradieKit({
|
|
39
|
+
domain: 'http://localhost:3000',
|
|
40
|
+
onSystemMessage: (msg) => console.log('[system]', msg),
|
|
41
|
+
onAssistantReply: (msg) => console.log('[assistant]', msg),
|
|
42
|
+
});
|
|
43
|
+
await bradieKit.generate({ prompt: 'Hello' });
|
|
44
|
+
|
|
45
|
+
// Multi-provider client
|
|
46
|
+
const multiKit = createMultiProviderKit();
|
|
47
|
+
multiKit.addProvider(new OllamaAdapter('http://localhost:11434'));
|
|
48
|
+
multiKit.addProvider(new BradieAdapter({
|
|
49
|
+
domain: 'http://localhost:3000',
|
|
50
|
+
onSystemMessage: console.log,
|
|
51
|
+
onAssistantReply: console.log
|
|
52
|
+
}));
|
|
53
|
+
const reply = await multiKit.generate({ model: 'mistral', prompt: 'Hello' });
|
|
54
|
+
console.log(reply);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Streaming
|
|
58
|
+
|
|
59
|
+
Both adapters support a streaming mode that invokes a callback for each data chunk.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
await ollamaKit.generate(
|
|
63
|
+
{ model: 'mistral', prompt: 'Hello', stream: true },
|
|
64
|
+
(chunk) => console.log('Ollama chunk:', chunk)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
await bradieKit.generate(
|
|
68
|
+
{ model: 'mistral', prompt: 'Hello', stream: true },
|
|
69
|
+
(chunk) => console.log('Bradie chunk:', chunk)
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### AgentKit
|
|
76
|
+
|
|
77
|
+
- `.generate(input: GenerateInput, options?: StreamingOptions): Promise<string | void>`
|
|
78
|
+
- `.listProviders(): string[]`
|
|
79
|
+
- `.setProvider(name: string): void`
|
|
80
|
+
- `.getCurrentProvider(): AgentProvider | undefined`
|
|
81
|
+
|
|
82
|
+
### GenerateInput
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
interface GenerateInput {
|
|
86
|
+
model?: string; // For services that support named models
|
|
87
|
+
prompt: string; // The text prompt
|
|
88
|
+
stream?: boolean; // If true, use streaming mode
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### StreamingOptions
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
interface StreamingOptions {
|
|
96
|
+
onChunk?: (chunk: string) => void;
|
|
97
|
+
onStateChange?: (state: string) => void;
|
|
98
|
+
onError?: (error: Error) => void;
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Contributing
|
|
103
|
+
|
|
104
|
+
Contributions are welcome! Please submit issues and pull requests on [GitHub](https://github.com/hyperweb-io/agentic-kit).
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
© Hyperweb (formerly Cosmology). See LICENSE for full licensing and disclaimer.
|
package/esm/index.js
CHANGED
|
@@ -59,9 +59,25 @@ export class AgentKit {
|
|
|
59
59
|
throw new Error('No provider set');
|
|
60
60
|
}
|
|
61
61
|
if (input.stream && options?.onChunk) {
|
|
62
|
-
|
|
62
|
+
try {
|
|
63
|
+
const result = await this.currentProvider.generateStreaming(input, options.onChunk);
|
|
64
|
+
options?.onComplete?.();
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
options?.onError?.(error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const result = await this.currentProvider.generate(input);
|
|
74
|
+
options?.onComplete?.();
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
options?.onError?.(error);
|
|
79
|
+
throw error;
|
|
63
80
|
}
|
|
64
|
-
return this.currentProvider.generate(input);
|
|
65
81
|
}
|
|
66
82
|
listProviders() {
|
|
67
83
|
return Array.from(this.providers.keys());
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface StreamingOptions {
|
|
|
9
9
|
onChunk?: (chunk: string) => void;
|
|
10
10
|
onStateChange?: (state: string) => void;
|
|
11
11
|
onError?: (error: Error) => void;
|
|
12
|
+
onComplete?: () => void;
|
|
12
13
|
}
|
|
13
14
|
export declare class OllamaAdapter implements AgentProvider {
|
|
14
15
|
readonly name = "ollama";
|
package/index.js
CHANGED
|
@@ -70,9 +70,25 @@ class AgentKit {
|
|
|
70
70
|
throw new Error('No provider set');
|
|
71
71
|
}
|
|
72
72
|
if (input.stream && options?.onChunk) {
|
|
73
|
-
|
|
73
|
+
try {
|
|
74
|
+
const result = await this.currentProvider.generateStreaming(input, options.onChunk);
|
|
75
|
+
options?.onComplete?.();
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
options?.onError?.(error);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const result = await this.currentProvider.generate(input);
|
|
85
|
+
options?.onComplete?.();
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
options?.onError?.(error);
|
|
90
|
+
throw error;
|
|
74
91
|
}
|
|
75
|
-
return this.currentProvider.generate(input);
|
|
76
92
|
}
|
|
77
93
|
listProviders() {
|
|
78
94
|
return Array.from(this.providers.keys());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "Agentic Kit",
|
|
6
6
|
"main": "index.js",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"test:watch": "jest --watch"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@agentic-kit/bradie": "^0.1.
|
|
34
|
-
"@agentic-kit/ollama": "^0.1.
|
|
33
|
+
"@agentic-kit/bradie": "^0.1.2",
|
|
34
|
+
"@agentic-kit/ollama": "^0.1.2"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [],
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "957a378bb3b08f3be63cce7b72d741f1f044ae95"
|
|
38
38
|
}
|