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 CHANGED
@@ -1,4 +1,10 @@
1
- # ✨ ART: Agentic Runtime Framework <img src="https://img.shields.io/badge/Version-v0.2.8-blue" alt="Version 0.3.0">
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, runs in-memory, and answers a query.
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 { createArtInstance } from 'art-framework';
74
- import type { ArtInstanceConfig } from 'art-framework';
75
-
76
- async function runSimpleAgent() {
77
- // 1. Define the configuration for the ART instance
78
- const config: ArtInstanceConfig = {
79
- // Use 'memory' for simple tests, or 'indexedDB' for browser persistence
80
- storage: { type: 'memory' },
81
-
82
- // Configure your LLM providers. The key ('openai' here) is a friendly name.
83
- providers: {
84
- openai: {
85
- // The adapter handles communication with the provider
86
- adapter: 'openai', // Use the name of the built-in adapter
87
- // Pass API key securely (use env vars or a secrets manager in production)
88
- apiKey: 'YOUR_OPENAI_API_KEY',
89
- },
90
- // You could add other providers here, e.g., 'anthropic', 'gemini'
91
- },
92
-
93
- // Register any tools you want the agent to use
94
- // tools: [new CalculatorTool()],
95
-
96
- // (Optional) Define a default persona for the agent instance
97
- persona: {
98
- name: 'ART-Bot',
99
- prompts: {
100
- synthesis: 'You are ART-Bot, a helpful and friendly AI assistant. Provide a clear and concise answer to the user\'s query.'
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
- // 2. Create the ART instance
106
- const art = await createArtInstance(config);
107
- console.log('ART instance created successfully!');
108
-
109
- // 3. Start a conversation and process a query
110
- try {
111
- const result = await art.process({
112
- query: 'What is the capital of France?',
113
- // Use a provider and model configured above
114
- threadConfig: {
115
- runtimeProvider: {
116
- provider: 'openai',
117
- model: 'gpt-4o-mini',
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
- runSimpleAgent();
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/README.md):** Auto-generated API documentation.
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