flock-core 0.4.0b18__py3-none-any.whl → 0.4.0b19__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,572 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: flock-core
3
- Version: 0.4.0b18
4
- Summary: Declarative LLM Orchestration at Scale
5
- Author-email: Andre Ratzenberger <andre.ratzenberger@whiteduck.de>
6
- License-File: LICENSE
7
- Classifier: License :: OSI Approved :: MIT License
8
- Classifier: Operating System :: OS Independent
9
- Classifier: Programming Language :: Python :: 3
10
- Requires-Python: >=3.10
11
- Requires-Dist: azure-search-documents>=11.5.2
12
- Requires-Dist: chromadb>=0.6.3
13
- Requires-Dist: cloudpickle>=3.1.1
14
- Requires-Dist: datasets>=3.2.0
15
- Requires-Dist: devtools>=0.12.2
16
- Requires-Dist: dspy==2.6.16
17
- Requires-Dist: duckduckgo-search>=7.3.2
18
- Requires-Dist: fastapi>=0.115.8
19
- Requires-Dist: httpx>=0.28.1
20
- Requires-Dist: litellm==1.63.7
21
- Requires-Dist: loguru>=0.7.3
22
- Requires-Dist: matplotlib>=3.10.0
23
- Requires-Dist: msgpack>=1.1.0
24
- Requires-Dist: nltk>=3.9.1
25
- Requires-Dist: notion-client>=2.3.0
26
- Requires-Dist: opentelemetry-api>=1.30.0
27
- Requires-Dist: opentelemetry-exporter-jaeger-proto-grpc>=1.21.0
28
- Requires-Dist: opentelemetry-exporter-jaeger>=1.21.0
29
- Requires-Dist: opentelemetry-exporter-otlp>=1.30.0
30
- Requires-Dist: opentelemetry-instrumentation-logging>=0.51b0
31
- Requires-Dist: opentelemetry-sdk>=1.30.0
32
- Requires-Dist: pandas>=2.2.3
33
- Requires-Dist: pillow>=10.4.0
34
- Requires-Dist: prometheus-client>=0.21.1
35
- Requires-Dist: psutil>=6.1.1
36
- Requires-Dist: pydantic-settings>=2.7.1
37
- Requires-Dist: pydantic>=2.10.5
38
- Requires-Dist: python-box>=7.3.2
39
- Requires-Dist: python-decouple>=3.8
40
- Requires-Dist: python-dotenv>=1.0.1
41
- Requires-Dist: python-fasthtml>=0.12.6
42
- Requires-Dist: pyyaml>=6.0
43
- Requires-Dist: questionary>=2.1.0
44
- Requires-Dist: rich>=13.9.4
45
- Requires-Dist: sentence-transformers>=3.4.1
46
- Requires-Dist: temporalio>=1.9.0
47
- Requires-Dist: tiktoken>=0.8.0
48
- Requires-Dist: toml>=0.10.2
49
- Requires-Dist: tqdm>=4.67.1
50
- Requires-Dist: uvicorn>=0.34.0
51
- Requires-Dist: zep-python>=2.0.2
52
- Provides-Extra: all
53
- Requires-Dist: docling>=2.18.0; extra == 'all'
54
- Requires-Dist: markdownify>=0.14.1; extra == 'all'
55
- Requires-Dist: tavily-python>=0.5.0; extra == 'all'
56
- Provides-Extra: tools
57
- Requires-Dist: markdownify>=0.14.1; extra == 'tools'
58
- Requires-Dist: tavily-python>=0.5.0; extra == 'tools'
59
- Description-Content-Type: text/markdown
60
-
61
- <p align="center">
62
- <img src="docs/assets/images/flock.png" width="600"><br>
63
- <img alt="Dynamic TOML Badge" src="https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fwhiteducksoftware%2Fflock%2Frefs%2Fheads%2Fmaster%2Fpyproject.toml&query=%24.project.version&style=for-the-badge&logo=pypi&label=pip%20version">
64
- <a href="https://www.linkedin.com/company/whiteduck" target="_blank"><img alt="LinkedIn" src="https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white&label=whiteduck"></a>
65
- <a href="https://bsky.app/profile/whiteduck-gmbh.bsky.social" target="_blank"><img alt="Bluesky" src="https://img.shields.io/badge/bluesky-Follow-blue?style=for-the-badge&logo=bluesky&logoColor=%23fff&color=%23333&labelColor=%230285FF&label=whiteduck-gmbh"></a>
66
-
67
- 🐤 Flock 0.4.0 currently in beta - use `pip install flock-core==0.4.0b5` 🐤
68
-
69
- 🐤 `pip install flock-core` will install the latest non-beta version 🐤
70
-
71
- 🐤 Expected Release for 0.4.0 `Magpie`: End of April 2025 🐤
72
-
73
-
74
-
75
- ## Overview
76
-
77
- Flock is a framework for orchestrating LLM-powered agents. It leverages a **declarative approach** where you simply specify what each agent needs as input and what it produces as output, without having to write lengthy, brittle prompts. Under the hood, Flock transforms these declarations into robust workflows, using cutting-edge components such as Temporal and DSPy to handle fault tolerance, state management, and error recovery.
78
-
79
-
80
-
81
- | Traditional Agent Frameworks 🙃 | Flock 🐤🐧🐓🦆 |
82
- |------------------------------------------|--------------------------------------------------------------|
83
- | 🤖 **Complex Prompt Engineering** | 📝 **Declarative Agent Definitions** |
84
- | • Lengthy, brittle prompts | • Clear, concise input/output declarations |
85
- | • Hard-to-tune and adapt | • No need for manual prompt engineering |
86
- | | |
87
- | 💥 **Fragile Execution** | ⚡ **Robust & Scalable** |
88
- | • Single failure can break the system | • Fault-tolerant with built-in retries and error handling |
89
- | • Difficult to monitor and recover | • Automatic recovery via Temporal workflow integration |
90
- | | |
91
- | 🏗️ **Rigid Workflows** | 🔄 **Flexible Orchestration** |
92
- | • Limited adaptability | • Dynamic agent chaining and hand-offs |
93
- | • Hard to scale and parallelize | • Modular, concurrent, and batch processing |
94
- | | |
95
-
96
- ## Video Demonstration
97
-
98
-
99
- https://github.com/user-attachments/assets/bdab4786-d532-459f-806a-024727164dcc
100
-
101
- ## Table of Contents
102
-
103
- - [Key Innovations](#key-innovations)
104
- - [Examples](#examples)
105
- - [Hello Flock!](#hello-flock)
106
- - [It's not my type](#its-not-my-type)
107
- - [Being pydantic](#being-pydantic)
108
- - [Building a chain gang!](#building-a-chain-gang)
109
- - [Installation](#installation)
110
-
111
-
112
- ## Key Innovations
113
-
114
- - **Declarative Agent System:**
115
- When you order a pizza at your favorite place, you just tell them what pizza you want, not the 30 steps to get there!
116
- And thanks to an invention called LLMs, we now have the technology to come up with those 30 steps.
117
-
118
- Flock takes advantage of that.
119
-
120
- Define agents by declaring their input/output interfaces (with type hints and human-readable descriptions) using a concise syntax.
121
- The framework automatically extracts type and description details, builds precise prompts, and configures the underlying LLM.
122
-
123
- Testing becomes quite simple as well. You got the pizza you ordered? Passed ✅
124
-
125
- - **Type Safety and Clear Contracts:**
126
- Agents are implemented as Pydantic models. This provides automatic JSON serialization/deserialization, strong typing, and an explicit contract for inputs and outputs. Testing, validation, and integration become straightforward.
127
-
128
- - **Unparalleled Flexibility:**
129
- Each agent (via the new `FlockAgent` base class) supports lifecycle hooks such as `initialize()`, `terminate()`, `evaluate()`, and `on_error()`. This ensures that agents can perform setup, cleanup, and robust error handling—all without cluttering the main business logic. Everything is overridable or lets you provide your own callables per callback. We mean `everything` quite literally. Except for the agent name, literally every property of an agent can be set to a callable, leading to highly dynamic and capable agents.
130
-
131
- - **Fault Tolerance & Temporal Integration:**
132
- Flock is built with production readiness in mind. By integrating with Temporal, your agent workflows enjoy automatic retries, durable state management, and resilience against failures. This means that a single agent crash won't bring down your entire system.
133
-
134
-
135
- <p align="center">
136
- <img src="docs/assets/images//flock_cli.png" width="200"><br>
137
-
138
- ## Examples
139
-
140
- Let's showcase easy to understand examples to give you an idea what flock offers!
141
- All examples and/or similar examples can be found in the examples folder!
142
-
143
- ### Hello Flock!
144
-
145
-
146
- Let's start the most simple way possible 🚀
147
-
148
- ```python
149
-
150
- from flock.core import Flock, FlockAgent
151
-
152
- MODEL = "openai/gpt-4o"
153
-
154
- flock = Flock(model=MODEL, local_debug=True)
155
-
156
- bloggy = FlockAgent(
157
- name="bloggy",
158
- input="blog_idea",
159
- output="funny_blog_title, blog_headers"
160
- )
161
- flock.add_agent(bloggy)
162
-
163
- result = flock.run(
164
- start_agent=bloggy,
165
- input={"blog_idea": "A blog about cats"}
166
- )
167
-
168
- ```
169
-
170
- With almost no boilerplate needed, getting your first agent to run is as easy as cake!
171
-
172
- `bloggy` takes in a `blog_idea` to produce a `funny_blog_title` and `blog_headers`. That is all!
173
-
174
- Flock does take care of the rest, which frees you from needing to write paragraphs of text.
175
- You might think abstracting prompting like this means less control - but nope! Quite the contrary, it'll increase your control over it!
176
-
177
- When we let `bloggy` loose in the flock:
178
-
179
-
180
- ```python
181
- {
182
- 'funny_blog_title': '"Whisker Wonders: The Purr-fect Guide to Cat-tastrophes and Feline Follies"',
183
- 'blog_headers': (
184
- '1. "The Cat\'s Meow: Understanding Your Feline\'s Language"\n'
185
- '2. "Paws and Reflect: The Secret Life of Cats"\n'
186
- '3. "Fur Real: Debunking Myths About Our Furry Friends"\n'
187
- '4. "Claw-some Adventures: How to Entertain Your Indoor Cat"\n'
188
- '5. "Cat-astrophic Cuteness: Why We Can\'t Resist Those Whiskers"\n'
189
- '6. "Tail Tales: The History of Cats and Their Human Companions"\n'
190
- '7. "Purr-sonality Plus: What Your Cat\'s Behavior Says About Them"\n'
191
- '8. "Kitty Conundrums: Solving Common Cat Problems with Humor"'
192
- ),
193
- 'blog_idea': 'A blog about cats',
194
- }
195
- ```
196
-
197
- Look at that! A real Python object with fields exactly as we defined them in the agent.
198
- No need to mess around with parsing or post-processing! 🎉
199
-
200
- ### It's not my type
201
-
202
- You probably noticed that your headers aren't a real Python list, but you need one for your downstream task. Flock got you! Just sprinkle some type hints in your agent definition! ✨
203
-
204
- ```python
205
-
206
- from flock.core import Flock, FlockAgent
207
-
208
- MODEL = "openai/gpt-4o"
209
-
210
- flock = Flock(model=MODEL, local_debug=True)
211
-
212
- bloggy = FlockAgent(
213
- name="bloggy",
214
- input="blog_idea",
215
- output="funny_blog_title, blog_headers: list[str]"
216
- )
217
- flock.add_agent(bloggy)
218
-
219
- result = flock.run(
220
- start_agent=bloggy,
221
- input={"blog_idea": "A blog about cats"}
222
- )
223
-
224
- ```
225
-
226
- Et voila! Now you get:
227
-
228
- ```python
229
- {
230
- 'funny_blog_title': '"Whisker Me This: The Purr-fect Guide to Cat-tastic Adventures"',
231
- 'blog_headers': [
232
- "The Cat's Out of the Bag: Understanding Feline Behavior",
233
- 'Paws and Reflect: The Secret Life of Cats',
234
- 'Feline Fine: Health Tips for Your Kitty',
235
- "Cat-astrophic Cuteness: Why We Can't Resist Them",
236
- 'Meow-sic to Your Ears: Communicating with Your Cat',
237
- 'Claw-some Toys and Games: Keeping Your Cat Entertained',
238
- 'The Tail End: Myths and Facts About Cats',
239
- ],
240
- 'blog_idea': 'A blog about cats',
241
- }
242
-
243
- ```
244
-
245
- ### Being pydantic
246
-
247
- That's not enough for you, since you already got your data classes defined and don't want to redefine them again for some agents?
248
-
249
- Also got some hard constraints, like the title needs to be in ALL CAPS? 🔥
250
-
251
- Check this out:
252
-
253
- ```python
254
- from pydantic import BaseModel, Field
255
-
256
- class BlogSection(BaseModel):
257
- header: str
258
- content: str
259
-
260
- class MyBlog(BaseModel):
261
- funny_blog_title: str = Field(description="The funny blog title in all caps")
262
- blog_sections: list[BlogSection]
263
- ```
264
-
265
- Since flock is bein' pedantic about pydantic, you can just use your pydantic models like you would use type hints:
266
-
267
- ```python
268
- bloggy = FlockAgent(
269
- name="bloggy",
270
- input="blog_idea",
271
- output="blog: MyBlog",
272
- )
273
- ```
274
-
275
- And BAM! Your finished data model filled up to the brim with data! 🎊
276
-
277
-
278
- ```python
279
- {
280
- 'blog': MyBlog(
281
- funny_blog_title='THE PURR-FECT LIFE: CATS AND THEIR QUIRKY ANTICS',
282
- blog_sections=[
283
- BlogSection(
284
- header='Introduction to the Feline World',
285
- content=(
286
- 'Cats have been our companions for thousands of years, yet they remain as mysterious and intriguin'
287
- 'g as ever. From their graceful movements to their independent nature, cats have a unique charm th'
288
- "at captivates us. In this blog, we'll explore the fascinating world of cats and their quirky anti"
289
- 'cs that make them the purr-fect pets.'
290
- ),
291
- ),
292
- BlogSection(
293
- header='The Mysterious Ways of Cats',
294
- content=(
295
- 'Ever wonder why your cat suddenly sprints across the room at 3 AM or stares at a blank wall for h'
296
- 'ours? Cats are known for their mysterious behaviors that often leave us scratching our heads. The'
297
- 'se antics are not just random; they are deeply rooted in their instincts and natural behaviors. L'
298
- "et's dive into some of the most common and puzzling cat behaviors."
299
- ),
300
- ),
301
- BlogSection(
302
- header="The Art of Napping: A Cat's Guide",
303
- content=(
304
- "Cats are the ultimate nappers, spending up to 16 hours a day snoozing. But there's more to a catn"
305
- 'ap than meets the eye. Cats have perfected the art of napping, and each nap serves a purpose, whe'
306
- "ther it's a quick power nap or a deep sleep. Learn how cats choose their napping spots and the sc"
307
- 'ience behind their sleep patterns.'
308
- ),
309
- ),
310
- BlogSection(
311
- header='The Great Cat Conspiracy: Do They Really Rule the World?',
312
- content=(
313
- "It's a well-known fact among cat owners that cats secretly rule the world. With their ability to "
314
- "manipulate humans into providing endless treats and belly rubs, it's no wonder they have us wrapp"
315
- "ed around their little paws. Explore the humorous side of cat ownership and the 'conspiracy' theo"
316
- 'ries that suggest cats are the true overlords of our homes.'
317
- ),
318
- ),
319
- BlogSection(
320
- header='Conclusion: Why We Love Cats',
321
- content=(
322
- 'Despite their quirks and sometimes aloof nature, cats have a special place in our hearts. Their c'
323
- "ompanionship, playful antics, and soothing purrs bring joy and comfort to our lives. Whether you'"
324
- "re a lifelong cat lover or a new cat parent, there's no denying the unique bond we share with our"
325
- " feline friends. So, here's to the purr-fect life with cats!"
326
- ),
327
- ),
328
- ],
329
- ),
330
- 'blog_idea': 'A blog about cats',
331
- }
332
- ```
333
-
334
- ### Building a chain gang
335
-
336
- Our `bloggy` is great, but what if we want to turn those amazing headers into full blog posts? Time to bring in a friend! 🤝
337
- Let's see how easy it is to make agents work together 🔗
338
-
339
- ```python
340
- from flock.core import Flock, FlockAgent
341
-
342
- flock = Flock(model="openai/gpt-4o")
343
-
344
- # First agent: Our trusty bloggy generates titles and headers! 📝
345
- bloggy = FlockAgent(
346
- name="bloggy",
347
- input="blog_idea: str|The topic to blog about",
348
- output=(
349
- "funny_blog_title: str|A catchy title for the blog, "
350
- "blog_headers: list[str]|List of section headers for the blog"
351
- )
352
- )
353
-
354
- # Second agent: The content wizard that brings headers to life! ✨
355
- content_writer = FlockAgent(
356
- name="content_writer",
357
- input=(
358
- "funny_blog_title: str|The blog title to work with, "
359
- "blog_headers: list[str]|The headers to expand into content"
360
- ),
361
- output="blog_sections: list[BlogSection]|The fully written blog sections"
362
- )
363
-
364
- # Make them besties! 🤝
365
- bloggy.hand_off = content_writer
366
-
367
- # Add your dynamic duo to the flock
368
- flock.add_agent(bloggy)
369
- flock.add_agent(content_writer)
370
-
371
- # Let them create some magic! 🎨
372
- result = flock.run(
373
- input={"blog_idea": "A blog about cats"},
374
- start_agent=bloggy
375
- )
376
- ```
377
-
378
- Super simple rules to remember:
379
- 1. Point the first agent to the next one using `hand_off`
380
- 2. Make sure their inputs and outputs match up
381
-
382
- ### Tools of the trade
383
-
384
- Of couse no agent framework is complete without using tools.
385
- Flock enables agents to use any python function you pass as tool or to use one of the plenty default tools
386
-
387
- ```python
388
- bloggy = FlockAgent(
389
- name="bloggy",
390
- input="blog_idea: str|The topic to blog about",
391
- output=(
392
- "funny_blog_title: str|A catchy title for the blog, "
393
- "blog_headers: list[str]|List of section headers for the blog"
394
- "analysis_results: dict[str,Any] | Result of calculated analysis if necessary"
395
- )
396
- tools=[basic_tools.web_search_duckduckgo, basic_tools.code_eval],
397
- )
398
-
399
- result = flock.run(
400
- input={"blog_idea": "A blog about cats, with an analysis how old the oldest cat became in days"},
401
- start_agent=bloggy
402
- )
403
- ```
404
-
405
- These tools are available out of the box (needs `flock-core[tools]`):
406
-
407
- - web_search_tavily
408
- - web_search_duckduckgo
409
- - get_web_content_as_markdown
410
- - get_anything_as_markdown (uses docling and needs `flock-core[all-tools]`)
411
- - evaluate_math
412
- - code_eval
413
- - get_current_time
414
- - count_words
415
- - extract_urls
416
- - extract_numbers
417
- - json_parse_safe
418
- - save_to_file
419
- - read_from_file
420
-
421
-
422
- That's all there is to it! `bloggy` comes up with amazing headers, and `content_writer` turns them into full blog sections. No more writer's block! 🎉
423
-
424
- And this is just the beginning - you can chain as many agents as you want. Maybe add a proofreader? Or add memory? Or an SEO optimizer? But let's not get ahead of ourselves! 😉
425
-
426
- So far we've barely scratched the surface of what flock has to offer, and we're currently hard at work building up the documentation for all the other super cool features Flock has up its sleeve! Stay tuned! 🚀
427
-
428
- ## Temporal Workflow Integration
429
-
430
- Flock supports execution on Temporal, ensuring robust, fault-tolerant workflows:
431
-
432
- - **Durability:** Persistent state management even in the case of failures.
433
- - **Retries & Error Handling:** Automatic recovery via Temporal's built-in mechanisms.
434
- - **Scalability:** Seamless orchestration of distributed agent workflows.
435
-
436
- Documentation in progress!
437
-
438
- ## Architecture
439
-
440
- <img src="docs/assets/images/components_chart.png" width="800"><br>
441
-
442
- <img src="docs/assets/images/flow_chart.png" width="800"><br>
443
-
444
-
445
- ## Requirements
446
-
447
- - Python 3.10+
448
- - (Optional) Temporal server running locally for production-grade workflow features
449
- - API keys for integrated services
450
-
451
-
452
- recommended services
453
- ```bash
454
- export OPENAI_API_KEY=sk-proj-
455
- export TAVILY_API_KEY=tvly-
456
- ```
457
-
458
- or in `.env`
459
-
460
- For LLM interaction LiteLLM is getting used. Please refer to its documentation on how to easily use other models and/or provider.
461
-
462
- https://docs.litellm.ai/docs/providers
463
-
464
- ## Installation
465
-
466
- ```bash
467
- pip install flock-core
468
- ```
469
-
470
- if you want to use the integrated tools
471
-
472
- ```bash
473
- pip install flock-core[tools]
474
- ```
475
-
476
- and for the docling tools
477
-
478
- ```bash
479
- pip install flock-core[all-tools]
480
- ```
481
-
482
- ## Development
483
-
484
-
485
- 1. **Clone the Repository:**
486
-
487
- ```bash
488
- git clone https://github.com/whiteducksoftware/flock
489
- cd flock
490
- ```
491
-
492
- 2. **Create a Virtual Environment and sync all packages:**
493
-
494
- ```bash
495
- uv sync --all-groups --all-extras
496
- ```
497
-
498
- 3. **Install local version of flock:**
499
-
500
- ```bash
501
- uv build && uv pip install -e .
502
- ```
503
-
504
- 4. **Install Jaeger for telemetry**
505
- ```
506
-
507
- docker run -d --name jaeger \
508
- -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
509
- -p 5775:5775/udp \
510
- -p 6831:6831/udp \
511
- -p 6832:6832/udp \
512
- -p 5778:5778 \
513
- -p 16686:16686 \
514
- -p 14268:14268 \
515
- -p 14250:14250 \
516
- -p 9411:9411 \
517
- jaegertracing/all-in-one:1.41
518
-
519
-
520
- ```
521
-
522
- 5. **Create your .env**
523
-
524
- Use `.env_template` as a template for you custom config variables
525
-
526
-
527
- ## Contributing
528
-
529
- Contributions are welcome! Please submit Pull Requests and open issues on GitHub.
530
-
531
- ## License
532
-
533
- This project is licensed under the terms of the LICENSE file included in the repository.
534
-
535
- ## Acknowledgments
536
-
537
- - Built with [DSPy](https://github.com/stanfordnlp/dspy)
538
- - Uses [Temporal](https://temporal.io/) for workflow management
539
- - Integrates with [Tavily](https://tavily.com/) for web search capabilities
540
-
541
- ## Evolution & Future Direction
542
-
543
- Flock was created to overcome the limitations of traditional agent frameworks. Key design goals include:
544
-
545
- ### Declarative Over Prompt Engineering
546
-
547
- - **Simplify Agent Definitions:**
548
- Focus on clear input/output contracts rather than long, complex prompts.
549
- - **Model Agnostic:**
550
- Change LLM backends without altering agent logic.
551
- - **Improved Testability:**
552
- Clear, structured interfaces facilitate unit testing and validation.
553
-
554
- ### Robust, Production-Grade Orchestration
555
-
556
- - **Fault Tolerance:**
557
- Leveraging Temporal for automatic retries, durable state, and robust error handling.
558
- - **Scalability:**
559
- Support for concurrent, batch, and distributed workflows.
560
- - **Observability:**
561
- Built-in logging and monitoring for real-time insights into workflow execution.
562
-
563
- ### Future Enhancements
564
-
565
- - Expanded type system for richer agent interactions
566
- - Enhanced tool ecosystem and custom integrations
567
- - Advanced monitoring, debugging, and performance metrics
568
- - Extended testing frameworks and validation tools
569
-
570
- Join us in building the next generation of reliable, production-ready AI agent systems!
571
- Become part of the FLOCK!
572
-