agno 2.4.1__py3-none-any.whl → 2.4.2__py3-none-any.whl

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.
@@ -121,93 +121,86 @@ class FirestoreDb(BaseDb):
121
121
  CollectionReference: The collection reference.
122
122
  """
123
123
  if table_type == "sessions":
124
- if not hasattr(self, "session_collection"):
125
- if self.session_table_name is None:
126
- raise ValueError("Session collection was not provided on initialization")
127
- self.session_collection = self._get_or_create_collection(
128
- collection_name=self.session_table_name,
129
- collection_type="sessions",
130
- create_collection_if_not_found=create_collection_if_not_found,
131
- )
124
+ if self.session_table_name is None:
125
+ raise ValueError("Session collection was not provided on initialization")
126
+ self.session_collection = self._get_or_create_collection(
127
+ collection_name=self.session_table_name,
128
+ collection_type="sessions",
129
+ create_collection_if_not_found=create_collection_if_not_found,
130
+ )
132
131
  return self.session_collection
133
132
 
134
133
  if table_type == "memories":
135
- if not hasattr(self, "memory_collection"):
136
- if self.memory_table_name is None:
137
- raise ValueError("Memory collection was not provided on initialization")
138
- self.memory_collection = self._get_or_create_collection(
139
- collection_name=self.memory_table_name,
140
- collection_type="memories",
141
- create_collection_if_not_found=create_collection_if_not_found,
142
- )
134
+ if self.memory_table_name is None:
135
+ raise ValueError("Memory collection was not provided on initialization")
136
+ self.memory_collection = self._get_or_create_collection(
137
+ collection_name=self.memory_table_name,
138
+ collection_type="memories",
139
+ create_collection_if_not_found=create_collection_if_not_found,
140
+ )
143
141
  return self.memory_collection
144
142
 
145
143
  if table_type == "metrics":
146
- if not hasattr(self, "metrics_collection"):
147
- if self.metrics_table_name is None:
148
- raise ValueError("Metrics collection was not provided on initialization")
149
- self.metrics_collection = self._get_or_create_collection(
150
- collection_name=self.metrics_table_name,
151
- collection_type="metrics",
152
- create_collection_if_not_found=create_collection_if_not_found,
153
- )
144
+ if self.metrics_table_name is None:
145
+ raise ValueError("Metrics collection was not provided on initialization")
146
+ self.metrics_collection = self._get_or_create_collection(
147
+ collection_name=self.metrics_table_name,
148
+ collection_type="metrics",
149
+ create_collection_if_not_found=create_collection_if_not_found,
150
+ )
154
151
  return self.metrics_collection
155
152
 
156
153
  if table_type == "evals":
157
- if not hasattr(self, "eval_collection"):
158
- if self.eval_table_name is None:
159
- raise ValueError("Eval collection was not provided on initialization")
160
- self.eval_collection = self._get_or_create_collection(
161
- collection_name=self.eval_table_name,
162
- collection_type="evals",
163
- create_collection_if_not_found=create_collection_if_not_found,
164
- )
154
+ if self.eval_table_name is None:
155
+ raise ValueError("Eval collection was not provided on initialization")
156
+ self.eval_collection = self._get_or_create_collection(
157
+ collection_name=self.eval_table_name,
158
+ collection_type="evals",
159
+ create_collection_if_not_found=create_collection_if_not_found,
160
+ )
165
161
  return self.eval_collection
166
162
 
167
163
  if table_type == "knowledge":
168
- if not hasattr(self, "knowledge_collection"):
169
- if self.knowledge_table_name is None:
170
- raise ValueError("Knowledge collection was not provided on initialization")
171
- self.knowledge_collection = self._get_or_create_collection(
172
- collection_name=self.knowledge_table_name,
173
- collection_type="knowledge",
174
- create_collection_if_not_found=create_collection_if_not_found,
175
- )
164
+ if self.knowledge_table_name is None:
165
+ raise ValueError("Knowledge collection was not provided on initialization")
166
+ self.knowledge_collection = self._get_or_create_collection(
167
+ collection_name=self.knowledge_table_name,
168
+ collection_type="knowledge",
169
+ create_collection_if_not_found=create_collection_if_not_found,
170
+ )
176
171
  return self.knowledge_collection
177
172
 
178
173
  if table_type == "culture":
179
- if not hasattr(self, "culture_collection"):
180
- if self.culture_table_name is None:
181
- raise ValueError("Culture collection was not provided on initialization")
182
- self.culture_collection = self._get_or_create_collection(
183
- collection_name=self.culture_table_name,
184
- collection_type="culture",
185
- create_collection_if_not_found=create_collection_if_not_found,
186
- )
174
+ if self.culture_table_name is None:
175
+ raise ValueError("Culture collection was not provided on initialization")
176
+ self.culture_collection = self._get_or_create_collection(
177
+ collection_name=self.culture_table_name,
178
+ collection_type="culture",
179
+ create_collection_if_not_found=create_collection_if_not_found,
180
+ )
187
181
  return self.culture_collection
188
182
 
189
183
  if table_type == "traces":
190
- if not hasattr(self, "traces_collection"):
191
- if self.trace_table_name is None:
192
- raise ValueError("Traces collection was not provided on initialization")
193
- self.traces_collection = self._get_or_create_collection(
194
- collection_name=self.trace_table_name,
195
- collection_type="traces",
196
- create_collection_if_not_found=create_collection_if_not_found,
197
- )
184
+ if self.trace_table_name is None:
185
+ raise ValueError("Traces collection was not provided on initialization")
186
+ self.traces_collection = self._get_or_create_collection(
187
+ collection_name=self.trace_table_name,
188
+ collection_type="traces",
189
+ create_collection_if_not_found=create_collection_if_not_found,
190
+ )
198
191
  return self.traces_collection
199
192
 
200
193
  if table_type == "spans":
201
194
  # Ensure traces collection exists first (spans reference traces)
202
- self._get_collection("traces", create_collection_if_not_found=create_collection_if_not_found)
203
- if not hasattr(self, "spans_collection"):
204
- if self.span_table_name is None:
205
- raise ValueError("Spans collection was not provided on initialization")
206
- self.spans_collection = self._get_or_create_collection(
207
- collection_name=self.span_table_name,
208
- collection_type="spans",
209
- create_collection_if_not_found=create_collection_if_not_found,
210
- )
195
+ if create_collection_if_not_found:
196
+ self._get_collection("traces", create_collection_if_not_found=True)
197
+ if self.span_table_name is None:
198
+ raise ValueError("Spans collection was not provided on initialization")
199
+ self.spans_collection = self._get_or_create_collection(
200
+ collection_name=self.span_table_name,
201
+ collection_type="spans",
202
+ create_collection_if_not_found=create_collection_if_not_found,
203
+ )
211
204
  return self.spans_collection
212
205
 
213
206
  raise ValueError(f"Unknown table type: {table_type}")
@@ -282,86 +282,78 @@ class AsyncMySQLDb(AsyncBaseDb):
282
282
 
283
283
  async def _get_table(self, table_type: str, create_table_if_not_found: Optional[bool] = False) -> Table:
284
284
  if table_type == "sessions":
285
- if not hasattr(self, "session_table"):
286
- self.session_table = await self._get_or_create_table(
287
- table_name=self.session_table_name,
288
- table_type="sessions",
289
- create_table_if_not_found=create_table_if_not_found,
290
- )
285
+ self.session_table = await self._get_or_create_table(
286
+ table_name=self.session_table_name,
287
+ table_type="sessions",
288
+ create_table_if_not_found=create_table_if_not_found,
289
+ )
291
290
  return self.session_table
292
291
 
293
292
  if table_type == "memories":
294
- if not hasattr(self, "memory_table"):
295
- self.memory_table = await self._get_or_create_table(
296
- table_name=self.memory_table_name,
297
- table_type="memories",
298
- create_table_if_not_found=create_table_if_not_found,
299
- )
293
+ self.memory_table = await self._get_or_create_table(
294
+ table_name=self.memory_table_name,
295
+ table_type="memories",
296
+ create_table_if_not_found=create_table_if_not_found,
297
+ )
300
298
  return self.memory_table
301
299
 
302
300
  if table_type == "metrics":
303
- if not hasattr(self, "metrics_table"):
304
- self.metrics_table = await self._get_or_create_table(
305
- table_name=self.metrics_table_name,
306
- table_type="metrics",
307
- create_table_if_not_found=create_table_if_not_found,
308
- )
301
+ self.metrics_table = await self._get_or_create_table(
302
+ table_name=self.metrics_table_name,
303
+ table_type="metrics",
304
+ create_table_if_not_found=create_table_if_not_found,
305
+ )
309
306
  return self.metrics_table
310
307
 
311
308
  if table_type == "evals":
312
- if not hasattr(self, "eval_table"):
313
- self.eval_table = await self._get_or_create_table(
314
- table_name=self.eval_table_name,
315
- table_type="evals",
316
- create_table_if_not_found=create_table_if_not_found,
317
- )
309
+ self.eval_table = await self._get_or_create_table(
310
+ table_name=self.eval_table_name,
311
+ table_type="evals",
312
+ create_table_if_not_found=create_table_if_not_found,
313
+ )
318
314
  return self.eval_table
319
315
 
320
316
  if table_type == "knowledge":
321
- if not hasattr(self, "knowledge_table"):
322
- self.knowledge_table = await self._get_or_create_table(
323
- table_name=self.knowledge_table_name,
324
- table_type="knowledge",
325
- create_table_if_not_found=create_table_if_not_found,
326
- )
317
+ self.knowledge_table = await self._get_or_create_table(
318
+ table_name=self.knowledge_table_name,
319
+ table_type="knowledge",
320
+ create_table_if_not_found=create_table_if_not_found,
321
+ )
327
322
  return self.knowledge_table
328
323
 
329
324
  if table_type == "culture":
330
- if not hasattr(self, "culture_table"):
331
- self.culture_table = await self._get_or_create_table(
332
- table_name=self.culture_table_name,
333
- table_type="culture",
334
- create_table_if_not_found=create_table_if_not_found,
335
- )
325
+ self.culture_table = await self._get_or_create_table(
326
+ table_name=self.culture_table_name,
327
+ table_type="culture",
328
+ create_table_if_not_found=create_table_if_not_found,
329
+ )
336
330
  return self.culture_table
337
331
 
338
332
  if table_type == "versions":
339
- if not hasattr(self, "versions_table"):
340
- self.versions_table = await self._get_or_create_table(
341
- table_name=self.versions_table_name,
342
- table_type="versions",
343
- create_table_if_not_found=create_table_if_not_found,
344
- )
333
+ self.versions_table = await self._get_or_create_table(
334
+ table_name=self.versions_table_name,
335
+ table_type="versions",
336
+ create_table_if_not_found=create_table_if_not_found,
337
+ )
345
338
  return self.versions_table
346
339
 
347
340
  if table_type == "traces":
348
- if not hasattr(self, "traces_table"):
349
- self.traces_table = await self._get_or_create_table(
350
- table_name=self.trace_table_name,
351
- table_type="traces",
352
- create_table_if_not_found=create_table_if_not_found,
353
- )
341
+ self.traces_table = await self._get_or_create_table(
342
+ table_name=self.trace_table_name,
343
+ table_type="traces",
344
+ create_table_if_not_found=create_table_if_not_found,
345
+ )
354
346
  return self.traces_table
355
347
 
356
348
  if table_type == "spans":
357
- if not hasattr(self, "spans_table"):
358
- # Ensure traces table exists first (spans has FK to traces)
349
+ # Ensure traces table exists first (spans has FK to traces)
350
+ if create_table_if_not_found:
359
351
  await self._get_table(table_type="traces", create_table_if_not_found=True)
360
- self.spans_table = await self._get_or_create_table(
361
- table_name=self.span_table_name,
362
- table_type="spans",
363
- create_table_if_not_found=create_table_if_not_found,
364
- )
352
+ self.spans_table = await self._get_or_create_table(
353
+ table_name=self.span_table_name,
354
+ table_type="spans",
355
+ create_table_if_not_found=create_table_if_not_found,
356
+ )
365
357
  return self.spans_table
366
358
 
367
359
  raise ValueError(f"Unknown table type: {table_type}")
@@ -285,95 +285,86 @@ class AsyncPostgresDb(AsyncBaseDb):
285
285
 
286
286
  async def _get_table(self, table_type: str, create_table_if_not_found: Optional[bool] = False) -> Table:
287
287
  if table_type == "sessions":
288
- if not hasattr(self, "session_table"):
289
- self.session_table = await self._get_or_create_table(
290
- table_name=self.session_table_name,
291
- table_type="sessions",
292
- create_table_if_not_found=create_table_if_not_found,
293
- )
288
+ self.session_table = await self._get_or_create_table(
289
+ table_name=self.session_table_name,
290
+ table_type="sessions",
291
+ create_table_if_not_found=create_table_if_not_found,
292
+ )
294
293
  return self.session_table
295
294
 
296
295
  if table_type == "memories":
297
- if not hasattr(self, "memory_table"):
298
- self.memory_table = await self._get_or_create_table(
299
- table_name=self.memory_table_name,
300
- table_type="memories",
301
- create_table_if_not_found=create_table_if_not_found,
302
- )
296
+ self.memory_table = await self._get_or_create_table(
297
+ table_name=self.memory_table_name,
298
+ table_type="memories",
299
+ create_table_if_not_found=create_table_if_not_found,
300
+ )
303
301
  return self.memory_table
304
302
 
305
303
  if table_type == "metrics":
306
- if not hasattr(self, "metrics_table"):
307
- self.metrics_table = await self._get_or_create_table(
308
- table_name=self.metrics_table_name,
309
- table_type="metrics",
310
- create_table_if_not_found=create_table_if_not_found,
311
- )
304
+ self.metrics_table = await self._get_or_create_table(
305
+ table_name=self.metrics_table_name,
306
+ table_type="metrics",
307
+ create_table_if_not_found=create_table_if_not_found,
308
+ )
312
309
  return self.metrics_table
313
310
 
314
311
  if table_type == "evals":
315
- if not hasattr(self, "eval_table"):
316
- self.eval_table = await self._get_or_create_table(
317
- table_name=self.eval_table_name,
318
- table_type="evals",
319
- create_table_if_not_found=create_table_if_not_found,
320
- )
312
+ self.eval_table = await self._get_or_create_table(
313
+ table_name=self.eval_table_name,
314
+ table_type="evals",
315
+ create_table_if_not_found=create_table_if_not_found,
316
+ )
321
317
  return self.eval_table
322
318
 
323
319
  if table_type == "knowledge":
324
- if not hasattr(self, "knowledge_table"):
325
- self.knowledge_table = await self._get_or_create_table(
326
- table_name=self.knowledge_table_name,
327
- table_type="knowledge",
328
- create_table_if_not_found=create_table_if_not_found,
329
- )
320
+ self.knowledge_table = await self._get_or_create_table(
321
+ table_name=self.knowledge_table_name,
322
+ table_type="knowledge",
323
+ create_table_if_not_found=create_table_if_not_found,
324
+ )
330
325
  return self.knowledge_table
331
326
 
332
327
  if table_type == "culture":
333
- if not hasattr(self, "culture_table"):
334
- self.culture_table = await self._get_or_create_table(
335
- table_name=self.culture_table_name,
336
- table_type="culture",
337
- create_table_if_not_found=create_table_if_not_found,
338
- )
328
+ self.culture_table = await self._get_or_create_table(
329
+ table_name=self.culture_table_name,
330
+ table_type="culture",
331
+ create_table_if_not_found=create_table_if_not_found,
332
+ )
339
333
  return self.culture_table
340
334
 
341
335
  if table_type == "versions":
342
- if not hasattr(self, "versions_table"):
343
- self.versions_table = await self._get_or_create_table(
344
- table_name=self.versions_table_name,
345
- table_type="versions",
346
- create_table_if_not_found=create_table_if_not_found,
347
- )
336
+ self.versions_table = await self._get_or_create_table(
337
+ table_name=self.versions_table_name,
338
+ table_type="versions",
339
+ create_table_if_not_found=create_table_if_not_found,
340
+ )
348
341
  return self.versions_table
349
342
 
350
343
  if table_type == "traces":
351
- if not hasattr(self, "traces_table"):
352
- self.traces_table = await self._get_or_create_table(
353
- table_name=self.trace_table_name,
354
- table_type="traces",
355
- create_table_if_not_found=create_table_if_not_found,
356
- )
344
+ self.traces_table = await self._get_or_create_table(
345
+ table_name=self.trace_table_name,
346
+ table_type="traces",
347
+ create_table_if_not_found=create_table_if_not_found,
348
+ )
357
349
  return self.traces_table
358
350
 
359
351
  if table_type == "spans":
360
- if not hasattr(self, "spans_table"):
361
- # Ensure traces table exists first (spans has FK to traces)
352
+ # Ensure traces table exists first (spans has FK to traces)
353
+ if create_table_if_not_found:
362
354
  await self._get_table(table_type="traces", create_table_if_not_found=True)
363
- self.spans_table = await self._get_or_create_table(
364
- table_name=self.span_table_name,
365
- table_type="spans",
366
- create_table_if_not_found=create_table_if_not_found,
367
- )
355
+ self.spans_table = await self._get_or_create_table(
356
+ table_name=self.span_table_name,
357
+ table_type="spans",
358
+ create_table_if_not_found=create_table_if_not_found,
359
+ )
368
360
  return self.spans_table
369
361
 
370
362
  if table_type == "learnings":
371
- if not hasattr(self, "learnings_table"):
372
- self.learnings_table = await self._get_or_create_table(
373
- table_name=self.learnings_table_name,
374
- table_type="learnings",
375
- create_table_if_not_found=create_table_if_not_found,
376
- )
363
+ self.learnings_table = await self._get_or_create_table(
364
+ table_name=self.learnings_table_name,
365
+ table_type="learnings",
366
+ create_table_if_not_found=create_table_if_not_found,
367
+ )
377
368
  return self.learnings_table
378
369
 
379
370
  raise ValueError(f"Unknown table type: {table_type}")
@@ -263,95 +263,86 @@ class AsyncSqliteDb(AsyncBaseDb):
263
263
 
264
264
  async def _get_table(self, table_type: str, create_table_if_not_found: Optional[bool] = False) -> Optional[Table]:
265
265
  if table_type == "sessions":
266
- if not hasattr(self, "session_table"):
267
- self.session_table = await self._get_or_create_table(
268
- table_name=self.session_table_name,
269
- table_type=table_type,
270
- create_table_if_not_found=create_table_if_not_found,
271
- )
266
+ self.session_table = await self._get_or_create_table(
267
+ table_name=self.session_table_name,
268
+ table_type=table_type,
269
+ create_table_if_not_found=create_table_if_not_found,
270
+ )
272
271
  return self.session_table
273
272
 
274
273
  elif table_type == "memories":
275
- if not hasattr(self, "memory_table"):
276
- self.memory_table = await self._get_or_create_table(
277
- table_name=self.memory_table_name,
278
- table_type="memories",
279
- create_table_if_not_found=create_table_if_not_found,
280
- )
274
+ self.memory_table = await self._get_or_create_table(
275
+ table_name=self.memory_table_name,
276
+ table_type="memories",
277
+ create_table_if_not_found=create_table_if_not_found,
278
+ )
281
279
  return self.memory_table
282
280
 
283
281
  elif table_type == "metrics":
284
- if not hasattr(self, "metrics_table"):
285
- self.metrics_table = await self._get_or_create_table(
286
- table_name=self.metrics_table_name,
287
- table_type="metrics",
288
- create_table_if_not_found=create_table_if_not_found,
289
- )
282
+ self.metrics_table = await self._get_or_create_table(
283
+ table_name=self.metrics_table_name,
284
+ table_type="metrics",
285
+ create_table_if_not_found=create_table_if_not_found,
286
+ )
290
287
  return self.metrics_table
291
288
 
292
289
  elif table_type == "evals":
293
- if not hasattr(self, "eval_table"):
294
- self.eval_table = await self._get_or_create_table(
295
- table_name=self.eval_table_name,
296
- table_type="evals",
297
- create_table_if_not_found=create_table_if_not_found,
298
- )
290
+ self.eval_table = await self._get_or_create_table(
291
+ table_name=self.eval_table_name,
292
+ table_type="evals",
293
+ create_table_if_not_found=create_table_if_not_found,
294
+ )
299
295
  return self.eval_table
300
296
 
301
297
  elif table_type == "knowledge":
302
- if not hasattr(self, "knowledge_table"):
303
- self.knowledge_table = await self._get_or_create_table(
304
- table_name=self.knowledge_table_name,
305
- table_type="knowledge",
306
- create_table_if_not_found=create_table_if_not_found,
307
- )
298
+ self.knowledge_table = await self._get_or_create_table(
299
+ table_name=self.knowledge_table_name,
300
+ table_type="knowledge",
301
+ create_table_if_not_found=create_table_if_not_found,
302
+ )
308
303
  return self.knowledge_table
309
304
 
310
305
  elif table_type == "culture":
311
- if not hasattr(self, "culture_table"):
312
- self.culture_table = await self._get_or_create_table(
313
- table_name=self.culture_table_name,
314
- table_type="culture",
315
- create_table_if_not_found=create_table_if_not_found,
316
- )
306
+ self.culture_table = await self._get_or_create_table(
307
+ table_name=self.culture_table_name,
308
+ table_type="culture",
309
+ create_table_if_not_found=create_table_if_not_found,
310
+ )
317
311
  return self.culture_table
318
312
 
319
313
  elif table_type == "versions":
320
- if not hasattr(self, "versions_table"):
321
- self.versions_table = await self._get_or_create_table(
322
- table_name=self.versions_table_name,
323
- table_type="versions",
324
- create_table_if_not_found=create_table_if_not_found,
325
- )
314
+ self.versions_table = await self._get_or_create_table(
315
+ table_name=self.versions_table_name,
316
+ table_type="versions",
317
+ create_table_if_not_found=create_table_if_not_found,
318
+ )
326
319
  return self.versions_table
327
320
 
328
321
  elif table_type == "traces":
329
- if not hasattr(self, "traces_table"):
330
- self.traces_table = await self._get_or_create_table(
331
- table_name=self.trace_table_name,
332
- table_type="traces",
333
- create_table_if_not_found=create_table_if_not_found,
334
- )
322
+ self.traces_table = await self._get_or_create_table(
323
+ table_name=self.trace_table_name,
324
+ table_type="traces",
325
+ create_table_if_not_found=create_table_if_not_found,
326
+ )
335
327
  return self.traces_table
336
328
 
337
329
  elif table_type == "spans":
338
- if not hasattr(self, "spans_table"):
339
- # Ensure traces table exists first (spans has FK to traces)
330
+ # Ensure traces table exists first (spans has FK to traces)
331
+ if create_table_if_not_found:
340
332
  await self._get_table(table_type="traces", create_table_if_not_found=True)
341
- self.spans_table = await self._get_or_create_table(
342
- table_name=self.span_table_name,
343
- table_type="spans",
344
- create_table_if_not_found=create_table_if_not_found,
345
- )
333
+ self.spans_table = await self._get_or_create_table(
334
+ table_name=self.span_table_name,
335
+ table_type="spans",
336
+ create_table_if_not_found=create_table_if_not_found,
337
+ )
346
338
  return self.spans_table
347
339
 
348
340
  elif table_type == "learnings":
349
- if not hasattr(self, "learnings_table"):
350
- self.learnings_table = await self._get_or_create_table(
351
- table_name=self.learnings_table_name,
352
- table_type="learnings",
353
- create_table_if_not_found=create_table_if_not_found,
354
- )
341
+ self.learnings_table = await self._get_or_create_table(
342
+ table_name=self.learnings_table_name,
343
+ table_type="learnings",
344
+ create_table_if_not_found=create_table_if_not_found,
345
+ )
355
346
  return self.learnings_table
356
347
 
357
348
  else: