-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigration-guide.html
302 lines (274 loc) · 9.61 KB
/
migration-guide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Murmuration: Migration Guide from v1.0.0 to v2.0.0 🐦</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<style>
body {
margin: 0;
font-family: 'Roboto', sans-serif;
background: linear-gradient(to bottom, #0175C2, #1E1E1E);
color: #ECEFF1;
}
header {
background: #02569B;
padding: 20px;
text-align: center;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.2);
}
header h1 {
font-size: 2.5rem;
margin: 0;
color: #FFFFFF;
}
.content {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background: #263238;
border-radius: 10px;
box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.3);
text-align: left;
}
.content h2 {
color: #0288D1;
border-bottom: 2px solid #0288D1;
padding-bottom: 5px;
}
.code-block {
background: #37474F;
padding: 15px;
border-radius: 5px;
overflow-x: auto;
}
.code-block pre {
margin: 0;
color: #ECEFF1;
}
footer {
text-align: center;
padding: 10px;
background: #02569B;
margin-top: 20px;
color: #B3E5FC;
}
</style>
</head>
<body>
<header>
<h1>Murmuration: Migration Guide from v1.0.0 to v2.0.0 🐦</h1>
</header>
<div class="content">
<h2>Major Changes Overview</h2>
<ul>
<li>Enhanced schema validation system</li>
<li>Thread-safe state management</li>
<li>Improved error handling</li>
<li>New configuration options</li>
<li>Extended message history capabilities</li>
<li>Streaming response improvements</li>
<li>More robust progress tracking</li>
</ul>
<h2>Step-by-Step Migration</h2>
<h3>1. Update Dependencies</h3>
<p>Update your <code>pubspec.yaml</code>:</p>
<div class="code-block">
<pre>dependencies:
murmuration: ^2.0.0
google_generative_ai: ^latest_version
shared_preferences: ^latest_version # New requirement
synchronized: ^latest_version # New requirement</pre>
</div>
<h3>2. Configuration Updates</h3>
<h4>Before (1.0.0):</h4>
<div class="code-block">
<pre>final config = MurmurationConfig(
apiKey: 'your-api-key',
model: 'gemini-1.5-flash-latest',
debug: false,
stream: false,
logger: MurmurationLogger()
);</pre>
</div>
<h4>After (2.0.0):</h4>
<div class="code-block">
<pre>final config = MurmurationConfig(
apiKey: 'your-api-key',
model: 'gemini-1.5-pro', // Updated default model
debug: true,
stream: false,
logger: MurmurationLogger(enabled: true),
timeout: Duration(seconds: 30), // New option
maxRetries: 3, // New option
retryDelay: Duration(seconds: 1),// New option
enableCache: true, // New option
cacheTimeout: Duration(hours: 1) // New option
);</pre>
</div>
<h3>3. Schema Validation Changes</h3>
<h4>Before (1.0.0):</h4>
<div class="code-block">
<pre>final schema = {
'type': 'object',
'properties': {
'name': {'type': 'string'},
'age': {'type': 'number'}
}
};</pre>
</div>
<h4>After (2.0.0):</h4>
<div class="code-block">
<pre>final schema = OutputSchema(
fields: {
'name': StringSchemaField(
description: 'User name',
minLength: 2,
required: true
),
'age': IntSchemaField(
description: 'User age',
min: 0,
required: true
)
},
strict: true
);</pre>
</div>
<h3>4. State Management Updates</h3>
<h4>Before (1.0.0):</h4>
<div class="code-block">
<pre>agent.updateState({'key': 'value'});
final value = agent.getState()['key'];</pre>
</div>
<h4>After (2.0.0):</h4>
<div class="code-block">
<pre>// State is now immutable
final newState = state.copyWith({'key': 'value'});
final value = state.get<String>('key'); // Type-safe access</pre>
</div>
<h3>5. Error Handling Improvements</h3>
<h4>Before (1.0.0):</h4>
<div class="code-block">
<pre>try {
final result = await agent.execute("Process data");
} catch (e) {
print('Error: $e');
}</pre>
</div>
<h4>After (2.0.0):</h4>
<div class="code-block">
<pre>try {
final result = await agent.execute("Process data");
} on MurmurationException catch (e) {
print('Error: ${e.message}');
print('Original error: ${e.originalError}');
print('Stack trace: ${e.stackTrace}');
}</pre>
</div>
<h3>6. Message History Management</h3>
<h4>Before (1.0.0):</h4>
<div class="code-block">
<pre>// Basic message storage
final messages = [];
messages.add(message);</pre>
</div>
<h4>After (2.0.0):</h4>
<div class="code-block">
<pre>final history = MessageHistory(
threadId: 'user-123',
maxMessages: 50,
maxTokens: 4000
);
await history.addMessage(Message(
role: 'user',
content: 'Hello!',
timestamp: DateTime.now()
));
await history.save(); // Persist to storage
await history.load(); // Load from storage
await history.clear(); // Clear history</pre>
</div>
<h3>7. Progress Tracking Updates</h3>
<h4>Before (1.0.0):</h4>
<div class="code-block">
<pre>final result = await murmur.run(
input: "Process this",
onProgress: (progress) {
print('Progress: ${progress.toString()}');
}
);</pre>
</div>
<h4>After (2.0.0):</h4>
<div class="code-block">
<pre>final result = await murmur.runAgentChain(
input: "Process this",
agentInstructions: [/* ... */],
logProgress: true,
onProgress: (progress) {
print('Agent: ${progress.currentAgent}/${progress.totalAgents}');
print('Status: ${progress.status}');
print('Output: ${progress.output}');
}
);</pre>
</div>
<h3>8. Tool Integration Changes</h3>
<h4>Before (1.0.0):</h4>
<div class="code-block">
<pre>final tool = Tool(
name: 'processor',
description: 'Processes data',
execute: (params) async => processData(params)
);</pre>
</div>
<h4>After (2.0.0):</h4>
<div class="code-block">
<pre>final tool = Tool(
name: 'processor',
description: 'Processes data parameters: {
'data': StringSchemaField(
description: 'Input data to process',
required: true
),
'format': StringSchemaField(
description: 'Output format',
enumValues: ['json', 'xml', 'text'],
required: true
)
},
execute: (params) async => processData(params)
);</pre>
</div>
<h2>Breaking Changes</h2>
<ul>
<li><strong>Schema System:</strong> Complete overhaul of schema validation with new type-safe field definitions required and strict validation mode by default.</li>
<li><strong>State Management:</strong> State is now immutable, requiring the use of copyWith() for updates and type-safe access methods.</li>
<li><strong>Configuration:</strong> New required configuration options, different default values, and additional dependencies required.</li>
<li><strong>Error Handling:</strong> Introduction of the MurmurationException class with more detailed error information and structured error handling required.</li>
<li><strong>Message History:</strong> Thread-safe by default with persistence required and automatic cleanup mechanisms.</li>
</ul>
<h2>Performance Improvements</h2>
<ul>
<li><strong>Caching:</strong> Built-in response caching with configurable cache timeout and automatic cache cleanup.</li>
<li><strong>Threading:</strong> Thread-safe operations with improved concurrency handling and better resource management.</li>
<li><strong>Memory Management:</strong> Automatic message cleanup, token limit enforcement, and resource optimization.</li>
</ul>
<h2>Best Practices for Migration</h2>
<ol>
<li><strong>Incremental Migration:</strong> Update dependencies first, migrate configuration, update schema definitions, implement new error handling, update state management, add message history, and implement new tools.</li>
<li><strong>Testing:</strong> Test each component after migration, verify error handling, check state management, validate schema compliance, and test concurrent operations.</li>
<li><strong>Monitoring:</strong> Enable debug logging, monitor performance, track error rates, observe memory usage, and check response times.</li>
</ol>
<h2>Additional Resources</h2>
<ul>
<li><a href="https://agnivamaiti.github.io/murmuration/tutorial.html">Examples</a></li>
<li><a href="https://github.com/AgnivaMaiti/murmuration/issues">GitHub Issues</a></li>
</ul>
<p>For any migration issues or questions, please open an issue on GitHub or contact the maintainers.</p>
</div>
<footer>
<p>Created by <strong>Agniva Maiti</strong> © 2025.</p>
</footer>
</body>
</html>