agentic-kit 0.0.2 → 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/README.md +101 -5
- package/esm/index.js +82 -1
- package/index.d.ts +51 -1
- package/index.js +92 -0
- 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
|
@@ -1 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
import { Bradie } from '@agentic-kit/bradie';
|
|
2
|
+
import OllamaClient from '@agentic-kit/ollama';
|
|
3
|
+
export class OllamaAdapter {
|
|
4
|
+
name = 'ollama';
|
|
5
|
+
client;
|
|
6
|
+
constructor(baseUrl) {
|
|
7
|
+
this.client = new OllamaClient(baseUrl);
|
|
8
|
+
}
|
|
9
|
+
async generate(input) {
|
|
10
|
+
return this.client.generate(input);
|
|
11
|
+
}
|
|
12
|
+
async generateStreaming(input, onChunk) {
|
|
13
|
+
await this.client.generate({ ...input, stream: true }, onChunk);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class BradieAdapter {
|
|
17
|
+
name = 'bradie';
|
|
18
|
+
client;
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.client = new Bradie(config);
|
|
21
|
+
}
|
|
22
|
+
async generate(input) {
|
|
23
|
+
const requestId = await this.client.sendMessage(input.prompt);
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
this.client.subscribeToResponse(requestId)
|
|
26
|
+
.then(() => resolve('Response completed'))
|
|
27
|
+
.catch(reject);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async generateStreaming(input, onChunk) {
|
|
31
|
+
const requestId = await this.client.sendMessage(input.prompt);
|
|
32
|
+
await this.client.subscribeToResponse(requestId);
|
|
33
|
+
}
|
|
34
|
+
getState() {
|
|
35
|
+
return this.client.getState();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class AgentKit {
|
|
39
|
+
providers = new Map();
|
|
40
|
+
currentProvider;
|
|
41
|
+
addProvider(provider) {
|
|
42
|
+
this.providers.set(provider.name, provider);
|
|
43
|
+
if (!this.currentProvider) {
|
|
44
|
+
this.currentProvider = provider;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
setProvider(name) {
|
|
48
|
+
const provider = this.providers.get(name);
|
|
49
|
+
if (!provider) {
|
|
50
|
+
throw new Error(`Provider '${name}' not found`);
|
|
51
|
+
}
|
|
52
|
+
this.currentProvider = provider;
|
|
53
|
+
}
|
|
54
|
+
getCurrentProvider() {
|
|
55
|
+
return this.currentProvider;
|
|
56
|
+
}
|
|
57
|
+
async generate(input, options) {
|
|
58
|
+
if (!this.currentProvider) {
|
|
59
|
+
throw new Error('No provider set');
|
|
60
|
+
}
|
|
61
|
+
if (input.stream && options?.onChunk) {
|
|
62
|
+
return this.currentProvider.generateStreaming(input, options.onChunk);
|
|
63
|
+
}
|
|
64
|
+
return this.currentProvider.generate(input);
|
|
65
|
+
}
|
|
66
|
+
listProviders() {
|
|
67
|
+
return Array.from(this.providers.keys());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function createOllamaKit(baseUrl) {
|
|
71
|
+
const kit = new AgentKit();
|
|
72
|
+
kit.addProvider(new OllamaAdapter(baseUrl));
|
|
73
|
+
return kit;
|
|
74
|
+
}
|
|
75
|
+
export function createBradieKit(config) {
|
|
76
|
+
const kit = new AgentKit();
|
|
77
|
+
kit.addProvider(new BradieAdapter(config));
|
|
78
|
+
return kit;
|
|
79
|
+
}
|
|
80
|
+
export function createMultiProviderKit() {
|
|
81
|
+
return new AgentKit();
|
|
82
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
import { BradieState } from '@agentic-kit/bradie';
|
|
2
|
+
import { GenerateInput } from '@agentic-kit/ollama';
|
|
3
|
+
export interface AgentProvider {
|
|
4
|
+
name: string;
|
|
5
|
+
generate(input: GenerateInput): Promise<string>;
|
|
6
|
+
generateStreaming(input: GenerateInput, onChunk: (chunk: string) => void): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface StreamingOptions {
|
|
9
|
+
onChunk?: (chunk: string) => void;
|
|
10
|
+
onStateChange?: (state: string) => void;
|
|
11
|
+
onError?: (error: Error) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class OllamaAdapter implements AgentProvider {
|
|
14
|
+
readonly name = "ollama";
|
|
15
|
+
private client;
|
|
16
|
+
constructor(baseUrl?: string);
|
|
17
|
+
generate(input: GenerateInput): Promise<string>;
|
|
18
|
+
generateStreaming(input: GenerateInput, onChunk: (chunk: string) => void): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare class BradieAdapter implements AgentProvider {
|
|
21
|
+
readonly name = "bradie";
|
|
22
|
+
private client;
|
|
23
|
+
constructor(config: {
|
|
24
|
+
domain: string;
|
|
25
|
+
onSystemMessage: (msg: string) => void;
|
|
26
|
+
onAssistantReply: (msg: string) => void;
|
|
27
|
+
onError?: (err: Error) => void;
|
|
28
|
+
onComplete?: () => void;
|
|
29
|
+
});
|
|
30
|
+
generate(input: GenerateInput): Promise<string>;
|
|
31
|
+
generateStreaming(input: GenerateInput, onChunk: (chunk: string) => void): Promise<void>;
|
|
32
|
+
getState(): BradieState;
|
|
33
|
+
}
|
|
34
|
+
export declare class AgentKit {
|
|
35
|
+
private providers;
|
|
36
|
+
private currentProvider?;
|
|
37
|
+
addProvider(provider: AgentProvider): void;
|
|
38
|
+
setProvider(name: string): void;
|
|
39
|
+
getCurrentProvider(): AgentProvider | undefined;
|
|
40
|
+
generate(input: GenerateInput, options?: StreamingOptions): Promise<string | void>;
|
|
41
|
+
listProviders(): string[];
|
|
42
|
+
}
|
|
43
|
+
export declare function createOllamaKit(baseUrl?: string): AgentKit;
|
|
44
|
+
export declare function createBradieKit(config: {
|
|
45
|
+
domain: string;
|
|
46
|
+
onSystemMessage: (msg: string) => void;
|
|
47
|
+
onAssistantReply: (msg: string) => void;
|
|
48
|
+
onError?: (err: Error) => void;
|
|
49
|
+
onComplete?: () => void;
|
|
50
|
+
}): AgentKit;
|
|
51
|
+
export declare function createMultiProviderKit(): AgentKit;
|
package/index.js
CHANGED
|
@@ -1,2 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AgentKit = exports.BradieAdapter = exports.OllamaAdapter = void 0;
|
|
7
|
+
exports.createOllamaKit = createOllamaKit;
|
|
8
|
+
exports.createBradieKit = createBradieKit;
|
|
9
|
+
exports.createMultiProviderKit = createMultiProviderKit;
|
|
10
|
+
const bradie_1 = require("@agentic-kit/bradie");
|
|
11
|
+
const ollama_1 = __importDefault(require("@agentic-kit/ollama"));
|
|
12
|
+
class OllamaAdapter {
|
|
13
|
+
name = 'ollama';
|
|
14
|
+
client;
|
|
15
|
+
constructor(baseUrl) {
|
|
16
|
+
this.client = new ollama_1.default(baseUrl);
|
|
17
|
+
}
|
|
18
|
+
async generate(input) {
|
|
19
|
+
return this.client.generate(input);
|
|
20
|
+
}
|
|
21
|
+
async generateStreaming(input, onChunk) {
|
|
22
|
+
await this.client.generate({ ...input, stream: true }, onChunk);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.OllamaAdapter = OllamaAdapter;
|
|
26
|
+
class BradieAdapter {
|
|
27
|
+
name = 'bradie';
|
|
28
|
+
client;
|
|
29
|
+
constructor(config) {
|
|
30
|
+
this.client = new bradie_1.Bradie(config);
|
|
31
|
+
}
|
|
32
|
+
async generate(input) {
|
|
33
|
+
const requestId = await this.client.sendMessage(input.prompt);
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
this.client.subscribeToResponse(requestId)
|
|
36
|
+
.then(() => resolve('Response completed'))
|
|
37
|
+
.catch(reject);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async generateStreaming(input, onChunk) {
|
|
41
|
+
const requestId = await this.client.sendMessage(input.prompt);
|
|
42
|
+
await this.client.subscribeToResponse(requestId);
|
|
43
|
+
}
|
|
44
|
+
getState() {
|
|
45
|
+
return this.client.getState();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.BradieAdapter = BradieAdapter;
|
|
49
|
+
class AgentKit {
|
|
50
|
+
providers = new Map();
|
|
51
|
+
currentProvider;
|
|
52
|
+
addProvider(provider) {
|
|
53
|
+
this.providers.set(provider.name, provider);
|
|
54
|
+
if (!this.currentProvider) {
|
|
55
|
+
this.currentProvider = provider;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
setProvider(name) {
|
|
59
|
+
const provider = this.providers.get(name);
|
|
60
|
+
if (!provider) {
|
|
61
|
+
throw new Error(`Provider '${name}' not found`);
|
|
62
|
+
}
|
|
63
|
+
this.currentProvider = provider;
|
|
64
|
+
}
|
|
65
|
+
getCurrentProvider() {
|
|
66
|
+
return this.currentProvider;
|
|
67
|
+
}
|
|
68
|
+
async generate(input, options) {
|
|
69
|
+
if (!this.currentProvider) {
|
|
70
|
+
throw new Error('No provider set');
|
|
71
|
+
}
|
|
72
|
+
if (input.stream && options?.onChunk) {
|
|
73
|
+
return this.currentProvider.generateStreaming(input, options.onChunk);
|
|
74
|
+
}
|
|
75
|
+
return this.currentProvider.generate(input);
|
|
76
|
+
}
|
|
77
|
+
listProviders() {
|
|
78
|
+
return Array.from(this.providers.keys());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.AgentKit = AgentKit;
|
|
82
|
+
function createOllamaKit(baseUrl) {
|
|
83
|
+
const kit = new AgentKit();
|
|
84
|
+
kit.addProvider(new OllamaAdapter(baseUrl));
|
|
85
|
+
return kit;
|
|
86
|
+
}
|
|
87
|
+
function createBradieKit(config) {
|
|
88
|
+
const kit = new AgentKit();
|
|
89
|
+
kit.addProvider(new BradieAdapter(config));
|
|
90
|
+
return kit;
|
|
91
|
+
}
|
|
92
|
+
function createMultiProviderKit() {
|
|
93
|
+
return new AgentKit();
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
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.
|
|
34
|
-
"@agentic-kit/ollama": "^0.
|
|
33
|
+
"@agentic-kit/bradie": "^0.1.1",
|
|
34
|
+
"@agentic-kit/ollama": "^0.1.1"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [],
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "0204aa87ae43833af29965684146ff22ebf77564"
|
|
38
38
|
}
|