flock-core 0.4.2__py3-none-any.whl → 0.4.3__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.

Potentially problematic release.


This version of flock-core might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flock-core
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Declarative LLM Orchestration at Scale
5
5
  Author-email: Andre Ratzenberger <andre.ratzenberger@whiteduck.de>
6
6
  License-File: LICENSE
@@ -246,71 +246,299 @@ if __name__ == "__main__":
246
246
  ```
247
247
 
248
248
  ## 🐤 New in Flock 0.4.0 `Magpie` 🐤
249
+ <p align="center">
250
+ <img width="300" alt="image" src="https://github.com/user-attachments/assets/34c2fe2f-6dd2-498c-a826-1687cb158755" />
251
+ </p>
249
252
 
250
- Version 0.4.0 brings significant enhancements focused on usability, deployment, and robustness:
251
253
 
252
254
 
253
- ### 🚀 REST API - Deploy Flock Agents as REST API Endpoints
255
+ ### 🚀 REST API Deploy Flock Agents as REST API Endpoints
254
256
 
255
257
  Easily deploy your Flock agents as scalable REST API endpoints. Interact with your agent workflows via standard HTTP requests.
256
258
 
257
- --------------------------------
259
+ The all-in-one `flock.serve()` method turns your Flock into a proper REST API!
258
260
 
259
- ### 🖥️ Web UI - Test Flock Agents in the Browser
261
+ <img width="1135" alt="image" src="https://github.com/user-attachments/assets/95a58e96-d866-4fd1-aca3-c7635843503c" />
260
262
 
261
- Test and interact with your Flock agents directly in your browser through an integrated web interface.
263
+ Need custom endpoints to wrap abstract agent logic or add business logic? We've got you.
264
+ Define them. Declaratively.
262
265
 
263
- --------------------------------
266
+ ```python
267
+ word_count_route = FlockEndpoint(
268
+ path="/api/word_count",
269
+ methods=["GET"],
270
+ callback=word_count,
271
+ query_model=WordCountParams,
272
+ response_model=WordCountResponse,
273
+ summary="Counts words in a text",
274
+ description="Takes a text and returns the number of words in it.",
275
+ )
264
276
 
