agentic-api 1.0.1 → 1.0.3
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 +60 -77
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,58 +1,41 @@
|
|
|
1
1
|
# @agentic-api
|
|
2
2
|
|
|
3
|
-
API
|
|
4
|
-
> **Note personnelle** :
|
|
5
|
-
Ce projet n'a pas l'intention d'être meilleur que Vercel ou LangChain. Il est simplement moins générique, et optimisé pour un petit nombre de problèmes.
|
|
6
|
-
Il se concentre sur des fonctionnalités spécifiques qui impliquait trop de dépendances avec les autres frameworks.
|
|
7
|
-
|
|
8
|
-
## 🚀 Fonctionnalités clés
|
|
9
|
-
- Orchestration d'agents en séquences selon un graphe prédéfini
|
|
10
|
-
- Escalade automatique vers des modèles plus performants
|
|
11
|
-
- Transfert intelligent entre agents spécialisés avec seuil de confiance
|
|
12
|
-
- Gestion de la mémoire (session et long terme)
|
|
13
|
-
- Extraction de texte depuis les PDFs
|
|
14
|
-
- Outil de réflexion (thinking) pour le raisonnement complexe
|
|
15
|
-
- Feedback en temps réel sur l'état des agents
|
|
16
|
-
|
|
17
|
-
### Avantages clés de @agentic-api
|
|
18
|
-
1. **Simplicité d'utilisation**
|
|
19
|
-
- Configuration minimale requise
|
|
20
|
-
- Un minimum de dépendances
|
|
21
|
-
|
|
22
|
-
2. **Performance**
|
|
23
|
-
- Optimisé pour les applications en production
|
|
24
|
-
- Gestion efficace de la mémoire
|
|
25
|
-
- Transferts d'agents rapides et (relativement) fiables
|
|
26
|
-
|
|
27
|
-
3. **Flexibilité**
|
|
28
|
-
- Support principalement d'OpenAI
|
|
29
|
-
- Système extensible
|
|
30
|
-
- Personnalisation facile des agents
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Cas d'utilisation recommandés
|
|
34
|
-
- Applications nécessitant une orchestration d'agents spécialisés
|
|
35
|
-
- Projets nécessitant une extraction de contenu fiable
|
|
3
|
+
Super simple API for intelligent agent orchestration with automatic sequences and escalations. (inspiré du projet [OpenAI Swarm](https://github.com/openai/openai-realtime-agents))
|
|
36
4
|
|
|
37
|
-
|
|
5
|
+
> **Personal Note**:
|
|
6
|
+
> This project is not meant to be better than Vercel or LangChain. It's simply less generic and optimized for a specific set of problems.
|
|
7
|
+
> It focuses on specific features that required too many dependencies with other frameworks.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 🚀 Key Features
|
|
11
|
+
|
|
12
|
+
- Agent orchestration in predefined sequences
|
|
13
|
+
- Automatic model escalation to more intelligent instructions and models.
|
|
14
|
+
- Smart transfer between specialized agents with confidence threshold
|
|
15
|
+
- Prompting models to follow a state machine, for example to accurately collect things like names and phone numbers.
|
|
38
16
|
|
|
39
|
-
```bash
|
|
40
|
-
npm install @agentic-api
|
|
41
|
-
```
|
|
42
17
|
|
|
43
|
-
|
|
18
|
+
### Key Advantages
|
|
44
19
|
|
|
45
|
-
|
|
20
|
+
1. **Simplicity**
|
|
21
|
+
- Minimal configuration
|
|
22
|
+
- Few dependencies
|
|
23
|
+
- Fast
|
|
24
|
+
|
|
25
|
+
### Recommended Use Cases
|
|
26
|
+
|
|
27
|
+
- Applications requiring specialized agent orchestration
|
|
28
|
+
- Projects needing reliable content extraction
|
|
29
|
+
|
|
30
|
+
[](https://mermaid.live/edit#pako:eNpVkd1OwjAUx1-lOYmJJkDYhxvswoRB0AtvdCQmbsTU7bAt2dqltCogz2K89uV8BMs-AM9F199__3N6TruDmCcIHqwK_h5nVEiymEWM6Aikpsuw_iyvGm0S3gpEiWLZ8OwyjOD36-eb3KmSsgg6Y7Ou1WsqaJWRAMVbHuPLJEUm1yRsmTTcFjtEkguMZc4ZuX88qb4RBrTAc6NvhlO1lrxEQQJVVVw3efbXCh8Ul8cMZEnEmu00fFrMlx3V05F-_4ZM2glr8I1_ZP4jq0u-uCBzLmLdAS3ylGGphyEZF_mWM0mLxuQbpD84K-KbLVstWw3Puqptwuec5oUS-EmmbeOH00_q0Q890JdQ0jzRz7g7aBHITDcTgae3Ca6oKmQEEdtrK1WSBxsWgyeFwh4IrtIMvBUt1ppUlVCJs5zqZyuPakXZM-dll5KKw1Ftur5ZFFOumATPdN3aDN4OPsC7HpkDwzRcczw0DEtHDzbgucPBtWPajuXYY9twbGffg21dfTgYufb4PPZ_wB3E1Q)
|
|
31
|
+
|
|
32
|
+
## 📦 Installation
|
|
46
33
|
|
|
47
34
|
```bash
|
|
48
|
-
|
|
49
|
-
sudo apt install python3.*-venv
|
|
50
|
-
python3 -m venv .venv
|
|
51
|
-
source .venv/bin/activate
|
|
52
|
-
pip install -r bin/requirements.txt
|
|
35
|
+
npm install @agentic-api
|
|
53
36
|
```
|
|
54
37
|
|
|
55
|
-
## 💡
|
|
38
|
+
## 💡 Quick Start
|
|
56
39
|
|
|
57
40
|
```typescript
|
|
58
41
|
import OpenAI from "openai";
|
|
@@ -64,7 +47,7 @@ const openai = new OpenAI({
|
|
|
64
47
|
apiKey: process.env.OPENAI_API_KEY,
|
|
65
48
|
});
|
|
66
49
|
|
|
67
|
-
//
|
|
50
|
+
// Create session context
|
|
68
51
|
const session: AgenticContext = {
|
|
69
52
|
memory: {
|
|
70
53
|
messages: [],
|
|
@@ -73,64 +56,64 @@ const session: AgenticContext = {
|
|
|
73
56
|
usage: { prompt: 0, completion: 0, total: 0, cost: 0 }
|
|
74
57
|
},
|
|
75
58
|
user: {
|
|
76
|
-
id:
|
|
59
|
+
id: user.id
|
|
77
60
|
}
|
|
78
61
|
};
|
|
79
62
|
|
|
80
|
-
//
|
|
63
|
+
// Execute agent with memory enrichment
|
|
81
64
|
const stream = await executeAgentSet(agents, session, {
|
|
82
|
-
query: "
|
|
65
|
+
query: "Hello, what can you do?",
|
|
83
66
|
initialAgent: "greeter",
|
|
84
67
|
verbose: true,
|
|
85
68
|
enrichWithMemory: async (role) => {
|
|
86
|
-
//
|
|
69
|
+
// Memory enrichment logic
|
|
87
70
|
return "";
|
|
88
71
|
}
|
|
89
72
|
});
|
|
90
73
|
```
|
|
91
74
|
|
|
92
|
-
## 🤖
|
|
75
|
+
## 🤖 Custom Agent Creation
|
|
93
76
|
|
|
94
77
|
```typescript
|
|
95
78
|
import { AgentConfig } from '@agentic-api/types';
|
|
96
79
|
import { modelConfig } from '@agentic-api/execute';
|
|
97
80
|
|
|
98
|
-
//
|
|
81
|
+
// Example specialized agent with thinking tool
|
|
99
82
|
const haiku: AgentConfig = {
|
|
100
83
|
name: "haiku",
|
|
101
|
-
publicDescription: "Agent
|
|
102
|
-
instructions: "
|
|
84
|
+
publicDescription: "Agent that writes haikus.",
|
|
85
|
+
instructions: "Ask the user for a subject, then respond with a haiku.",
|
|
103
86
|
model: modelConfig("LOW"),
|
|
104
87
|
tools: [],
|
|
105
|
-
maxSteps: 3 //
|
|
88
|
+
maxSteps: 3 // Limit thinking steps
|
|
106
89
|
};
|
|
107
90
|
|
|
108
|
-
//
|
|
91
|
+
// Welcome agent with transfer
|
|
109
92
|
const welcome: AgentConfig = {
|
|
110
93
|
name: "welcome",
|
|
111
|
-
publicDescription: "Agent
|
|
112
|
-
instructions: "
|
|
94
|
+
publicDescription: "Agent that welcomes users.",
|
|
95
|
+
instructions: "Welcome the user and suggest options.",
|
|
113
96
|
model: modelConfig("LOW"),
|
|
114
97
|
tools: [],
|
|
115
98
|
downstreamAgents: [haiku]
|
|
116
99
|
};
|
|
117
100
|
|
|
118
|
-
//
|
|
101
|
+
// Inject transfer and thinking tools
|
|
119
102
|
import { injectTransferTools } from '@agentic-api/utils';
|
|
120
103
|
const myAgents = injectTransferTools([welcome, haiku]);
|
|
121
104
|
```
|
|
122
105
|
|
|
123
|
-
## 🧠
|
|
106
|
+
## 🧠 Memory Management
|
|
124
107
|
|
|
125
108
|
```typescript
|
|
126
109
|
import { MemoriesLite } from '@memories-lite';
|
|
127
110
|
|
|
128
111
|
const memory = new MemoriesLite({
|
|
129
|
-
//
|
|
112
|
+
// Memory configuration
|
|
130
113
|
});
|
|
131
114
|
|
|
132
115
|
async function chatWithMemories(message: string, userId = "default_user") {
|
|
133
|
-
//
|
|
116
|
+
// Semantic memory search
|
|
134
117
|
const relevantMemories = await memory.retrieve(message, userId, {
|
|
135
118
|
limit: 5,
|
|
136
119
|
filters: { type: "conversation" }
|
|
@@ -145,39 +128,39 @@ ${relevantMemories.results.map(entry => `- ${entry.memory}`).join("\n")}`;
|
|
|
145
128
|
{ role: "user", content: message },
|
|
146
129
|
];
|
|
147
130
|
|
|
148
|
-
// Capture
|
|
131
|
+
// Capture new conversation
|
|
149
132
|
await memory.capture(messages, userId, {
|
|
150
133
|
metadata: { type: "conversation" }
|
|
151
134
|
});
|
|
152
135
|
}
|
|
153
136
|
```
|
|
154
137
|
|
|
155
|
-
## ⚙️
|
|
138
|
+
## ⚙️ Model Levels
|
|
156
139
|
|
|
157
|
-
- **LOW**: gpt-4.1-nano (
|
|
158
|
-
- **MEDIUM**: gpt-4.1-mini (
|
|
159
|
-
- **HIGH**: gpt-4.1 (
|
|
160
|
-
- **SEARCH**: gpt-4o-mini-search-preview (
|
|
140
|
+
- **LOW**: gpt-4.1-nano (simple tasks)
|
|
141
|
+
- **MEDIUM**: gpt-4.1-mini (balanced performance/cost)
|
|
142
|
+
- **HIGH**: gpt-4.1 (advanced reasoning)
|
|
143
|
+
- **SEARCH**: gpt-4o-mini-search-preview (web search with localization)
|
|
161
144
|
|
|
162
|
-
## 🔄
|
|
145
|
+
## 🔄 Agent Transfer
|
|
163
146
|
|
|
164
|
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
147
|
+
Agent transfer is automatically managed with:
|
|
148
|
+
- Confidence threshold (0.7) for transfer
|
|
149
|
+
- Transfer justification
|
|
150
|
+
- Conversation context preservation
|
|
151
|
+
- Automatic system instruction updates
|
|
169
152
|
|
|
170
|
-
## 🧪
|
|
153
|
+
## 🧪 Testing
|
|
171
154
|
|
|
172
155
|
```bash
|
|
173
156
|
npm test
|
|
174
157
|
```
|
|
175
158
|
|
|
176
|
-
## 📄
|
|
159
|
+
## 📄 License
|
|
177
160
|
|
|
178
161
|
MIT License
|
|
179
162
|
|
|
180
|
-
Copyright (c) 2024
|
|
163
|
+
Copyright (c) 2024 Pilet-Renaud SA
|
|
181
164
|
|
|
182
165
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
183
166
|
of this software and associated documentation files (the "Software"), to deal
|
package/package.json
CHANGED