@em3odme/agentic 0.1.0
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/LICENSE.md +21 -0
- package/README.md +145 -0
- package/dist/index.cjs +782 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +111 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.js +751 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Roman Jankowski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Agentic
|
|
2
|
+
|
|
3
|
+
A TypeScript library for running AI models across multiple providers with a unified interface.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Agentic provides a simple, consistent API for interacting with various AI providers including Cloudflare Workers AI and Groq. It handles provider-specific execution logic, retry logic with exponential backoff, JSON mode, tool calling, and response formatting.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @em3odme/agentic
|
|
13
|
+
pnpm install @em3odme/agentic
|
|
14
|
+
yarn add @em3odme/agentic
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Requirements:** Node.js >= 18.0.0
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { ModelRunner, groqAIModel } from '@em3odme/agentic';
|
|
23
|
+
|
|
24
|
+
const runner = new ModelRunner({
|
|
25
|
+
GROQ_API_KEY: process.env.GROQ_API_KEY!,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const result = await runner.run({
|
|
29
|
+
messages: [{ role: 'user', content: 'Hello, how are you?' }],
|
|
30
|
+
model: groqAIModel('llama-3.3-70b-versatile'),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log(result.content);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Supported Providers
|
|
37
|
+
|
|
38
|
+
| Provider | JSON Mode | Tools | Streaming | Setup |
|
|
39
|
+
| ----------------------------------------------------- | --------- | ----- | --------- | -------------- |
|
|
40
|
+
| [Cloudflare Workers AI](./docs/CloudflareProvider.md) | ✓ | ✓ | ✗ | `AI` binding |
|
|
41
|
+
| [Groq](./docs/GroqProvider.md) | ✓ | ✓ | ✓ | `GROQ_API_KEY` |
|
|
42
|
+
|
|
43
|
+
### Cloudflare Workers AI
|
|
44
|
+
|
|
45
|
+
Run open-source models (Llama, DeepSeek, Mistral, etc.) on Cloudflare's global edge network.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { ModelRunner, cloudflareAIModel } from '@em3odme/agentic';
|
|
49
|
+
|
|
50
|
+
const runner = new ModelRunner({ AI: env.AI });
|
|
51
|
+
|
|
52
|
+
const result = await runner.run({
|
|
53
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
54
|
+
model: cloudflareAIModel('@cf/meta/llama-3.3-70b-instruct-fp8-fast'),
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Features:**
|
|
59
|
+
|
|
60
|
+
- Serverless GPU infrastructure
|
|
61
|
+
- JSON mode for structured responses
|
|
62
|
+
- Function calling capabilities
|
|
63
|
+
- Embedding models support
|
|
64
|
+
- Automatic retries with exponential backoff
|
|
65
|
+
|
|
66
|
+
### Groq
|
|
67
|
+
|
|
68
|
+
High-performance LLM inference with ultra-low latency.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { ModelRunner, groqAIModel } from '@em3odme/agentic';
|
|
72
|
+
|
|
73
|
+
const runner = new ModelRunner({
|
|
74
|
+
GROQ_API_KEY: process.env.GROQ_API_KEY!,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const result = await runner.run({
|
|
78
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
79
|
+
model: groqAIModel('llama-3.3-70b-versatile'),
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Features:**
|
|
84
|
+
|
|
85
|
+
- Real-time streaming responses
|
|
86
|
+
- JSON mode for structured outputs
|
|
87
|
+
- Tool/function calling
|
|
88
|
+
- Speech recognition (Whisper models)
|
|
89
|
+
- Ultra-fast inference
|
|
90
|
+
|
|
91
|
+
## Usage Examples
|
|
92
|
+
|
|
93
|
+
### JSON Mode
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const result = await runner.run({
|
|
97
|
+
messages: [{ role: 'user', content: 'List top 3 programming languages' }],
|
|
98
|
+
model: groqAIModel('llama-3.3-70b-versatile'),
|
|
99
|
+
jsonMode: true,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const languages = JSON.parse(result.content);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Tool Calling
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const result = await runner.run({
|
|
109
|
+
messages: [{ role: 'user', content: 'What is the weather in New York?' }],
|
|
110
|
+
model: groqAIModel('llama-3.3-70b-versatile'),
|
|
111
|
+
options: { tools: true },
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
console.log(result.tool_calls);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Runtime Configuration
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
ModelRunner.updateRuntimeConfig({
|
|
121
|
+
timeout: 60000,
|
|
122
|
+
retries: {
|
|
123
|
+
maxAttempts: 5,
|
|
124
|
+
baseDelay: 1000,
|
|
125
|
+
maxDelay: 10000,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Documentation
|
|
131
|
+
|
|
132
|
+
For detailed documentation, see:
|
|
133
|
+
|
|
134
|
+
- [ModelRunner Documentation](./docs/ModelRunner.md) - Core API reference
|
|
135
|
+
- [Cloudflare Provider](./docs/CloudflareProvider.md) - Cloudflare Workers AI setup and usage
|
|
136
|
+
- [Groq Provider](./docs/GroqProvider.md) - Groq API setup and usage
|
|
137
|
+
|
|
138
|
+
## Package Info
|
|
139
|
+
|
|
140
|
+
- **Repository:** https://github.com/Em3ODMe/agentic.git
|
|
141
|
+
- **Issues:** https://github.com/Em3ODMe/agentic/issues
|
|
142
|
+
|
|
143
|
+
## Keywords
|
|
144
|
+
|
|
145
|
+
agent, llm, ai, typescript, nodejs
|