265
- ### ⌨️ CLI Tool - Manage Flock Agents via the Command Line
277
+ flock.serve(custom_endpoints=[img_url_route, word_count_route, yoda_route])
278
+ ```
266
279
 
267
- Manage Flock configurations, run agents, and inspect results directly from your command line.
280
+ <img width="1135" alt="image" src="https://github.com/user-attachments/assets/d9315648-ac10-4129-aca4-1cb4c8835672" />
268
281
 
269
- --------------------------------
282
+ Want chat and UI too? Just turn them on.
270
283
 
271
- ### 💾 Enhanced Serialization - Share, Deploy, and Run Flock Agents by human readable yaml files
284
+ ```python
285
+ flock.serve(ui=True, chat=True)
286
+ ```
272
287
 
273
- Define and share entire Flock configurations, including agents and components, using human-readable YAML files. Load flocks directly from these files for easy deployment and versioning.
288
+ ---
274
289
 
275
- --------------------------------
290
+ ### 🖥️ Web UI – Test Flock Agents in the Browser
276
291
 
277
- ### 💾 New execution flows
292
+ Test and interact with your Flock agents directly in your browser using an integrated web interface.
278
293
 
279
- Run Flock in batch mode to process multiple inputs at once or in evaluation mode to test agents with different inputs.
294
+ ![image](https://github.com/user-attachments/assets/5746ae82-757b-43a3-931d-56d19d39371a)
280
295
 
281
- --------------------------------
296
+ Highlights of this feature-rich interface:
282
297
 
283
- ### ⏱️ Robust Temporal Integration
298
+ * Run all your agents and agent flows
299
+ * Chat with your agents
300
+ * Create sharable links – these freeze agent config so testers can focus on evaluation
301
+ * Send direct feedback – includes everything needed to reproduce issues
302
+ * Switch modes – like standalone chat mode, which hides all but the chat
284
303
 
285
- Flock 0.4.0 introduces first-class support for Temporal.io, enabling you to build truly production-grade, reliable, and scalable agent workflows. Move beyond simple local execution and leverage Temporal's power for:
304
+ <img width="1135" alt="image" src="https://github.com/user-attachments/assets/398337ee-e56e-4bce-8bd8-d258c261cb64" />
286
305
 
287
- * **Fault Tolerance:** Workflows automatically resume from the last successful step after failures.
288
- * **Retries:** Configure automatic retries for activities (like LLM calls or tool usage) with exponential backoff.
289
- * **Scalability:** Distribute workflow and activity execution across multiple worker processes using Task Queues.
290
- * **Observability:** Gain deep insights into workflow execution history via the Temporal UI.
306
+ And much, much more... All features are based on real-world client feedback and serve actual business needs.
291
307
 
292
- Flock makes this easy with:
308
+ ---
293
309
 
294
- * **Declarative Configuration:** Define Temporal timeouts, retry policies, and task queues directly within your `Flock` and `FlockAgent` configurations (YAML or Python).
295
- * **Correct Patterns:** Uses Temporal's recommended granular activity execution for better control and visibility.
296
- * **Clear Worker Separation:** Provides guidance and flags for running dedicated Temporal workers, separating development convenience from production best practices.
310
+ ### ⌨️ CLI Tool Manage Flock Agents via Command Line
297
311
 
298
- Visit the [Temporal Documentation](https://learn.temporal.io/python/workflows/) for more information on how to use Temporal.
312
+ Manage configurations, run agents, and inspect results all from your terminal. A quick way to test and validate serialized flocks.
299
313
 
300
- Or check out the [Flock Showcase](https://github.com/whiteducksoftware/flock-showcase) for a complete example of a Flock that uses Temporal or our [docs](https://whiteducksoftware.github.io/flock/guides/temporal-configuration/) for more information.
314
+ ![image](https://github.com/user-attachments/assets/9370e7e8-94c3-4e26-8c7e-46ff2edd667a)
301
315
 
302
- Here's an example of how to configure a Flock to use Temporal:
316
+ ---
303
317
 
304
- ```python
305
- from flock.core import Flock, FlockFactory
318
+ ### 💾 Enhanced Serialization – Share, Deploy, and Run Flocks from YAML
319
+
320
+ Define and share entire Flock configurations using readable YAML files. Perfect for versioning, deployment, and portability.
321
+
322
+ Take note how even custom types like `FantasyCharacter` are serialized so the target system doesn't even need your code! Everything portable!
323
+
324
+ ```yaml
325
+ name: pydantic_example
326
+ model: openai/gpt-4o
327
+ enable_temporal: false
328
+ enable_logging: false
329
+ show_flock_banner: false
330
+ temporal_start_in_process_worker: true
331
+ agents:
332
+ character_agent:
333
+ name: character_agent
334
+ model: openai/gpt-4o
335
+ description: Generates fantasy RPG character profiles for a specified number of
336
+ characters.
337
+ input: 'number_of_characters: int | The number of fantasy character profiles to
338
+ generate.'
339
+ output: 'character_list: list[FantasyCharacter] | A list containing the generated
340
+ character profiles.'
341
+ write_to_file: false
342
+ wait_for_input: false
343
+ evaluator:
344
+ name: default
345
+ config:
346
+ model: openai/gpt-4o
347
+ use_cache: true
348
+ temperature: 0.8
349
+ max_tokens: 8192
350
+ stream: false
351
+ include_thought_process: false
352
+ kwargs: {}
353
+ type: DeclarativeEvaluator
354
+ modules:
355
+ output:
356
+ name: output
357
+ config:
358
+ enabled: true
359
+ theme: abernathy
360
+ render_table: false
361
+ max_length: 1000
362
+ truncate_long_values: true
363
+ show_metadata: true
364
+ format_code_blocks: true
365
+ custom_formatters: {}
366
+ no_output: false
367
+ print_context: false
368
+ type: OutputModule
369
+ metrics:
370
+ name: metrics
371
+ config:
372
+ enabled: true
373
+ collect_timing: true
374
+ collect_memory: true
375
+ collect_token_usage: true
376
+ collect_cpu: true
377
+ storage_type: json
378
+ metrics_dir: metrics/
379
+ aggregation_interval: 1h
380
+ retention_days: 30
381
+ alert_on_high_latency: true
382
+ latency_threshold_ms: 30000
383
+ type: MetricsModule
384
+ types:
385
+ FantasyCharacter:
386
+ module_path: __main__
387
+ type: pydantic.BaseModel
388
+ schema:
389
+ description: 'Data model for fantasy RPG character information.
390
+
391
+ Docstrings and Field descriptions can help guide the LLM.'
392
+ properties:
393
+ name:
394
+ description: A creative fantasy character name.
395
+ title: Name
396
+ type: string
397
+ race:
398
+ description: The character's race.
399
+ enum:
400
+ - human
401
+ - elf
402
+ - dwarf
403
+ - orc
404
+ - halfling
405
+ title: Race
406
+ type: string
407
+ class_type:
408
+ description: The character's class.
409
+ enum:
410
+ - warrior
411
+ - mage
412
+ - rogue
413
+ - cleric
414
+ - ranger
415
+ title: Class Type
416
+ type: string
417
+ level:
418
+ description: Character level
419
+ title: Level
420
+ type: integer
421
+ strength:
422
+ description: Strength stat
423
+ title: Strength
424
+ type: integer
425
+ dexterity:
426
+ description: Dexterity stat
427
+ title: Dexterity
428
+ type: integer
429
+ constitution:
430
+ description: Constitution stat
431
+ title: Constitution
432
+ type: integer
433
+ intelligence:
434
+ description: Intelligence stat
435
+ title: Intelligence
436
+ type: integer
437
+ wisdom:
438
+ description: Wisdom stat
439
+ title: Wisdom
440
+ type: integer
441
+ charisma:
442
+ description: Charisma stat
443
+ title: Charisma
444
+ type: integer
445
+ weapons:
446
+ description: A list of weapons the character carries.
447
+ items:
448
+ type: string
449
+ title: Weapons
450
+ type: array
451
+ backstory:
452
+ description: A brief, engaging backstory (2-3 sentences).
453
+ title: Backstory
454
+ type: string
455
+ motivation:
456
+ description: The character's motivation for their adventuring.
457
+ title: Motivation
458
+ type: string
459
+ alignment:
460
+ description: Character's moral alignment
461
+ title: Alignment
462
+ type: string
463
+ required:
464
+ - name
465
+ - race
466
+ - class_type
467
+ - level
468
+ - strength
469
+ - dexterity
470
+ - constitution
471
+ - intelligence
472
+ - wisdom
473
+ - charisma
474
+ - weapons
475
+ - backstory
476
+ - motivation
477
+ - alignment
478
+ type: object
479
+ components:
480
+ DeclarativeEvaluator:
481
+ type: flock_component
482
+ module_path: flock.evaluators.declarative.declarative_evaluator
483
+ file_path: src\\flock\\evaluators\\declarative\\declarative_evaluator.py
484
+ description: Evaluator that uses DSPy for generation.
485
+ OutputModule:
486
+ type: flock_component
487
+ module_path: flock.modules.output.output_module
488
+ file_path: src\\flock\\modules\\output\\output_module.py
489
+ description: Module that handles output formatting and display.
490
+ MetricsModule:
491
+ type: flock_component
492
+ module_path: flock.modules.performance.metrics_module
493
+ file_path: src\\flock\\modules\\performance\\metrics_module.py
494
+ description: Module for collecting and analyzing agent performance metrics.
495
+ dependencies:
496
+ - pydantic>=2.0.0
497
+ - flock-core>=0.4.0
498
+ metadata:
499
+ path_type: relative
500
+ flock_version: 0.4.0
501
+
502
+ ```
503
+
504
+ Why is text-based serialization cool? Because agents can manipulate their own config – go wild with meta agents and experiments.
505
+
506
+ ---
507
+
508
+ ### 🌀 New Execution Flows – Batch and Evaluation Modes
509
+
510
+ Run Flock in batch mode to process multiple inputs or in evaluation mode to benchmark agents against question/answer pairs.
306
511
 
