flock-core 0.1.1__py3-none-any.whl → 0.2.1__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.
- flock/__init__.py +1 -4
- flock/agents/__init__.py +0 -3
- flock/agents/batch_agent.py +140 -175
- flock/agents/loop_agent.py +117 -178
- flock/agents/trigger_agent.py +113 -191
- flock/agents/user_agent.py +145 -230
- flock/core/__init__.py +1 -7
- flock/core/context/context.py +211 -0
- flock/core/context/context_manager.py +34 -0
- flock/core/{context_vars.py → context/context_vars.py} +8 -6
- flock/core/execution/local_executor.py +27 -0
- flock/core/execution/temporal_executor.py +40 -0
- flock/core/flock.py +199 -208
- flock/core/flock_agent.py +492 -0
- flock/core/logging/__init__.py +2 -18
- flock/core/logging/formatters/base_formatter.py +36 -0
- flock/core/logging/formatters/formatter_factory.py +38 -0
- flock/core/logging/formatters/pprint_formatter.py +18 -0
- flock/core/logging/formatters/rich_formatters.py +132 -0
- flock/core/logging/formatters/theme_builder.py +480 -0
- flock/core/logging/formatters/themed_formatter.py +442 -0
- flock/core/logging/logging.py +123 -0
- flock/core/mixin/dspy_integration.py +171 -0
- flock/core/mixin/prompt_parser.py +125 -0
- flock/core/registry/agent_registry.py +103 -0
- flock/core/tools/basic_tools.py +273 -98
- flock/core/tools/dev_tools/github.py +161 -0
- flock/core/util/cli_helper.py +21 -0
- flock/core/util/input_resolver.py +156 -0
- flock/core/util/serializable.py +93 -0
- flock/themes/3024-day.toml +39 -0
- flock/themes/3024-night.toml +77 -0
- flock/themes/aardvark-blue.toml +77 -0
- flock/themes/abernathy.toml +77 -0
- flock/themes/adventure.toml +77 -0
- flock/themes/adventuretime.toml +77 -0
- flock/themes/afterglow.toml +77 -0
- flock/themes/alabaster.toml +77 -0
- flock/themes/alienblood.toml +77 -0
- flock/themes/andromeda.toml +77 -0
- flock/themes/apple-classic.toml +77 -0
- flock/themes/apple-system-colors.toml +77 -0
- flock/themes/arcoiris.toml +77 -0
- flock/themes/argonaut copy.toml +77 -0
- flock/themes/argonaut.toml +39 -0
- flock/themes/arthur.toml +77 -0
- flock/themes/ateliersulphurpool.toml +77 -0
- flock/themes/atom.toml +38 -0
- flock/themes/atom_test.toml +65 -0
- flock/themes/atomonelight.toml +77 -0
- flock/themes/aurora.toml +77 -0
- flock/themes/ayu copy.toml +77 -0
- flock/themes/ayu-light.toml +77 -0
- flock/themes/ayu-mirage.toml +77 -0
- flock/themes/ayu.toml +39 -0
- flock/themes/banana-blueberry.toml +77 -0
- flock/themes/batman.toml +77 -0
- flock/themes/belafonte-day.toml +77 -0
- flock/themes/belafonte-night.toml +77 -0
- flock/themes/birdsofparadise.toml +77 -0
- flock/themes/blazer.toml +77 -0
- flock/themes/blue-matrix.toml +77 -0
- flock/themes/blueberrypie.toml +77 -0
- flock/themes/bluedolphin.toml +77 -0
- flock/themes/blulocodark.toml +77 -0
- flock/themes/blulocolight.toml +77 -0
- flock/themes/borland.toml +77 -0
- flock/themes/breeze.toml +77 -0
- flock/themes/bright-lights.toml +77 -0
- flock/themes/broadcast.toml +77 -0
- flock/themes/brogrammer.toml +77 -0
- flock/themes/builtin-dark.toml +77 -0
- flock/themes/builtin-light.toml +77 -0
- flock/themes/builtin-pastel-dark.toml +77 -0
- flock/themes/builtin-solarized-dark.toml +77 -0
- flock/themes/builtin-solarized-light.toml +77 -0
- flock/themes/builtin-tango-dark.toml +77 -0
- flock/themes/builtin-tango-light.toml +77 -0
- flock/themes/c64.toml +77 -0
- flock/themes/calamity.toml +77 -0
- flock/themes/catppuccin-frappe.toml +77 -0
- flock/themes/catppuccin-latte.toml +77 -0
- flock/themes/catppuccin-macchiato.toml +77 -0
- flock/themes/catppuccin-mocha.toml +77 -0
- flock/themes/cga.toml +77 -0
- flock/themes/chalk.toml +77 -0
- flock/themes/chalkboard.toml +77 -0
- flock/themes/challengerdeep.toml +77 -0
- flock/themes/chester.toml +77 -0
- flock/themes/ciapre.toml +77 -0
- flock/themes/clrs.toml +77 -0
- flock/themes/cobalt-neon.toml +77 -0
- flock/themes/cobalt2.toml +77 -0
- flock/themes/coffee-theme.toml +77 -0
- flock/themes/crayonponyfish.toml +77 -0
- flock/themes/cutiepro.toml +77 -0
- flock/themes/cyberdyne.toml +77 -0
- flock/themes/cyberpunk.toml +77 -0
- flock/themes/cyberpunkscarletprotocol.toml +77 -0
- flock/themes/dark+.toml +77 -0
- flock/themes/dark-pastel.toml +77 -0
- flock/themes/darkermatrix.toml +77 -0
- flock/themes/darkmatrix.toml +77 -0
- flock/themes/darkside.toml +77 -0
- flock/themes/dayfox.toml +77 -0
- flock/themes/deep.toml +77 -0
- flock/themes/desert.toml +77 -0
- flock/themes/dimidium.toml +77 -0
- flock/themes/dimmedmonokai.toml +77 -0
- flock/themes/django.toml +77 -0
- flock/themes/djangorebornagain.toml +77 -0
- flock/themes/djangosmooth.toml +77 -0
- flock/themes/doom-peacock.toml +77 -0
- flock/themes/doomone.toml +77 -0
- flock/themes/dotgov.toml +77 -0
- flock/themes/dracula+.toml +77 -0
- flock/themes/dracula.toml +77 -0
- flock/themes/duckbones.toml +77 -0
- flock/themes/duotone-dark.toml +77 -0
- flock/themes/earthsong.toml +77 -0
- flock/themes/elemental.toml +77 -0
- flock/themes/elementary.toml +77 -0
- flock/themes/encom.toml +77 -0
- flock/themes/espresso-libre.toml +77 -0
- flock/themes/espresso.toml +77 -0
- flock/themes/everblush.toml +77 -0
- flock/themes/fahrenheit.toml +77 -0
- flock/themes/fairyfloss.toml +77 -0
- flock/themes/farmhouse-dark.toml +77 -0
- flock/themes/farmhouse-light.toml +77 -0
- flock/themes/fideloper.toml +77 -0
- flock/themes/firefly-traditional.toml +77 -0
- flock/themes/firefoxdev.toml +77 -0
- flock/themes/firewatch.toml +77 -0
- flock/themes/fishtank.toml +77 -0
- flock/themes/flat.toml +77 -0
- flock/themes/flatland.toml +77 -0
- flock/themes/flexoki-dark.toml +77 -0
- flock/themes/flexoki-light.toml +77 -0
- flock/themes/floraverse.toml +77 -0
- flock/themes/forestblue.toml +77 -0
- flock/themes/framer.toml +77 -0
- flock/themes/frontenddelight.toml +77 -0
- flock/themes/funforrest.toml +77 -0
- flock/themes/galaxy.toml +77 -0
- flock/themes/galizur.toml +77 -0
- flock/themes/github-dark.toml +77 -0
- flock/themes/github.toml +77 -0
- flock/themes/glacier.toml +77 -0
- flock/themes/grape.toml +77 -0
- flock/themes/grass.toml +77 -0
- flock/themes/grey-green.toml +77 -0
- flock/themes/gruber-darker.toml +77 -0
- flock/themes/gruvboxdark.toml +77 -0
- flock/themes/gruvboxdarkhard.toml +77 -0
- flock/themes/gruvboxlight.toml +77 -0
- flock/themes/guezwhoz.toml +77 -0
- flock/themes/hacktober.toml +77 -0
- flock/themes/hardcore.toml +77 -0
- flock/themes/harper.toml +77 -0
- flock/themes/hax0r-blue.toml +77 -0
- flock/themes/hax0r-gr33n.toml +77 -0
- flock/themes/hax0r-r3d.toml +77 -0
- flock/themes/highway.toml +77 -0
- flock/themes/hipster-green.toml +77 -0
- flock/themes/hivacruz.toml +77 -0
- flock/themes/homebrew.toml +77 -0
- flock/themes/hopscotch.256.toml +77 -0
- flock/themes/hopscotch.toml +77 -0
- flock/themes/hurtado.toml +77 -0
- flock/themes/hybrid.toml +77 -0
- flock/themes/ic-green-ppl.toml +77 -0
- flock/themes/ic-orange-ppl.toml +77 -0
- flock/themes/iceberg-dark.toml +77 -0
- flock/themes/iceberg-light.toml +77 -0
- flock/themes/idea.toml +77 -0
- flock/themes/idletoes.toml +77 -0
- flock/themes/ir-black.toml +77 -0
- flock/themes/iterm2-dark-background.toml +77 -0
- flock/themes/iterm2-default.toml +77 -0
- flock/themes/iterm2-light-background.toml +77 -0
- flock/themes/iterm2-pastel-dark-background.toml +77 -0
- flock/themes/iterm2-smoooooth.toml +77 -0
- flock/themes/iterm2-solarized-dark.toml +77 -0
- flock/themes/iterm2-solarized-light.toml +77 -0
- flock/themes/iterm2-tango-dark.toml +77 -0
- flock/themes/iterm2-tango-light.toml +77 -0
- flock/themes/jackie-brown.toml +77 -0
- flock/themes/japanesque.toml +77 -0
- flock/themes/jellybeans.toml +77 -0
- flock/themes/jetbrains-darcula.toml +77 -0
- flock/themes/jubi.toml +77 -0
- flock/themes/kanagawabones.toml +77 -0
- flock/themes/kibble.toml +77 -0
- flock/themes/kolorit.toml +77 -0
- flock/themes/konsolas.toml +77 -0
- flock/themes/kurokula.toml +77 -0
- flock/themes/lab-fox.toml +77 -0
- flock/themes/laser.toml +77 -0
- flock/themes/later-this-evening.toml +77 -0
- flock/themes/lavandula.toml +77 -0
- flock/themes/liquidcarbon.toml +77 -0
- flock/themes/liquidcarbontransparent.toml +77 -0
- flock/themes/liquidcarbontransparentinverse.toml +77 -0
- flock/themes/lovelace.toml +77 -0
- flock/themes/man-page.toml +77 -0
- flock/themes/mariana.toml +77 -0
- flock/themes/material.toml +77 -0
- flock/themes/materialdark.toml +77 -0
- flock/themes/materialdarker.toml +77 -0
- flock/themes/materialdesigncolors.toml +77 -0
- flock/themes/materialocean.toml +77 -0
- flock/themes/mathias.toml +77 -0
- flock/themes/matrix.toml +77 -0
- flock/themes/medallion.toml +77 -0
- flock/themes/mellifluous.toml +77 -0
- flock/themes/midnight-in-mojave.toml +77 -0
- flock/themes/mirage.toml +77 -0
- flock/themes/misterioso.toml +77 -0
- flock/themes/molokai.toml +77 -0
- flock/themes/monalisa.toml +77 -0
- flock/themes/monokai-remastered.toml +77 -0
- flock/themes/monokai-soda.toml +77 -0
- flock/themes/monokai-vivid.toml +77 -0
- flock/themes/n0tch2k.toml +77 -0
- flock/themes/neobones-dark.toml +77 -0
- flock/themes/neobones-light.toml +77 -0
- flock/themes/neon.toml +77 -0
- flock/themes/neopolitan.toml +77 -0
- flock/themes/neutron.toml +77 -0
- flock/themes/night-owlish-light.toml +77 -0
- flock/themes/nightfox.toml +77 -0
- flock/themes/nightlion-v1.toml +77 -0
- flock/themes/nightlion-v2.toml +77 -0
- flock/themes/niji.toml +77 -0
- flock/themes/nocturnal-winter.toml +77 -0
- flock/themes/nord-light.toml +77 -0
- flock/themes/nord.toml +77 -0
- flock/themes/novel.toml +77 -0
- flock/themes/nvimdark.toml +77 -0
- flock/themes/nvimlight.toml +77 -0
- flock/themes/obsidian.toml +77 -0
- flock/themes/ocean.toml +77 -0
- flock/themes/oceanic-next.toml +77 -0
- flock/themes/oceanicmaterial.toml +77 -0
- flock/themes/ollie.toml +77 -0
- flock/themes/onehalfdark.toml +77 -0
- flock/themes/onehalflight.toml +77 -0
- flock/themes/operator-mono-dark.toml +77 -0
- flock/themes/overnight-slumber.toml +77 -0
- flock/themes/oxocarbon.toml +77 -0
- flock/themes/palenighthc.toml +77 -0
- flock/themes/pandora.toml +77 -0
- flock/themes/paraiso-dark.toml +77 -0
- flock/themes/paulmillr.toml +77 -0
- flock/themes/pencildark.toml +77 -0
- flock/themes/pencillight.toml +77 -0
- flock/themes/peppermint.toml +77 -0
- flock/themes/piatto-light.toml +77 -0
- flock/themes/pnevma.toml +77 -0
- flock/themes/popping-and-locking.toml +77 -0
- flock/themes/primary.toml +77 -0
- flock/themes/pro-light.toml +77 -0
- flock/themes/pro.toml +77 -0
- flock/themes/purple-rain.toml +77 -0
- flock/themes/purplepeter.toml +77 -0
- flock/themes/rapture.toml +77 -0
- flock/themes/raycast-dark.toml +77 -0
- flock/themes/raycast-light.toml +77 -0
- flock/themes/rebecca.toml +77 -0
- flock/themes/red-alert.toml +77 -0
- flock/themes/red-planet.toml +77 -0
- flock/themes/red-sands.toml +77 -0
- flock/themes/relaxed.toml +77 -0
- flock/themes/retro.toml +77 -0
- flock/themes/rippedcasts.toml +77 -0
- flock/themes/rose-pine-dawn.toml +77 -0
- flock/themes/rose-pine-moon.toml +77 -0
- flock/themes/rose-pine.toml +77 -0
- flock/themes/rouge-2.toml +77 -0
- flock/themes/royal.toml +77 -0
- flock/themes/ryuuko.toml +77 -0
- flock/themes/sakura.toml +77 -0
- flock/themes/scarlet-protocol.toml +77 -0
- flock/themes/seafoam-pastel.toml +77 -0
- flock/themes/seashells.toml +77 -0
- flock/themes/seoulbones-dark.toml +77 -0
- flock/themes/seoulbones-light.toml +77 -0
- flock/themes/seti.toml +77 -0
- flock/themes/shades-of-purple.toml +77 -0
- flock/themes/shaman.toml +77 -0
- flock/themes/slate.toml +77 -0
- flock/themes/sleepyhollow.toml +77 -0
- flock/themes/smyck.toml +77 -0
- flock/themes/snazzy.toml +77 -0
- flock/themes/softserver.toml +77 -0
- flock/themes/solarized-darcula.toml +77 -0
- flock/themes/solarized-dark---patched.toml +77 -0
- flock/themes/solarized-dark-higher-contrast.toml +77 -0
- flock/themes/spacedust.toml +77 -0
- flock/themes/spacegray-eighties-dull.toml +77 -0
- flock/themes/spacegray-eighties.toml +77 -0
- flock/themes/spacegray.toml +77 -0
- flock/themes/spiderman.toml +77 -0
- flock/themes/spring.toml +77 -0
- flock/themes/square.toml +77 -0
- flock/themes/sublette.toml +77 -0
- flock/themes/subliminal.toml +77 -0
- flock/themes/sugarplum.toml +77 -0
- flock/themes/sundried.toml +77 -0
- flock/themes/symfonic.toml +77 -0
- flock/themes/synthwave-everything.toml +77 -0
- flock/themes/synthwave.toml +77 -0
- flock/themes/synthwavealpha.toml +77 -0
- flock/themes/tango-adapted.toml +77 -0
- flock/themes/tango-half-adapted.toml +77 -0
- flock/themes/teerb.toml +77 -0
- flock/themes/terafox.toml +77 -0
- flock/themes/terminal-basic.toml +77 -0
- flock/themes/thayer-bright.toml +77 -0
- flock/themes/the-hulk.toml +77 -0
- flock/themes/tinacious-design-(dark).toml +77 -0
- flock/themes/tinacious-design-(light).toml +77 -0
- flock/themes/tokyonight-day.toml +77 -0
- flock/themes/tokyonight-storm.toml +77 -0
- flock/themes/tokyonight.toml +77 -0
- flock/themes/tomorrow-night-blue.toml +77 -0
- flock/themes/tomorrow-night-bright.toml +77 -0
- flock/themes/tomorrow-night-burns.toml +77 -0
- flock/themes/tomorrow-night-eighties.toml +77 -0
- flock/themes/tomorrow-night.toml +77 -0
- flock/themes/tomorrow.toml +77 -0
- flock/themes/toychest.toml +77 -0
- flock/themes/treehouse.toml +77 -0
- flock/themes/twilight.toml +77 -0
- flock/themes/ubuntu.toml +77 -0
- flock/themes/ultradark.toml +77 -0
- flock/themes/ultraviolent.toml +77 -0
- flock/themes/underthesea.toml +77 -0
- flock/themes/unikitty.toml +77 -0
- flock/themes/urple.toml +77 -0
- flock/themes/vaughn.toml +77 -0
- flock/themes/vesper.toml +77 -0
- flock/themes/vibrantink.toml +77 -0
- flock/themes/vimbones.toml +77 -0
- flock/themes/violet-dark.toml +77 -0
- flock/themes/violet-light.toml +77 -0
- flock/themes/warmneon.toml +77 -0
- flock/themes/wez.toml +77 -0
- flock/themes/whimsy.toml +77 -0
- flock/themes/wildcherry.toml +77 -0
- flock/themes/wilmersdorf.toml +77 -0
- flock/themes/wombat.toml +77 -0
- flock/themes/wryan.toml +77 -0
- flock/themes/xcodedark.toml +77 -0
- flock/themes/xcodedarkhc.toml +77 -0
- flock/themes/xcodelight.toml +77 -0
- flock/themes/xcodelighthc.toml +77 -0
- flock/themes/xcodewwdc.toml +77 -0
- flock/themes/zenbones-dark.toml +77 -0
- flock/themes/zenbones-light.toml +77 -0
- flock/themes/zenbones.toml +77 -0
- flock/themes/zenburn.toml +77 -0
- flock/themes/zenburned.toml +77 -0
- flock/themes/zenwritten-dark.toml +77 -0
- flock/themes/zenwritten-light.toml +77 -0
- flock/workflow/activities.py +117 -115
- flock/workflow/agent_activities.py +24 -26
- flock/workflow/temporal_setup.py +38 -37
- flock/workflow/workflow.py +58 -53
- flock_core-0.2.1.dist-info/METADATA +287 -0
- flock_core-0.2.1.dist-info/RECORD +375 -0
- {flock_core-0.1.1.dist-info → flock_core-0.2.1.dist-info}/licenses/LICENSE +21 -21
- flock/agents/declarative_agent.py +0 -166
- flock/app/components/__init__.py +0 -14
- flock/app/components/charts/agent_workflow.py +0 -14
- flock/app/components/charts/core_architecture.py +0 -14
- flock/app/components/charts/tool_system.py +0 -14
- flock/app/components/history_grid.py +0 -168
- flock/app/components/history_grid_alt.py +0 -189
- flock/app/components/sidebar.py +0 -19
- flock/app/components/theme.py +0 -9
- flock/app/components/util.py +0 -18
- flock/app/hive_app.py +0 -118
- flock/app/html/d3.html +0 -179
- flock/app/modules/__init__.py +0 -12
- flock/app/modules/about.py +0 -17
- flock/app/modules/agent_detail.py +0 -70
- flock/app/modules/agent_list.py +0 -59
- flock/app/modules/playground.py +0 -322
- flock/app/modules/settings.py +0 -96
- flock/core/agent.py +0 -150
- flock/core/agent_registry.py +0 -162
- flock/core/context.py +0 -279
- flock/core/handoff/handoff_base.py +0 -12
- flock/core/logging/error_handler.py +0 -84
- flock/core/logging/formatters.py +0 -122
- flock/core/logging/handlers.py +0 -117
- flock/core/logging/logger.py +0 -107
- flock/core/serializable.py +0 -206
- flock_core-0.1.1.dist-info/METADATA +0 -449
- flock_core-0.1.1.dist-info/RECORD +0 -48
- flock_core-0.1.1.dist-info/entry_points.txt +0 -2
- /flock/{core/config/declarative_agent_config.py → workflow/__init__.py} +0 -0
- {flock_core-0.1.1.dist-info → flock_core-0.2.1.dist-info}/WHEEL +0 -0
flock/workflow/temporal_setup.py
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
import uuid
|
|
3
|
-
|
|
4
|
-
from temporalio.client import Client
|
|
5
|
-
from temporalio.worker import Worker
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
async def create_temporal_client() -> Client:
|
|
9
|
-
client = await Client.connect("localhost:7233")
|
|
10
|
-
return client
|
|
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
|
-
|
|
1
|
+
import asyncio
|
|
2
|
+
import uuid
|
|
3
|
+
|
|
4
|
+
from temporalio.client import Client
|
|
5
|
+
from temporalio.worker import Worker
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def create_temporal_client() -> Client:
|
|
9
|
+
client = await Client.connect("localhost:7233")
|
|
10
|
+
return client
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
async def setup_worker(workflow, activity) -> Client:
|
|
14
|
+
worker_client = await create_temporal_client()
|
|
15
|
+
worker = Worker(worker_client, task_queue="flock-queue", workflows=[workflow], activities=[activity])
|
|
16
|
+
asyncio.create_task(worker.run())
|
|
17
|
+
await asyncio.sleep(1)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async def run_worker(client: Client, task_queue: str, workflows, activities):
|
|
21
|
+
worker = Worker(client, task_queue=task_queue, workflows=workflows, activities=activities)
|
|
22
|
+
await worker.run()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
async def run_activity(client: Client, name: str, func, param):
|
|
26
|
+
run_id = f"{name}_{uuid.uuid4().hex[:4]}"
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
result = await client.execute_activity(
|
|
30
|
+
func,
|
|
31
|
+
param,
|
|
32
|
+
id=run_id,
|
|
33
|
+
task_queue="flock-queue",
|
|
34
|
+
start_to_close_timeout=300, # e.g., 5 minutes
|
|
35
|
+
)
|
|
36
|
+
return result
|
|
37
|
+
except Exception:
|
|
38
|
+
raise
|
flock/workflow/workflow.py
CHANGED
|
@@ -1,53 +1,58 @@
|
|
|
1
|
-
from datetime import timedelta
|
|
2
|
-
|
|
3
|
-
from temporalio import workflow
|
|
4
|
-
|
|
5
|
-
from flock.core.context import FlockContext
|
|
6
|
-
from flock.core.logging import
|
|
7
|
-
from flock.workflow.activities import run_agent
|
|
8
|
-
|
|
9
|
-
# Import activity, passing it through the sandbox without reloading the module
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
self.context
|
|
23
|
-
self.context.
|
|
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
|
-
|
|
1
|
+
from datetime import timedelta
|
|
2
|
+
|
|
3
|
+
from temporalio import workflow
|
|
4
|
+
|
|
5
|
+
from flock.core.context.context import FlockContext
|
|
6
|
+
from flock.core.logging.logging import get_logger
|
|
7
|
+
from flock.workflow.activities import run_agent
|
|
8
|
+
|
|
9
|
+
# Import activity, passing it through the sandbox without reloading the module
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
logger = get_logger("workflow")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@workflow.defn
|
|
16
|
+
class FlockWorkflow:
|
|
17
|
+
def __init__(self) -> None:
|
|
18
|
+
self.context = None
|
|
19
|
+
|
|
20
|
+
@workflow.run
|
|
21
|
+
async def run(self, context_dict: dict) -> dict:
|
|
22
|
+
self.context = FlockContext.from_dict(context_dict)
|
|
23
|
+
self.context.workflow_id = workflow.info().workflow_id
|
|
24
|
+
self.context.workflow_timestamp = workflow.info().start_time.strftime("%Y-%m-%d %H:%M:%S")
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
logger.info(
|
|
28
|
+
"Starting workflow execution",
|
|
29
|
+
timestamp=self.context.workflow_timestamp,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
result = await workflow.execute_activity(
|
|
33
|
+
run_agent,
|
|
34
|
+
self.context,
|
|
35
|
+
start_to_close_timeout=timedelta(minutes=5),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
self.context.set_variable(
|
|
39
|
+
"flock.result",
|
|
40
|
+
{
|
|
41
|
+
"result": result,
|
|
42
|
+
"success": True,
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
logger.success("Workflow completed successfully")
|
|
47
|
+
return result
|
|
48
|
+
|
|
49
|
+
except Exception as e:
|
|
50
|
+
logger.exception("Workflow execution failed", error=str(e))
|
|
51
|
+
self.context.set_variable(
|
|
52
|
+
"flock.result",
|
|
53
|
+
{
|
|
54
|
+
"result": f"Failed: {e}",
|
|
55
|
+
"success": False,
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
return self.context
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flock-core
|
|
3
|
+
Version: 0.2.1
|
|
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: cloudpickle>=3.1.1
|
|
12
|
+
Requires-Dist: devtools>=0.12.2
|
|
13
|
+
Requires-Dist: dspy==2.5.42
|
|
14
|
+
Requires-Dist: httpx>=0.28.1
|
|
15
|
+
Requires-Dist: loguru>=0.7.3
|
|
16
|
+
Requires-Dist: msgpack>=1.1.0
|
|
17
|
+
Requires-Dist: pydantic>=2.10.5
|
|
18
|
+
Requires-Dist: python-box>=7.3.2
|
|
19
|
+
Requires-Dist: rich>=13.9.4
|
|
20
|
+
Requires-Dist: temporalio>=1.9.0
|
|
21
|
+
Requires-Dist: toml>=0.10.2
|
|
22
|
+
Provides-Extra: all-tools
|
|
23
|
+
Requires-Dist: docling>=2.18.0; extra == 'all-tools'
|
|
24
|
+
Requires-Dist: markdownify>=0.14.1; extra == 'all-tools'
|
|
25
|
+
Requires-Dist: tavily-python>=0.5.0; extra == 'all-tools'
|
|
26
|
+
Provides-Extra: tools
|
|
27
|
+
Requires-Dist: markdownify>=0.14.1; extra == 'tools'
|
|
28
|
+
Requires-Dist: tavily-python>=0.5.0; extra == 'tools'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<img src="docs/img/flock.png" width="600"><br>
|
|
33
|
+
<h1 align="center">Flock</h1><br>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
| Traditional Agent Frameworks 🙃 | Flock 🐤🐧🐓🦆 |
|
|
43
|
+
|------------------------------------------|--------------------------------------------------------------|
|
|
44
|
+
| 🤖 **Complex Prompt Engineering** | 📝 **Declarative Agent Definitions** |
|
|
45
|
+
| • Lengthy, brittle prompts | • Clear, concise input/output declarations |
|
|
46
|
+
| • Hard-to-tune and adapt | • No need for manual prompt engineering |
|
|
47
|
+
| | |
|
|
48
|
+
| 💥 **Fragile Execution** | ⚡ **Robust & Scalable** |
|
|
49
|
+
| • Single failure can break the system | • Fault-tolerant with built-in retries and error handling |
|
|
50
|
+
| • Difficult to monitor and recover | • Automatic recovery via Temporal workflow integration |
|
|
51
|
+
| | |
|
|
52
|
+
| 🏗️ **Rigid Workflows** | 🔄 **Flexible Orchestration** |
|
|
53
|
+
| • Limited adaptability | • Dynamic agent chaining and hand-offs |
|
|
54
|
+
| • Hard to scale and parallelize | • Modular, concurrent, and batch processing |
|
|
55
|
+
| | |
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## Key Innovations
|
|
59
|
+
|
|
60
|
+
- **Declarative Agent System:**
|
|
61
|
+
Define agents by declaring their input/output interfaces (with type hints and human-readable descriptions) using a concise syntax.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<img src="docs/img/examples/01_01.png" width="300"><br>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
Example syntax:
|
|
68
|
+
```python
|
|
69
|
+
input = "query: str|The search query, context: dict|The full conversation context"
|
|
70
|
+
output = "idea: str|The generated software project idea"
|
|
71
|
+
```
|
|
72
|
+
The framework automatically extracts type and description details, builds precise prompts, and configures the underlying LLM.
|
|
73
|
+
|
|
74
|
+
- **Lifecycle Hooks:**
|
|
75
|
+
Each agent (via the new `FlockAgent` base class) supports lifecycle hooks such as `initialize()`, `terminate()`, and `on_error()`. This ensures that agents can perform setup, cleanup, and robust error handling—all without cluttering the main business logic.
|
|
76
|
+
|
|
77
|
+
- **Fault Tolerance & Temporal Integration:**
|
|
78
|
+
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.
|
|
79
|
+
|
|
80
|
+
- **Type Safety and Clear Contracts:**
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
- **DSPy Integration:**
|
|
84
|
+
Flock leverages DSPy for managing LLM interactions. The framework constructs clean signature strings and updates field metadata so that DSPy can include detailed instructions and context for each agent call.
|
|
85
|
+
|
|
86
|
+
## Quick Start
|
|
87
|
+
|
|
88
|
+
Below is a simple example of how to create and run an agent with Flock:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import asyncio
|
|
92
|
+
from flock.core.flock import Flock
|
|
93
|
+
from flock.core.agents.flock_agent import FlockAgent
|
|
94
|
+
from flock.core.tools import basic_tools
|
|
95
|
+
|
|
96
|
+
async def main():
|
|
97
|
+
# Initialize Flock
|
|
98
|
+
flock = Flock(model="openai/gpt-4o")
|
|
99
|
+
|
|
100
|
+
# Create an agent with clear input/output declarations and optional tools.
|
|
101
|
+
idea_agent = FlockAgent(
|
|
102
|
+
name="idea_agent",
|
|
103
|
+
input="query: str|The search query, context: dict|Additional context",
|
|
104
|
+
output="a_fun_software_project_idea: str|The generated software project idea",
|
|
105
|
+
tools=[basic_tools.web_search_tavily],
|
|
106
|
+
)
|
|
107
|
+
flock.add_agent(idea_agent)
|
|
108
|
+
|
|
109
|
+
# Run the agent locally (with built-in debugging/logging)
|
|
110
|
+
result = await flock.run_async(
|
|
111
|
+
start_agent=idea_agent,
|
|
112
|
+
input="build a revolutionary app",
|
|
113
|
+
local_debug=True
|
|
114
|
+
)
|
|
115
|
+
print(result)
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
asyncio.run(main())
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Advanced Usage
|
|
122
|
+
|
|
123
|
+
### Agents with Lifecycle Hooks
|
|
124
|
+
|
|
125
|
+
Customize behavior by overriding lifecycle methods:
|
|
126
|
+
|
|
127
|
+
- **initialize(inputs):** Set up resources, validate inputs, or log pre-run state.
|
|
128
|
+
- **terminate(inputs, result):** Clean up resources, log output, or perform post-run actions.
|
|
129
|
+
- **on_error(error, inputs):** Handle exceptions gracefully, log detailed error information, and trigger recovery logic.
|
|
130
|
+
|
|
131
|
+
### Agents with Tools
|
|
132
|
+
|
|
133
|
+
Agents can seamlessly integrate external tools for enhanced functionality:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from flock.core.tools import basic_tools
|
|
137
|
+
|
|
138
|
+
research_agent = FlockAgent(
|
|
139
|
+
name="research_agent",
|
|
140
|
+
input="research_topic: str|Topic to investigate",
|
|
141
|
+
output="research_result: str|The outcome of the research",
|
|
142
|
+
tools=[basic_tools.web_search_tavily],
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Agent Chaining
|
|
147
|
+
|
|
148
|
+
Chain agents together to create complex workflows:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
# Define the first agent in the chain.
|
|
152
|
+
project_plan_agent = FlockAgent(
|
|
153
|
+
name="project_plan_agent",
|
|
154
|
+
input="project_idea: str|Initial project idea",
|
|
155
|
+
output="plan_headings: list[str]|Headings for the project plan",
|
|
156
|
+
tools=[basic_tools.web_search_tavily, basic_tools.code_eval],
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# Define a second agent that builds on the output of the first.
|
|
160
|
+
content_agent = FlockAgent(
|
|
161
|
+
name="content_agent",
|
|
162
|
+
input="context: dict|Global context, project_plan_agent.plan_headings: list[str]|Plan headings",
|
|
163
|
+
output="project_plan_content: str|Detailed content for the plan",
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
# Set up hand-off from the first agent to the second.
|
|
167
|
+
project_plan_agent.hand_off = content_agent
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Temporal Workflow Integration
|
|
171
|
+
|
|
172
|
+
Flock supports execution on Temporal, ensuring robust, fault-tolerant workflows:
|
|
173
|
+
|
|
174
|
+
- **Durability:** Persistent state management even in the case of failures.
|
|
175
|
+
- **Retries & Error Handling:** Automatic recovery via Temporal's built-in mechanisms.
|
|
176
|
+
- **Scalability:** Seamless orchestration of distributed agent workflows.
|
|
177
|
+
|
|
178
|
+
## Architecture
|
|
179
|
+
|
|
180
|
+
TODO: Insert charts
|
|
181
|
+
|
|
182
|
+
## Requirements
|
|
183
|
+
|
|
184
|
+
- Python 3.12+
|
|
185
|
+
- (Optional) Temporal server running locally for production-grade workflow features
|
|
186
|
+
- API keys for integrated services
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
recommended services
|
|
190
|
+
```bash
|
|
191
|
+
export OPENAI_API_KEY=sk-proj-
|
|
192
|
+
export TAVILY_API_KEY=tvly-
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
or in `.env`
|
|
196
|
+
|
|
197
|
+
For LLM interaction LiteLLM is getting used. Please refer to its documentation on how to easily use other models and/or provider.
|
|
198
|
+
|
|
199
|
+
https://docs.litellm.ai/docs/providers
|
|
200
|
+
|
|
201
|
+
## Installation
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pip install flock-core
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
if you want to use the integrated tools
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
pip install flock-core[tools]
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
and for the docling tools
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
pip install flock-core[all-tools]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Development
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
1. **Clone the Repository:**
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
git clone https://github.com/yourusername/flock.git
|
|
226
|
+
cd flock
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
2. **Create a Virtual Environment and sync all packages:**
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
uv sync --all-groups --all-extras
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
3. **Install local version of flock:**
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
uv build && uv pip install -e .
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
## Contributing
|
|
243
|
+
|
|
244
|
+
Contributions are welcome! Please submit Pull Requests and open issues on GitHub.
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
This project is licensed under the terms of the LICENSE file included in the repository.
|
|
249
|
+
|
|
250
|
+
## Acknowledgments
|
|
251
|
+
|
|
252
|
+
- Built with [DSPy](https://github.com/stanfordnlp/dspy)
|
|
253
|
+
- Uses [Temporal](https://temporal.io/) for workflow management
|
|
254
|
+
- Integrates with [Tavily](https://tavily.com/) for web search capabilities
|
|
255
|
+
- Web interface built with FastHTML and MonsterUI
|
|
256
|
+
|
|
257
|
+
## Evolution & Future Direction
|
|
258
|
+
|
|
259
|
+
Flock was created to overcome the limitations of traditional agent frameworks. Key design goals include:
|
|
260
|
+
|
|
261
|
+
### Declarative Over Prompt Engineering
|
|
262
|
+
|
|
263
|
+
- **Simplify Agent Definitions:**
|
|
264
|
+
Focus on clear input/output contracts rather than long, complex prompts.
|
|
265
|
+
- **Model Agnostic:**
|
|
266
|
+
Change LLM backends without altering agent logic.
|
|
267
|
+
- **Improved Testability:**
|
|
268
|
+
Clear, structured interfaces facilitate unit testing and validation.
|
|
269
|
+
|
|
270
|
+
### Robust, Production-Grade Orchestration
|
|
271
|
+
|
|
272
|
+
- **Fault Tolerance:**
|
|
273
|
+
Leveraging Temporal for automatic retries, durable state, and robust error handling.
|
|
274
|
+
- **Scalability:**
|
|
275
|
+
Support for concurrent, batch, and distributed workflows.
|
|
276
|
+
- **Observability:**
|
|
277
|
+
Built-in logging and monitoring for real-time insights into workflow execution.
|
|
278
|
+
|
|
279
|
+
### Future Enhancements
|
|
280
|
+
|
|
281
|
+
- Expanded type system for richer agent interactions
|
|
282
|
+
- Enhanced tool ecosystem and custom integrations
|
|
283
|
+
- Advanced monitoring, debugging, and performance metrics
|
|
284
|
+
- Extended testing frameworks and validation tools
|
|
285
|
+
|
|
286
|
+
Join us in building the next generation of reliable, production-ready AI agent systems!
|
|
287
|
+
|