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/core/tools/basic_tools.py
CHANGED
|
@@ -1,98 +1,273 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
response
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
"""This module contains basic agentic tools for performing various tasks."""
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def web_search_tavily(query: str):
|
|
8
|
+
"""Performs a web search using the Tavily client.
|
|
9
|
+
|
|
10
|
+
This function checks if the optional 'tavily' dependency is installed. If so,
|
|
11
|
+
it creates a TavilyClient using the API key from the environment variable
|
|
12
|
+
'TAVILY_API_KEY' and performs a search with the provided query. The search response
|
|
13
|
+
is returned if successful.
|
|
14
|
+
|
|
15
|
+
Parameters:
|
|
16
|
+
query (str): The search query string.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
Any: The search response obtained from the Tavily client.
|
|
20
|
+
|
|
21
|
+
Raises:
|
|
22
|
+
ImportError: If the 'tavily' dependency is not installed.
|
|
23
|
+
Exception: Re-raises any exceptions encountered during the search.
|
|
24
|
+
"""
|
|
25
|
+
if importlib.util.find_spec("tavily") is not None:
|
|
26
|
+
from tavily import TavilyClient
|
|
27
|
+
|
|
28
|
+
client = TavilyClient(api_key=os.getenv("TAVILY_API_KEY"))
|
|
29
|
+
try:
|
|
30
|
+
response = client.search(query, include_answer=True) # type: ignore
|
|
31
|
+
return response
|
|
32
|
+
except Exception:
|
|
33
|
+
raise
|
|
34
|
+
else:
|
|
35
|
+
raise ImportError("Optional tool dependencies not installed. Install with 'pip install flock-core[tools]'.")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_web_content_as_markdown(url: str):
|
|
39
|
+
"""Fetches web content from a URL and converts it to Markdown.
|
|
40
|
+
|
|
41
|
+
This function uses the 'httpx' library to retrieve the content of the provided URL.
|
|
42
|
+
It then converts the HTML content into Markdown using the 'markdownify' library.
|
|
43
|
+
|
|
44
|
+
Parameters:
|
|
45
|
+
url (str): The URL of the web page to fetch.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
str: The web page content converted into Markdown format.
|
|
49
|
+
|
|
50
|
+
Raises:
|
|
51
|
+
ImportError: If either 'httpx' or 'markdownify' dependencies are not installed.
|
|
52
|
+
Exception: Re-raises any exceptions encountered during the HTTP request or conversion.
|
|
53
|
+
"""
|
|
54
|
+
if importlib.util.find_spec("httpx") is not None and importlib.util.find_spec("markdownify") is not None:
|
|
55
|
+
import httpx
|
|
56
|
+
from markdownify import markdownify as md
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
response = httpx.get(url)
|
|
60
|
+
response.raise_for_status()
|
|
61
|
+
markdown = md(response.text)
|
|
62
|
+
return markdown
|
|
63
|
+
except Exception:
|
|
64
|
+
raise
|
|
65
|
+
else:
|
|
66
|
+
raise ImportError("Optional tool dependencies not installed. Install with 'pip install flock-core[tools]'.")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def get_anything_as_markdown(url_or_file_path: str):
|
|
70
|
+
"""Converts the content of a URL or file into Markdown format.
|
|
71
|
+
|
|
72
|
+
This function leverages the 'docling' library to convert various document types
|
|
73
|
+
(retrieved from a URL or a local file) into Markdown. It uses the DocumentConverter
|
|
74
|
+
from the 'docling.document_converter' module.
|
|
75
|
+
|
|
76
|
+
Parameters:
|
|
77
|
+
url_or_file_path (str): The URL or local file path of the document to convert.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
str: The converted document in Markdown format.
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
ImportError: If the 'docling' dependency is not installed.
|
|
84
|
+
Exception: Re-raises any exceptions encountered during the document conversion.
|
|
85
|
+
"""
|
|
86
|
+
if importlib.util.find_spec("docling") is not None:
|
|
87
|
+
from docling.document_converter import DocumentConverter
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
converter = DocumentConverter()
|
|
91
|
+
result = converter.convert(url_or_file_path)
|
|
92
|
+
markdown = result.document.export_to_markdown()
|
|
93
|
+
return markdown
|
|
94
|
+
except Exception:
|
|
95
|
+
raise
|
|
96
|
+
else:
|
|
97
|
+
raise ImportError("Optional tool dependencies not installed. Install with 'pip install flock-core[all-tools]'.")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def evaluate_math(expression: str) -> float:
|
|
101
|
+
"""Evaluates a mathematical expression using the dspy interpreter.
|
|
102
|
+
|
|
103
|
+
This function uses the 'dspy' library's PythonInterpreter to evaluate the provided
|
|
104
|
+
mathematical expression.
|
|
105
|
+
|
|
106
|
+
Parameters:
|
|
107
|
+
expression (str): A string containing the mathematical expression to evaluate.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
float: The result of the evaluated expression.
|
|
111
|
+
|
|
112
|
+
Raises:
|
|
113
|
+
Exception: Re-raises any exceptions encountered during the evaluation.
|
|
114
|
+
"""
|
|
115
|
+
import dspy
|
|
116
|
+
|
|
117
|
+
try:
|
|
118
|
+
result = dspy.PythonInterpreter({}).execute(expression)
|
|
119
|
+
return result
|
|
120
|
+
except Exception:
|
|
121
|
+
raise
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def code_eval(python_code: str) -> float:
|
|
125
|
+
"""Executes Python code using the dspy interpreter.
|
|
126
|
+
|
|
127
|
+
This function takes a string of Python code, executes it using the 'dspy' PythonInterpreter,
|
|
128
|
+
and returns the result.
|
|
129
|
+
|
|
130
|
+
Parameters:
|
|
131
|
+
python_code (str): A string containing Python code to execute.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
float: The result of the executed code.
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
Exception: Re-raises any exceptions encountered during code execution.
|
|
138
|
+
"""
|
|
139
|
+
import dspy
|
|
140
|
+
|
|
141
|
+
try:
|
|
142
|
+
result = dspy.PythonInterpreter({}).execute(python_code)
|
|
143
|
+
return result
|
|
144
|
+
except Exception:
|
|
145
|
+
raise
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_current_time() -> str:
|
|
149
|
+
"""Retrieves the current time in ISO 8601 format.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
str: The current date and time as an ISO 8601 formatted string.
|
|
153
|
+
"""
|
|
154
|
+
import datetime
|
|
155
|
+
|
|
156
|
+
time = datetime.datetime.now().isoformat()
|
|
157
|
+
return time
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def count_words(text: str) -> int:
|
|
161
|
+
"""Counts the number of words in the provided text.
|
|
162
|
+
|
|
163
|
+
This function splits the input text by whitespace and returns the count of resulting words.
|
|
164
|
+
|
|
165
|
+
Parameters:
|
|
166
|
+
text (str): The text in which to count words.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
int: The number of words in the text.
|
|
170
|
+
"""
|
|
171
|
+
count = len(text.split())
|
|
172
|
+
return count
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def extract_urls(text: str) -> list[str]:
|
|
176
|
+
"""Extracts all URLs from the given text.
|
|
177
|
+
|
|
178
|
+
This function uses a regular expression to find all substrings that match the typical
|
|
179
|
+
URL pattern (starting with http or https).
|
|
180
|
+
|
|
181
|
+
Parameters:
|
|
182
|
+
text (str): The text from which to extract URLs.
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
list[str]: A list of URLs found in the text.
|
|
186
|
+
"""
|
|
187
|
+
import re
|
|
188
|
+
|
|
189
|
+
url_pattern = r"https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+"
|
|
190
|
+
urls = re.findall(url_pattern, text)
|
|
191
|
+
return urls
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def extract_numbers(text: str) -> list[float]:
|
|
195
|
+
"""Extracts all numerical values from the provided text.
|
|
196
|
+
|
|
197
|
+
This function uses a regular expression to find substrings that represent integers or decimals,
|
|
198
|
+
converts them to floats, and returns them as a list.
|
|
199
|
+
|
|
200
|
+
Parameters:
|
|
201
|
+
text (str): The text from which to extract numerical values.
|
|
202
|
+
|
|
203
|
+
Returns:
|
|
204
|
+
list[float]: A list of numbers (as floats) found in the text.
|
|
205
|
+
"""
|
|
206
|
+
import re
|
|
207
|
+
|
|
208
|
+
numbers = [float(x) for x in re.findall(r"-?\d*\.?\d+", text)]
|
|
209
|
+
return numbers
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def json_parse_safe(text: str) -> dict:
|
|
213
|
+
"""Safely parses a JSON string into a dictionary.
|
|
214
|
+
|
|
215
|
+
This function attempts to load a JSON object from the given text. If parsing fails,
|
|
216
|
+
it returns an empty dictionary instead of raising an exception.
|
|
217
|
+
|
|
218
|
+
Parameters:
|
|
219
|
+
text (str): The JSON-formatted string to parse.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
dict: The parsed JSON object as a dictionary, or an empty dictionary if parsing fails.
|
|
223
|
+
"""
|
|
224
|
+
import json
|
|
225
|
+
|
|
226
|
+
try:
|
|
227
|
+
result = json.loads(text)
|
|
228
|
+
return result
|
|
229
|
+
except Exception:
|
|
230
|
+
return {}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def save_to_file(content: str, filename: str):
|
|
234
|
+
"""Saves the given content to a file.
|
|
235
|
+
|
|
236
|
+
This function writes the provided content to a file specified by the filename.
|
|
237
|
+
If the file cannot be written, an exception is raised.
|
|
238
|
+
|
|
239
|
+
Parameters:
|
|
240
|
+
content (str): The content to be saved.
|
|
241
|
+
filename (str): The path to the file where the content will be saved.
|
|
242
|
+
|
|
243
|
+
Raises:
|
|
244
|
+
Exception: Re-raises any exceptions encountered during the file write operation.
|
|
245
|
+
"""
|
|
246
|
+
try:
|
|
247
|
+
with open(filename, "w") as f:
|
|
248
|
+
f.write(content)
|
|
249
|
+
except Exception:
|
|
250
|
+
raise
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def read_from_file(filename: str) -> str:
|
|
254
|
+
"""Reads and returns the content of a file.
|
|
255
|
+
|
|
256
|
+
This function opens the specified file, reads its content, and returns it as a string.
|
|
257
|
+
If the file cannot be read, an exception is raised.
|
|
258
|
+
|
|
259
|
+
Parameters:
|
|
260
|
+
filename (str): The path to the file to be read.
|
|
261
|
+
|
|
262
|
+
Returns:
|
|
263
|
+
str: The content of the file.
|
|
264
|
+
|
|
265
|
+
Raises:
|
|
266
|
+
Exception: Re-raises any exceptions encountered during the file read operation.
|
|
267
|
+
"""
|
|
268
|
+
try:
|
|
269
|
+
with open(filename) as f:
|
|
270
|
+
content = f.read()
|
|
271
|
+
return content
|
|
272
|
+
except Exception:
|
|
273
|
+
raise
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""This module provides tools for interacting with GitHub repositories."""
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def create_user_stories_as_github_issue(title: str, body: str) -> str:
|
|
10
|
+
"""Create a new GitHub issue representing a user story.
|
|
11
|
+
|
|
12
|
+
This function creates an issue in a GitHub repository using the specified title and body.
|
|
13
|
+
The title is used as the issue title, and the body should contain the full user story
|
|
14
|
+
description along with a formatted list of acceptance criteria. The following
|
|
15
|
+
environment variables must be set for this function to work correctly:
|
|
16
|
+
|
|
17
|
+
- GITHUB_PAT: Personal Access Token for GitHub API authentication.
|
|
18
|
+
- GITHUB_REPO: Repository identifier in the format "owner/repo".
|
|
19
|
+
|
|
20
|
+
Parameters:
|
|
21
|
+
title (str): The title for the GitHub issue (user story).
|
|
22
|
+
body (str): The detailed description including acceptance criteria.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
str: A message indicating whether the issue was created successfully or not.
|
|
26
|
+
"""
|
|
27
|
+
github_pat = os.getenv("GITHUB_PAT")
|
|
28
|
+
github_repo = os.getenv("GITHUB_REPO")
|
|
29
|
+
|
|
30
|
+
url = f"https://api.github.com/repos/{github_repo}/issues"
|
|
31
|
+
headers = {
|
|
32
|
+
"Authorization": f"Bearer {github_pat}",
|
|
33
|
+
"Accept": "application/vnd.github+json",
|
|
34
|
+
}
|
|
35
|
+
issue_title = title
|
|
36
|
+
issue_body = body
|
|
37
|
+
|
|
38
|
+
payload = {"title": issue_title, "body": issue_body}
|
|
39
|
+
response = httpx.post(url, json=payload, headers=headers)
|
|
40
|
+
|
|
41
|
+
if response.status_code == 201:
|
|
42
|
+
return "Issue created successfully."
|
|
43
|
+
else:
|
|
44
|
+
return "Failed to create issue. Please try again later."
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def upload_readme(content: str):
|
|
48
|
+
"""Upload or update the README.md file in a GitHub repository.
|
|
49
|
+
|
|
50
|
+
This function uses the GitHub API to either create a new README.md file or update an
|
|
51
|
+
existing one in the specified repository. It encodes the provided content to base64 before
|
|
52
|
+
sending it via the API. The function requires the following environment variables to be set:
|
|
53
|
+
|
|
54
|
+
- GITHUB_USERNAME: Your GitHub username.
|
|
55
|
+
- GITHUB_REPO: The name of the repository.
|
|
56
|
+
- GITHUB_PAT: Your GitHub Personal Access Token for authentication.
|
|
57
|
+
|
|
58
|
+
Parameters:
|
|
59
|
+
content (str): The text content to be written into the README.md file.
|
|
60
|
+
|
|
61
|
+
Raises:
|
|
62
|
+
ValueError: If any of the required environment variables are missing.
|
|
63
|
+
"""
|
|
64
|
+
GITHUB_USERNAME = os.getenv("GITHUB_USERNAME")
|
|
65
|
+
REPO_NAME = os.getenv("GITHUB_REPO")
|
|
66
|
+
GITHUB_TOKEN = os.getenv("GITHUB_PAT")
|
|
67
|
+
|
|
68
|
+
if not GITHUB_USERNAME or not REPO_NAME or not GITHUB_TOKEN:
|
|
69
|
+
raise ValueError("Missing environment variables: GITHUB_USERNAME, GITHUB_REPO, or GITHUB_PAT")
|
|
70
|
+
|
|
71
|
+
GITHUB_API_URL = f"https://api.github.com/repos/{GITHUB_USERNAME}/{REPO_NAME}/contents/README.md"
|
|
72
|
+
|
|
73
|
+
encoded_content = base64.b64encode(content.encode()).decode()
|
|
74
|
+
|
|
75
|
+
with httpx.Client() as client:
|
|
76
|
+
response = client.get(
|
|
77
|
+
GITHUB_API_URL,
|
|
78
|
+
headers={"Authorization": f"token {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3+json"},
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
data = response.json()
|
|
82
|
+
sha = data.get("sha", None)
|
|
83
|
+
|
|
84
|
+
payload = {"message": "Updating README.md", "content": encoded_content, "branch": "main"}
|
|
85
|
+
|
|
86
|
+
if sha:
|
|
87
|
+
payload["sha"] = sha
|
|
88
|
+
|
|
89
|
+
response = client.put(
|
|
90
|
+
GITHUB_API_URL,
|
|
91
|
+
json=payload,
|
|
92
|
+
headers={"Authorization": f"token {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3+json"},
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
if response.status_code in [200, 201]:
|
|
96
|
+
print("README.md successfully uploaded/updated!")
|
|
97
|
+
else:
|
|
98
|
+
print("Failed to upload README.md:", response.json())
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def create_files(file_paths) -> str:
|
|
102
|
+
"""Create multiple files in a GitHub repository with a predefined content.
|
|
103
|
+
|
|
104
|
+
This function iterates over a list of file paths (relative to the repository root) and creates
|
|
105
|
+
each file in the specified GitHub repository with the content "#created by flock". For each file,
|
|
106
|
+
it checks whether the file already exists; if it does, that file is skipped. The function
|
|
107
|
+
uses the following environment variables for authentication and repository information:
|
|
108
|
+
|
|
109
|
+
- GITHUB_USERNAME: Your GitHub username.
|
|
110
|
+
- GITHUB_REPO: The name of the repository.
|
|
111
|
+
- GITHUB_PAT: Your GitHub Personal Access Token for authentication.
|
|
112
|
+
|
|
113
|
+
Parameters:
|
|
114
|
+
file_paths (list of str): A list of file paths (relative to the repository root) to be created.
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
str: A message indicating whether the files were created successfully or if there was a failure.
|
|
118
|
+
"""
|
|
119
|
+
try:
|
|
120
|
+
GITHUB_USERNAME = os.getenv("GITHUB_USERNAME")
|
|
121
|
+
REPO_NAME = os.getenv("GITHUB_REPO")
|
|
122
|
+
GITHUB_TOKEN = os.getenv("GITHUB_PAT")
|
|
123
|
+
|
|
124
|
+
if not GITHUB_USERNAME or not REPO_NAME or not GITHUB_TOKEN:
|
|
125
|
+
raise ValueError("Missing environment variables: GITHUB_USERNAME, GITHUB_REPO, or GITHUB_PAT")
|
|
126
|
+
|
|
127
|
+
encoded_content = base64.b64encode(b"#created by flock").decode()
|
|
128
|
+
|
|
129
|
+
with httpx.Client() as client:
|
|
130
|
+
for file_path in file_paths:
|
|
131
|
+
GITHUB_API_URL = f"https://api.github.com/repos/{GITHUB_USERNAME}/{REPO_NAME}/contents/{file_path}"
|
|
132
|
+
|
|
133
|
+
response = client.get(
|
|
134
|
+
GITHUB_API_URL,
|
|
135
|
+
headers={"Authorization": f"token {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3+json"},
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
data = response.json()
|
|
139
|
+
sha = data.get("sha", None)
|
|
140
|
+
|
|
141
|
+
payload = {"message": f"Creating {file_path}", "content": encoded_content, "branch": "main"}
|
|
142
|
+
|
|
143
|
+
if sha:
|
|
144
|
+
print(f"Skipping {file_path}, file already exists.")
|
|
145
|
+
continue
|
|
146
|
+
|
|
147
|
+
response = client.put(
|
|
148
|
+
GITHUB_API_URL,
|
|
149
|
+
json=payload,
|
|
150
|
+
headers={"Authorization": f"token {GITHUB_TOKEN}", "Accept": "application/vnd.github.v3+json"},
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
if response.status_code in [200, 201]:
|
|
154
|
+
print(f"{file_path} successfully created!")
|
|
155
|
+
else:
|
|
156
|
+
print(f"Failed to create {file_path}:", response.json())
|
|
157
|
+
|
|
158
|
+
return "Files created successfully."
|
|
159
|
+
|
|
160
|
+
except Exception:
|
|
161
|
+
return "Failed to create file. Please try again later."
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from rich.console import Console
|
|
2
|
+
from rich.syntax import Text
|
|
3
|
+
|
|
4
|
+
console = Console()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def display_banner():
|
|
8
|
+
"""Display the Flock banner."""
|
|
9
|
+
banner_text = Text(
|
|
10
|
+
"""
|
|
11
|
+
▒█▀▀▀ █░░ █▀▀█ █▀▀ █░█
|
|
12
|
+
▒█▀▀▀ █░░ █░░█ █░░ █▀▄
|
|
13
|
+
▒█░░░ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀░▀
|
|
14
|
+
""",
|
|
15
|
+
justify="center",
|
|
16
|
+
style="bold orange3",
|
|
17
|
+
)
|
|
18
|
+
console.print(banner_text)
|
|
19
|
+
console.print(
|
|
20
|
+
f"[bold]v0.2.1[/] - [bold]white duck GmbH[/] - [cyan]https://whiteduck.de[/]\n"
|
|
21
|
+
)
|