307
- from flock.workflow.temporal_config import (
308
- TemporalActivityConfig,
309
- TemporalRetryPolicyConfig,
310
- TemporalWorkflowConfig,
512
+ ```python
513
+ batch_data = [
514
+ {"topic": "Robot Kittens", "audience": "Tech Enthusiasts"},
515
+ {"topic": "AI in Gardening", "audience": "Homeowners"},
516
+ ...
517
+ ]
518
+
519
+ static_data = {"number_of_slides": 6}
520
+
521
+ silent_results = flock.run_batch(
522
+ start_agent=presentation_agent,
523
+ batch_inputs=batch_data,
524
+ static_inputs=static_data,
525
+ parallel=True,
526
+ max_workers=5,
527
+ silent_mode=True,
528
+ return_errors=True,
529
+ write_to_csv=".flock/batch_results.csv",
311
530
  )
531
+ ```
532
+
533
+ Supports CSV in and out. Combine with `.evaluate()` to benchmark Flock with known Q/A sets.
312
534
 
313
- # Flock-scoped temporal config
535
+ ---
536
+
537
+ ### ⏱️ First-Class Temporal Integration
538
+
539
+ Flock 0.4.0 brings seamless integration with Temporal.io. Build production-grade, reliable, and scalable agent workflows.
540
+
541
+ ```python
314
542
  flock = Flock(
315
543
  enable_temporal=True,
316
544
  temporal_config=TemporalWorkflowConfig(
@@ -321,56 +549,40 @@ flock = Flock(
321
549
  ),
322
550
  ),
323
551
  )
324
-
325
- # Agent-scoped temporal config
326
- content_agent = FlockFactory.create_default_agent(
327
- name="content_agent",
328
- input="funny_title, funny_slide_headers",
329
- output="funny_slide_content",
330
- temporal_activity_config=TemporalActivityConfig(
331
- start_to_close_timeout=timedelta(minutes=1),
332
- retry_policy=TemporalRetryPolicyConfig(
333
- maximum_attempts=4,
334
- initial_interval=timedelta(seconds=2),
335
- non_retryable_error_types=["ValueError"],
336
- ),
337
- ),
338
- )
339
552
  ```
340
553
 
341
- --------------------------------
554
+ Just set a flag. Add your constraints. Now you've got retry policies, timeout control, and error handling baked in.
342
555
 
343
- ### ✨ Utility: @flockclass Hydrator
556
+ ---
557
+
558
+ ### ✨ Utility – @flockclass Hydrator
344
559
 
345
- Flock also provides conveniences. The @flockclass decorator allows you to easily populate Pydantic models using an LLM:
560
+ Flock also adds conveniences. With `@flockclass`, you can turn any Pydantic model into a self-hydrating agent.
346
561
 
347
562
  ```python
348
563
  from pydantic import BaseModel
349
- from flock.util.hydrator import flockclass # Assuming hydrator utility exists
350
- import asyncio
564
+ from flock.util.hydrator import flockclass
351
565
 
352
- @flockclass(model="openai/gpt-4o") # Decorate your Pydantic model
566
+ @flockclass(model="openai/gpt-4o")
353
567
  class CharacterIdea(BaseModel):
354
568
  name: str
355
569
  char_class: str
356
570
  race: str
357
- backstory_hook: str | None = None # Field to be filled by hydrate
358
- personality_trait: str | None = None # Field to be filled by hydrate
571
+ backstory_hook: str | None = None
572
+ personality_trait: str | None = None
359
573
 
360
574
  async def create_character():
361
- # Create with minimal data
362
575
  char = CharacterIdea(name="Gorok", char_class="Barbarian", race="Orc")
363
576
  print(f"Before Hydration: {char}")
364
577
 
365
- # Call hydrate to fill in the None fields using the LLM
366
578
  hydrated_char = await char.hydrate()
367
579
 
368
580
  print(f"\nAfter Hydration: {hydrated_char}")
369
581
  print(f"Backstory Hook: {hydrated_char.backstory_hook}")
370
-
371
- # asyncio.run(create_character())
372
582
  ```
373
583
 
584
+
585
+
374
586
  --------------------------------
375
587
 
376
588
  ## 📚 Examples & Tutorials
@@ -537,8 +537,8 @@ flock/workflow/agent_execution_activity.py,sha256=Gy6FtuVAjf0NiUXmC3syS2eJpNQF4R
537
537
  flock/workflow/flock_workflow.py,sha256=iSUF_soFvWar0ffpkzE4irkDZRx0p4HnwmEBi_Ne2sY,9666
538
538
  flock/workflow/temporal_config.py,sha256=3_8O7SDEjMsSMXsWJBfnb6XTp0TFaz39uyzSlMTSF_I,3988
539
539
  flock/workflow/temporal_setup.py,sha256=YIHnSBntzOchHfMSh8hoLeNXrz3B1UbR14YrR6soM7A,1606
540
- flock_core-0.4.2.dist-info/METADATA,sha256=ICkzNC7SBmBQH3YeS92II8lHdoeji9ZBjLVrVnZ79i8,17713
541
- flock_core-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
542
- flock_core-0.4.2.dist-info/entry_points.txt,sha256=rWaS5KSpkTmWySURGFZk6PhbJ87TmvcFQDi2uzjlagQ,37
543
- flock_core-0.4.2.dist-info/licenses/LICENSE,sha256=iYEqWy0wjULzM9GAERaybP4LBiPeu7Z1NEliLUdJKSc,1072
544
- flock_core-0.4.2.dist-info/RECORD,,
540
+ flock_core-0.4.3.dist-info/METADATA,sha256=s-gnLa039PeivFnWS7dFxPYXMonOMy9ggumdRfvfGFI,22703
541
+ flock_core-0.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
542
+ flock_core-0.4.3.dist-info/entry_points.txt,sha256=rWaS5KSpkTmWySURGFZk6PhbJ87TmvcFQDi2uzjlagQ,37
543
+ flock_core-0.4.3.dist-info/licenses/LICENSE,sha256=iYEqWy0wjULzM9GAERaybP4LBiPeu7Z1NEliLUdJKSc,1072
544
+ flock_core-0.4.3.dist-info/RECORD,,