art-framework 0.3.0 → 0.3.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 +81 -59
- package/dist/index.cjs +67 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -48
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# ✨ ART: Agentic Runtime Framework <img src="https://img.shields.io/badge/Version-v0.3.2-blue" alt="Version 0.3.2">
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="docs/art-logo.jpeg" alt="ART Framework Logo" width="200"/>
|
|
7
|
+
</p>
|
|
2
8
|
|
|
3
9
|
**ART is a powerful, modular, and browser-first TypeScript framework for building sophisticated LLM-powered agents capable of complex reasoning, planning, and tool usage.**
|
|
4
10
|
|
|
@@ -67,69 +73,85 @@ yarn add art-framework
|
|
|
67
73
|
|
|
68
74
|
## Quick Start
|
|
69
75
|
|
|
70
|
-
This example demonstrates setting up a simple agent that uses OpenAI
|
|
76
|
+
This example demonstrates setting up a simple agent that uses OpenAI and runs in-memory. For a complete example with all configurations, see the [Comprehensive Developer Guide](./docs/README.md).
|
|
71
77
|
|
|
72
78
|
```typescript
|
|
73
|
-
import {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
79
|
+
import {
|
|
80
|
+
createArtInstance,
|
|
81
|
+
ArtInstanceConfig,
|
|
82
|
+
ThreadConfig,
|
|
83
|
+
CalculatorTool,
|
|
84
|
+
OpenAIAdapter,
|
|
85
|
+
GeminiAdapter
|
|
86
|
+
} from 'art-framework';
|
|
87
|
+
|
|
88
|
+
// --- 1. Configure the ART Instance ---
|
|
89
|
+
// Note: No API keys or secrets are present here.
|
|
90
|
+
|
|
91
|
+
const artConfig: ArtInstanceConfig = {
|
|
92
|
+
storage: {
|
|
93
|
+
type: 'indexedDB',
|
|
94
|
+
dbName: 'MyCorrectChatDB'
|
|
95
|
+
},
|
|
96
|
+
providers: {
|
|
97
|
+
availableProviders: [
|
|
98
|
+
{ name: 'openai', adapter: OpenAIAdapter },
|
|
99
|
+
{ name: 'gemini', adapter: GeminiAdapter }
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
tools: [new CalculatorTool()],
|
|
103
|
+
persona: {
|
|
104
|
+
name: 'ConfigExpert',
|
|
105
|
+
prompts: {
|
|
106
|
+
synthesis: 'You explain configurations clearly.'
|
|
102
107
|
}
|
|
108
|
+
},
|
|
109
|
+
logger: { level: 'info' }
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// --- 2. Main Application Logic ---
|
|
114
|
+
|
|
115
|
+
async function initializeAndRun() {
|
|
116
|
+
// Create the ART instance with the high-level configuration.
|
|
117
|
+
const art = await createArtInstance(artConfig);
|
|
118
|
+
console.log('ART Instance Initialized.');
|
|
119
|
+
|
|
120
|
+
// --- 3. Set Up a New Conversation Thread ---
|
|
121
|
+
const threadId = 'user-123-session-1';
|
|
122
|
+
|
|
123
|
+
// Create the thread-specific configuration.
|
|
124
|
+
// THIS is where you specify the provider, model, and API key.
|
|
125
|
+
const threadConfig: ThreadConfig = {
|
|
126
|
+
providerConfig: {
|
|
127
|
+
providerName: 'openai', // Must match a name from availableProviders
|
|
128
|
+
modelId: 'gpt-4o',
|
|
129
|
+
adapterOptions: {
|
|
130
|
+
apiKey: 'sk-your-real-openai-api-key', // Securely provide your API key here
|
|
131
|
+
temperature: 0.7
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
// Other thread settings
|
|
135
|
+
enabledTools: ['CalculatorTool'],
|
|
136
|
+
historyLimit: 20
|
|
103
137
|
};
|
|
104
138
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
// (Optional) A unique ID for the conversation thread
|
|
121
|
-
threadId: 'quickstart-thread-1',
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// 4. Log the result
|
|
125
|
-
console.log('Agent Response:', result.responseText);
|
|
126
|
-
// console.log("Full Result:", result); // You can inspect the full object for more details
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.error('Agent processing failed:', error);
|
|
129
|
-
}
|
|
139
|
+
// Save this configuration for the new thread.
|
|
140
|
+
// This step is crucial and must be done before the first `process` call.
|
|
141
|
+
await art.stateManager.setThreadConfig(threadId, threadConfig);
|
|
142
|
+
console.log(`ThreadConfig set for threadId: ${threadId}`);
|
|
143
|
+
|
|
144
|
+
// Now the ART instance is ready to process requests for this thread.
|
|
145
|
+
console.log('Sending first message...');
|
|
146
|
+
const response = await art.process({
|
|
147
|
+
query: 'What is 2 + 2?',
|
|
148
|
+
threadId: threadId
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
console.log('Final response:', response.response.content);
|
|
130
152
|
}
|
|
131
153
|
|
|
132
|
-
|
|
154
|
+
initializeAndRun().catch(console.error);
|
|
133
155
|
```
|
|
134
156
|
|
|
135
157
|
*(Note: Replace `'YOUR_OPENAI_API_KEY'` with your actual key. In a real application, load this from a secure source like environment variables or a secrets manager.)*
|
|
@@ -137,8 +159,8 @@ runSimpleAgent();
|
|
|
137
159
|
## Documentation
|
|
138
160
|
|
|
139
161
|
* **[Comprehensive Developer Guide](docs/README.md):** The primary guide covering concepts, architecture, and API usage. **(Start Here!)**
|
|
140
|
-
* **[How-To Guides](docs/how-to):** Practical guides for specific tasks, such as [Customizing the Agent's Persona](docs/how-to/customizing-agent-persona.md).
|
|
141
|
-
* **[API Reference](docs/components
|
|
162
|
+
* **[How-To Guides](./docs/how-to):** Practical guides for specific tasks, such as [Customizing the Agent's Persona](./docs/how-to/customizing-agent-persona.md).
|
|
163
|
+
* **[API Reference](./docs/components):** Auto-generated API documentation.
|
|
142
164
|
* **[Examples](./examples):** Find practical examples, including a full React chatbot implementation.
|
|
143
165
|
|
|
144
166
|
## Contributing
|