flock-core 0.4.0b46__py3-none-any.whl → 0.4.0b49__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 +45 -3
- flock/core/flock.py +105 -61
- flock/core/flock_registry.py +45 -38
- flock/core/util/spliter.py +4 -0
- flock/evaluators/__init__.py +1 -0
- flock/evaluators/declarative/__init__.py +1 -0
- flock/modules/__init__.py +1 -0
- flock/modules/assertion/__init__.py +1 -0
- flock/modules/callback/__init__.py +1 -0
- flock/modules/mem0/__init__.py +1 -0
- flock/modules/mem0/mem0_module.py +63 -0
- flock/modules/mem0graph/__init__.py +1 -0
- flock/modules/mem0graph/mem0_graph_module.py +63 -0
- flock/modules/memory/__init__.py +1 -0
- flock/modules/output/__init__.py +1 -0
- flock/modules/performance/__init__.py +1 -0
- flock/tools/__init__.py +188 -0
- flock/{core/tools → tools}/azure_tools.py +284 -0
- flock/tools/code_tools.py +56 -0
- flock/tools/file_tools.py +140 -0
- flock/{core/tools/dev_tools/github.py → tools/github_tools.py} +3 -3
- flock/{core/tools → tools}/markdown_tools.py +14 -4
- flock/tools/system_tools.py +9 -0
- flock/{core/tools/llm_tools.py → tools/text_tools.py} +47 -25
- flock/tools/web_tools.py +90 -0
- flock/{core/tools → tools}/zendesk_tools.py +6 -6
- flock/webapp/app/api/execution.py +130 -30
- flock/webapp/app/chat.py +303 -16
- flock/webapp/app/config.py +15 -1
- flock/webapp/app/dependencies.py +22 -0
- flock/webapp/app/main.py +509 -18
- flock/webapp/app/services/flock_service.py +38 -13
- flock/webapp/app/services/sharing_models.py +43 -0
- flock/webapp/app/services/sharing_store.py +156 -0
- flock/webapp/static/css/chat.css +57 -0
- flock/webapp/templates/chat.html +29 -4
- flock/webapp/templates/partials/_chat_messages.html +1 -1
- flock/webapp/templates/partials/_chat_settings_form.html +22 -0
- flock/webapp/templates/partials/_execution_form.html +28 -1
- flock/webapp/templates/partials/_share_chat_link_snippet.html +11 -0
- flock/webapp/templates/partials/_share_link_snippet.html +35 -0
- flock/webapp/templates/shared_run_page.html +116 -0
- flock/workflow/activities.py +1 -0
- {flock_core-0.4.0b46.dist-info → flock_core-0.4.0b49.dist-info}/METADATA +27 -14
- {flock_core-0.4.0b46.dist-info → flock_core-0.4.0b49.dist-info}/RECORD +48 -28
- flock/core/tools/basic_tools.py +0 -317
- flock/modules/zep/zep_module.py +0 -187
- {flock_core-0.4.0b46.dist-info → flock_core-0.4.0b49.dist-info}/WHEEL +0 -0
- {flock_core-0.4.0b46.dist-info → flock_core-0.4.0b49.dist-info}/entry_points.txt +0 -0
- {flock_core-0.4.0b46.dist-info → flock_core-0.4.0b49.dist-info}/licenses/LICENSE +0 -0
flock/workflow/activities.py
CHANGED
|
@@ -27,6 +27,7 @@ async def run_agent(context: FlockContext) -> dict:
|
|
|
27
27
|
# Start a top-level span for the entire run_agent activity.
|
|
28
28
|
with tracer.start_as_current_span("run_agent") as span:
|
|
29
29
|
registry = get_registry()
|
|
30
|
+
|
|
30
31
|
previous_agent_name = ""
|
|
31
32
|
if isinstance(context, dict):
|
|
32
33
|
context = FlockContext.from_dict(context)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flock-core
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.0b49
|
|
4
4
|
Summary: Declarative LLM Orchestration at Scale
|
|
5
5
|
Author-email: Andre Ratzenberger <andre.ratzenberger@whiteduck.de>
|
|
6
6
|
License-File: LICENSE
|
|
@@ -8,22 +8,23 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
8
8
|
Classifier: Operating System :: OS Independent
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Requires-Python: >=3.10
|
|
11
|
-
Requires-Dist:
|
|
11
|
+
Requires-Dist: aiosqlite>=0.21.0
|
|
12
12
|
Requires-Dist: chromadb>=0.6.3
|
|
13
13
|
Requires-Dist: cloudpickle>=3.1.1
|
|
14
14
|
Requires-Dist: datasets>=3.2.0
|
|
15
15
|
Requires-Dist: devtools>=0.12.2
|
|
16
|
-
Requires-Dist: dspy==2.6.
|
|
17
|
-
Requires-Dist: duckduckgo-search>=7.3.2
|
|
16
|
+
Requires-Dist: dspy==2.6.23
|
|
18
17
|
Requires-Dist: fastapi>=0.115.8
|
|
19
18
|
Requires-Dist: httpx>=0.28.1
|
|
20
19
|
Requires-Dist: inspect-ai>=0.3.88
|
|
21
|
-
Requires-Dist: litellm==1.
|
|
20
|
+
Requires-Dist: litellm==1.69.3
|
|
22
21
|
Requires-Dist: loguru>=0.7.3
|
|
22
|
+
Requires-Dist: markdown2>=2.5.3
|
|
23
23
|
Requires-Dist: matplotlib>=3.10.0
|
|
24
|
+
Requires-Dist: mem0ai[graph]>=0.1.100
|
|
24
25
|
Requires-Dist: msgpack>=1.1.0
|
|
25
|
-
Requires-Dist: nltk>=3.9.1
|
|
26
26
|
Requires-Dist: notion-client>=2.3.0
|
|
27
|
+
Requires-Dist: openai==1.75.0
|
|
27
28
|
Requires-Dist: opentelemetry-api>=1.30.0
|
|
28
29
|
Requires-Dist: opentelemetry-exporter-jaeger-proto-grpc>=1.21.0
|
|
29
30
|
Requires-Dist: opentelemetry-exporter-jaeger>=1.21.0
|
|
@@ -49,14 +50,26 @@ Requires-Dist: tiktoken>=0.8.0
|
|
|
49
50
|
Requires-Dist: toml>=0.10.2
|
|
50
51
|
Requires-Dist: tqdm>=4.67.1
|
|
51
52
|
Requires-Dist: uvicorn>=0.34.0
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Requires-Dist:
|
|
55
|
-
Requires-Dist:
|
|
56
|
-
Requires-Dist:
|
|
57
|
-
|
|
58
|
-
Requires-Dist: markdownify>=0.14.1; extra == 'tools'
|
|
59
|
-
Requires-Dist:
|
|
53
|
+
Provides-Extra: all-tools
|
|
54
|
+
Requires-Dist: azure-identity>=1.23.0; extra == 'all-tools'
|
|
55
|
+
Requires-Dist: azure-search-documents>=11.5.2; extra == 'all-tools'
|
|
56
|
+
Requires-Dist: azure-storage-blob>=12.25.1; extra == 'all-tools'
|
|
57
|
+
Requires-Dist: docling>=2.18.0; extra == 'all-tools'
|
|
58
|
+
Requires-Dist: duckduckgo-search>=7.3.2; extra == 'all-tools'
|
|
59
|
+
Requires-Dist: markdownify>=0.14.1; extra == 'all-tools'
|
|
60
|
+
Requires-Dist: nltk>=3.9.1; extra == 'all-tools'
|
|
61
|
+
Requires-Dist: tavily-python>=0.5.0; extra == 'all-tools'
|
|
62
|
+
Provides-Extra: azure-tools
|
|
63
|
+
Requires-Dist: azure-identity>=1.23.0; extra == 'azure-tools'
|
|
64
|
+
Requires-Dist: azure-search-documents>=11.5.2; extra == 'azure-tools'
|
|
65
|
+
Requires-Dist: azure-storage-blob>=12.25.1; extra == 'azure-tools'
|
|
66
|
+
Provides-Extra: basic-tools
|
|
67
|
+
Requires-Dist: docling>=2.18.0; extra == 'basic-tools'
|
|
68
|
+
Requires-Dist: duckduckgo-search>=7.3.2; extra == 'basic-tools'
|
|
69
|
+
Requires-Dist: markdownify>=0.14.1; extra == 'basic-tools'
|
|
70
|
+
Requires-Dist: tavily-python>=0.5.0; extra == 'basic-tools'
|
|
71
|
+
Provides-Extra: llm-tools
|
|
72
|
+
Requires-Dist: nltk>=3.9.1; extra == 'llm-tools'
|
|
60
73
|
Description-Content-Type: text/markdown
|
|
61
74
|
|
|
62
75
|
<p align="center">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
flock/__init__.py,sha256=
|
|
1
|
+
flock/__init__.py,sha256=jg2kcXIi1isxTtYdoQGgk0NYSA-BC0J6Xqy41viWpFg,7834
|
|
2
2
|
flock/config.py,sha256=9aUYglHavosdTS212WXW9qc_snZVimvxaXZ3Z5NDGWM,1923
|
|
3
3
|
flock/cli/config.py,sha256=5DvFLObOx3ObisHnc9JfnUBnK83y0CBsUQzXfxPZve0,138
|
|
4
4
|
flock/cli/constants.py,sha256=ZyXtTW91P1hUMkbMwmOwp_JEL5e9-YkcuM3vHM5glP4,978
|
|
@@ -19,12 +19,12 @@ flock/cli/view_results.py,sha256=dOzK0O1FHSIDERnx48y-2Xke9BkOHS7pcOhs64AyIg0,781
|
|
|
19
19
|
flock/cli/yaml_editor.py,sha256=K3N0bh61G1TSDAZDnurqW9e_-hO6CtSQKXQqlDhCjVo,12527
|
|
20
20
|
flock/cli/assets/release_notes.md,sha256=bqnk50jxM3w5uY44Dc7MkdT8XmRREFxrVBAG9XCOSSU,4896
|
|
21
21
|
flock/core/__init__.py,sha256=p7lmQULRu9ejIAELfanZiyMhW0CougIPvyFHW2nqBFQ,847
|
|
22
|
-
flock/core/flock.py,sha256=
|
|
22
|
+
flock/core/flock.py,sha256=1U1on8aMuCjFNAkQQMyWk7vNa0FqttWDFqoqQ1QlhEc,35674
|
|
23
23
|
flock/core/flock_agent.py,sha256=-gEfBKWc569ynqNdy7Gc1iqBrCYPHmC8qvzXkxTi5m4,41115
|
|
24
24
|
flock/core/flock_evaluator.py,sha256=dOXZeDOGZcAmJ9ahqq_2bdGUU1VOXY4skmwTVpAjiVw,1685
|
|
25
25
|
flock/core/flock_factory.py,sha256=_4zsjkEmJnCR7IvJ3SUHnDbX6c7Tt3E4P5ohxwKvE6w,3173
|
|
26
26
|
flock/core/flock_module.py,sha256=UCK6TFe4viXs596zeng0GD3gln4ZNGu_gCWkXIIMREg,3090
|
|
27
|
-
flock/core/flock_registry.py,sha256=
|
|
27
|
+
flock/core/flock_registry.py,sha256=WKfIYXowrtblQ0HIko2zGMU8FqkSxjgIxta_ywXaekk,25764
|
|
28
28
|
flock/core/flock_router.py,sha256=1OAXDsdaIIFApEfo6SRfFEDoTuGt3Si7n2MXiySEfis,2644
|
|
29
29
|
flock/core/api/__init__.py,sha256=KdzUwBOwhxqqy7lAMLpysKL5GvpIiwOy6CxXELZVWaY,186
|
|
30
30
|
flock/core/api/custom_endpoint.py,sha256=Mbk2owdcXVATaT5FtEWXFzllgursozcmqP8ouG5btc0,1305
|
|
@@ -67,30 +67,35 @@ flock/core/serialization/json_encoder.py,sha256=gAKj2zU_8wQiNvdkby2hksSA4fbPNwTj
|
|
|
67
67
|
flock/core/serialization/secure_serializer.py,sha256=n5-zRvvXddgJv1FFHsaQ2wuYdL3WUSGPvG_LGaffEJo,6144
|
|
68
68
|
flock/core/serialization/serializable.py,sha256=qlv8TsTqRuklXiNuCMrvro5VKz764xC2i3FlgLJSkdk,12129
|
|
69
69
|
flock/core/serialization/serialization_utils.py,sha256=AHRf90trgnj2Q6aaGaq5eja5PRcuJANUsp2wafGUeig,15257
|
|
70
|
-
flock/core/tools/azure_tools.py,sha256=hwLnI2gsEq6QzUoWj5eCGDKTdXY1XUf6K-H5Uwva2MY,17093
|
|
71
|
-
flock/core/tools/basic_tools.py,sha256=Ye7nlI4RRkqWRy8nH9CKuItBmh_ZXxUpouGnCOfx0s0,9050
|
|
72
|
-
flock/core/tools/llm_tools.py,sha256=Bdt4Dpur5dGpxd2KFEQyxjfZazvW1HCDKY6ydMj6UgQ,21811
|
|
73
|
-
flock/core/tools/markdown_tools.py,sha256=W6fGM48yGHbifVlaOk1jOtVcybfRbRmf20VbDOZv8S4,6031
|
|
74
|
-
flock/core/tools/zendesk_tools.py,sha256=deZAyUi9j-_yZaTayLQVJaFXIqIct-P6C8IGN5UU_tM,3528
|
|
75
|
-
flock/core/tools/dev_tools/github.py,sha256=a2OTPXS7kWOVA4zrZHynQDcsmEi4Pac5MfSjQOLePzA,5308
|
|
76
70
|
flock/core/util/cli_helper.py,sha256=g4u8kCtbwHRXETzBz1cw52_8muSWbWlr00CqST525jI,49963
|
|
77
71
|
flock/core/util/file_path_utils.py,sha256=Odf7uU32C-x1KNighbNERSiMtkzW4h8laABIoFK7A5M,6246
|
|
78
72
|
flock/core/util/hydrator.py,sha256=QJvCA8F4nkSP5akp3yg0cT6oaajOr1n7sldW5dCs6Lo,10733
|
|
79
73
|
flock/core/util/input_resolver.py,sha256=KPoPSpklyCoiR2t5r6J6GJHegmPLFZ0YE126VcKBewM,4703
|
|
80
74
|
flock/core/util/loader.py,sha256=j3q2qem5bFMP2SmMuYjb-ISxsNGNZd1baQmpvAnRUUk,2244
|
|
81
|
-
flock/core/util/spliter.py,sha256=
|
|
75
|
+
flock/core/util/spliter.py,sha256=cXgxrD-v6LqfCMp87BPRQq6C_BF6CJmMmug1WgwBosQ,6972
|
|
76
|
+
flock/evaluators/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
77
|
+
flock/evaluators/declarative/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
82
78
|
flock/evaluators/declarative/declarative_evaluator.py,sha256=q3qKHuKrj17mhaoOZuKh2HyVfiDBEEUk1Y1ZrejvggA,6328
|
|
83
79
|
flock/evaluators/memory/memory_evaluator.py,sha256=ySwz7kcc8suXMJ7gKNSWThW8iOMlE8lUcUzEAHvv8rw,3559
|
|
84
80
|
flock/evaluators/test/test_case_evaluator.py,sha256=3Emcoty0LOLLBIuPGxSpKphuZC9Fu1DTr1vbGg-hd0Q,1233
|
|
85
81
|
flock/evaluators/zep/zep_evaluator.py,sha256=6_5vTdU0yJAH8I8w3-MPXiAZx6iUPhAVCsHjrHzkPLM,2058
|
|
82
|
+
flock/modules/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
83
|
+
flock/modules/assertion/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
86
84
|
flock/modules/assertion/assertion_module.py,sha256=2p9mIj8yBXRGgfe5pUWYXcLT86Ny13KyWHpRhe0Ehtg,12877
|
|
85
|
+
flock/modules/callback/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
87
86
|
flock/modules/callback/callback_module.py,sha256=FnTYQeL828uQgYlpgGUnwCz0OzW_DKdOnQ3nwQCcu5o,2956
|
|
87
|
+
flock/modules/mem0/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
88
|
+
flock/modules/mem0/mem0_module.py,sha256=KEGWURXcqB4aRUVUcje8Tua2JOcYOHIbC4TkZQ6cvJo,2043
|
|
89
|
+
flock/modules/mem0graph/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
90
|
+
flock/modules/mem0graph/mem0_graph_module.py,sha256=ni1pu5sj2Qk13H-alWFjmwhIwG9_48gje59ZvVpn788,2012
|
|
91
|
+
flock/modules/memory/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
88
92
|
flock/modules/memory/memory_module.py,sha256=zxdA8RIwhwYIytB8bY0VW32j6xDToUuP9RRgk_mpCwo,15046
|
|
89
93
|
flock/modules/memory/memory_parser.py,sha256=FLH7GL8XThvHiCMfX3eQH7Sz-f62fzhAUmO6_gaDI7U,4372
|
|
90
94
|
flock/modules/memory/memory_storage.py,sha256=CNcLDMmvv0x7Z3YMKr6VveS_VCa7rKPw8l2d-XgqokA,27246
|
|
95
|
+
flock/modules/output/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
91
96
|
flock/modules/output/output_module.py,sha256=gEn1_khPAJp-hqU6Rxdv1sQz0jTLVSzYJvNbK1uVNCY,7402
|
|
97
|
+
flock/modules/performance/__init__.py,sha256=Y0cEkx0dujRmy--TDpKoTqFSLzbyFz8BwEOv8kdSUhg,22
|
|
92
98
|
flock/modules/performance/metrics_module.py,sha256=j4_xY4HTz_MsaduFCk7mmQAzFtDZ9pTgPxKTEW-d8fE,16993
|
|
93
|
-
flock/modules/zep/zep_module.py,sha256=EIs0EMDrmE--rmmkjj7vLhE-pgR_b3uRHp0dc8DiZMc,6135
|
|
94
99
|
flock/platform/docker_tools.py,sha256=fpA7-6rJBjPOUBLdQP4ny2QPgJ_042nmqRn5GtKnoYw,1445
|
|
95
100
|
flock/platform/jaeger_install.py,sha256=MyOMJQx4TQSMYvdUJxfiGSo3YCtsfkbNXcAcQ9bjETA,2898
|
|
96
101
|
flock/routers/__init__.py,sha256=w9uL34Auuo26-q_EGlE8Z9iHsw6S8qutTAH_ZI7pn7M,39
|
|
@@ -440,42 +445,55 @@ flock/themes/zenburn.toml,sha256=NxOAR3cx-Z9PVErEKHFZ6jsjfKBtPmfyN_vGSri5_qo,171
|
|
|
440
445
|
flock/themes/zenburned.toml,sha256=UEmquBbcAO3Zj652XKUwCsNoC2iQSlIh-q5c6DH-7Kc,1664
|
|
441
446
|
flock/themes/zenwritten-dark.toml,sha256=To5l6520_3UqAGiEumpzGWsHhXxqu9ThrMildXKgIO0,1669
|
|
442
447
|
flock/themes/zenwritten-light.toml,sha256=G1iEheCPfBNsMTGaVpEVpDzYBHA_T-MV27rolUYolmE,1666
|
|
448
|
+
flock/tools/__init__.py,sha256=rVCbfZvX_prgSwSbX9i5oCN0nt3jASusXsksVPU70A8,5098
|
|
449
|
+
flock/tools/azure_tools.py,sha256=OTJsb0B4l70GcD1W3ZMDHWd3X8nEnszhhz2sllD2z9E,30187
|
|
450
|
+
flock/tools/code_tools.py,sha256=CRDi3iIN4NQcgz4TJ4b-thFq7uXW_gIXPk-iEoWhF4E,1356
|
|
451
|
+
flock/tools/file_tools.py,sha256=zbXo5SxyKYLvrE7k3vLF5tGxCeuaeJtCCdWQ1fXJMAA,4626
|
|
452
|
+
flock/tools/github_tools.py,sha256=HH47-4K3HL6tRJhZhUttWDo2aloP9Hs12wRC_f_-Vkc,5329
|
|
453
|
+
flock/tools/markdown_tools.py,sha256=94fjGAJ5DEutoioD0ke-YRbxF6IWJQKuPVBLkNqdBo4,6345
|
|
454
|
+
flock/tools/system_tools.py,sha256=IUB8MiSxtQH5ZfTGOck3vl4TKva8m1lfU4-W5D5b-4w,202
|
|
455
|
+
flock/tools/text_tools.py,sha256=mMQ8tkyYDxIorqqzl9ccGyWYjrSynYiYFIeP9qypfdg,22491
|
|
456
|
+
flock/tools/web_tools.py,sha256=Wl3qO5lKq4PYtmYahgeFGBQ8tDC0uKY4k9A1Zn-MqFw,2588
|
|
457
|
+
flock/tools/zendesk_tools.py,sha256=HQ7qBVSrRfemwolz0IOXl8Z02vJCLE6mTd-cARVdX88,3576
|
|
443
458
|
flock/webapp/__init__.py,sha256=YtRbbyciN3Z2oMB9fdXZuvM3e49R8m2mY5qHLDoapRA,37
|
|
444
459
|
flock/webapp/run.py,sha256=Ekg-mQSl7RUDJAEDTBJMIlLyvhWqWPMjg8hPqmgFREE,8945
|
|
445
460
|
flock/webapp/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
446
|
-
flock/webapp/app/chat.py,sha256=
|
|
447
|
-
flock/webapp/app/config.py,sha256=
|
|
448
|
-
flock/webapp/app/dependencies.py,sha256=
|
|
449
|
-
flock/webapp/app/main.py,sha256=
|
|
461
|
+
flock/webapp/app/chat.py,sha256=AcVwgq4SQyOQnx0rheJVuR0Pp8u6Dc15YH2aMfIdK2Q,25943
|
|
462
|
+
flock/webapp/app/config.py,sha256=RVMvgOKRKKzE0T95UVai75iDXajTzV6mlPUhnW3Wloo,4812
|
|
463
|
+
flock/webapp/app/dependencies.py,sha256=JUcwY1N6SZplU141lMN2wk9dOC9er5HCedrKTJN9wJk,5533
|
|
464
|
+
flock/webapp/app/main.py,sha256=pVxu2w4h6QNKzi6AO-k_aHjhOS6lPYwCY0IdGIIPqy0,53784
|
|
450
465
|
flock/webapp/app/models_ui.py,sha256=vrEBLbhEp6FziAgBSFOLT1M7ckwadsTdT7qus5_NduE,329
|
|
451
466
|
flock/webapp/app/theme_mapper.py,sha256=QzWwLWpED78oYp3FjZ9zxv1KxCyj43m8MZ0fhfzz37w,34302
|
|
452
467
|
flock/webapp/app/utils.py,sha256=RF8DMKKAj1XPmm4txUdo2OdswI1ATQ7cqUm6G9JFDzA,2942
|
|
453
468
|
flock/webapp/app/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
454
469
|
flock/webapp/app/api/agent_management.py,sha256=5xqO94QjjAYvxImyjKV9EGUQOvo4n3eqs7pGwGPSQJ4,10394
|
|
455
|
-
flock/webapp/app/api/execution.py,sha256=
|
|
470
|
+
flock/webapp/app/api/execution.py,sha256=DO2dljCXa4zwedRbtjU_QiCTP-KRVSbFknUKpVcHBuk,13013
|
|
456
471
|
flock/webapp/app/api/flock_management.py,sha256=1o-6-36kTnUjI3am_BqLpdrcz0aqFXrxE-hQHIFcCsg,4869
|
|
457
472
|
flock/webapp/app/api/registry_viewer.py,sha256=IoInxJiRR0yFlecG_l2_eRc6l35RQQyEDMG9BcBkipY,1020
|
|
458
473
|
flock/webapp/app/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
459
|
-
flock/webapp/app/services/flock_service.py,sha256=
|
|
474
|
+
flock/webapp/app/services/flock_service.py,sha256=G4JQBC6WFO4ajjvZSbedZvlgczsD5fKdbMHVzhG_IaY,14970
|
|
475
|
+
flock/webapp/app/services/sharing_models.py,sha256=hXbi0gy2ARNKBoURRR3ZJSm7Uq5ID1YEgBfzFuhnB3A,2054
|
|
476
|
+
flock/webapp/app/services/sharing_store.py,sha256=jGuPpy4VwXEf1qEn4cQ9p_qkgkBOl3AwhDfyDB3mSRs,7049
|
|
460
477
|
flock/webapp/app/templates/theme_mapper.html,sha256=z8ZY7nmk6PiUGzD_-px7wSXcEnuBM121rMq6u-2oaCo,14249
|
|
461
|
-
flock/webapp/static/css/chat.css,sha256=
|
|
478
|
+
flock/webapp/static/css/chat.css,sha256=jbq1w2BrA9y5R6dPM2ZSXCLDCff82OCPS1F_excYN5E,8167
|
|
462
479
|
flock/webapp/static/css/components.css,sha256=WnicEHy3ptPzggKmyG9_oZp3X30EMJBUW3KEXaiUCUE,6018
|
|
463
480
|
flock/webapp/static/css/header.css,sha256=E9MgItZCk34S65NfMJ001ZsRz4oyFSJex8KvINMtCn0,1043
|
|
464
481
|
flock/webapp/static/css/layout.css,sha256=ocDd7dmezdQzNAQDuQSv1xZ8-pcbNgYLUYJB1SKcfvw,1526
|
|
465
482
|
flock/webapp/static/css/sidebar.css,sha256=gCwLTAiIvmHGksm0rHDpMsOGCDKBMxqx_aEc8ZQcQF8,3066
|
|
466
483
|
flock/webapp/templates/base.html,sha256=013TyI0TvzyvjnIhEr3ZgJYSAIVQK2ayPAngdi0hF18,4937
|
|
467
|
-
flock/webapp/templates/chat.html,sha256=
|
|
484
|
+
flock/webapp/templates/chat.html,sha256=CieTTl1RWG0uyltrBthblPBzNDx061WUE1x79UxT2Og,4294
|
|
468
485
|
flock/webapp/templates/chat_settings.html,sha256=nYz6ihYAUA9zN-Jru565QNl8_eJdoLMWC2LdZJtZ-20,862
|
|
469
486
|
flock/webapp/templates/flock_editor.html,sha256=ysDExf9zMj4SMsSXZUpCtG9EjIv8VJ5xL4IJQOMlb7o,542
|
|
470
487
|
flock/webapp/templates/index.html,sha256=eK7s5Cnh63unqPwq9NGZGEKyvYwkhudfmSn9su3Ctyg,412
|
|
471
488
|
flock/webapp/templates/registry_viewer.html,sha256=suAiWDvBxJ8SsF9MhheuN6MMQUZuIhTlurmbFOcYJfI,3235
|
|
489
|
+
flock/webapp/templates/shared_run_page.html,sha256=uB04jvhGISgpXl-zTJ1lbFTze9mQQXFmkYSZcx43PUc,6429
|
|
472
490
|
flock/webapp/templates/partials/_agent_detail_form.html,sha256=oLz17lmv8s-DI9lOxODLJpc57NRUPmnLlOqxyDFYTDE,6015
|
|
473
491
|
flock/webapp/templates/partials/_agent_list.html,sha256=comYjOeUxQvlJzS-3D4OruJKlhC3uhCgo-X-nqiOhkA,1037
|
|
474
492
|
flock/webapp/templates/partials/_agent_manager_view.html,sha256=oUJ-t2Mk3o4xjQ_HtHz0glgaHM8eqZpPB4i24ToJiJ8,2565
|
|
475
493
|
flock/webapp/templates/partials/_agent_tools_checklist.html,sha256=T60fb7OrJYHUw0hJLC_otskgvbH9dZXbv5klgWBkSWk,686
|
|
476
494
|
flock/webapp/templates/partials/_chat_container.html,sha256=n4MzCHAYvTw7rpINIW1dw7LgMSC0ifRORTU47We0p4s,804
|
|
477
|
-
flock/webapp/templates/partials/_chat_messages.html,sha256=
|
|
478
|
-
flock/webapp/templates/partials/_chat_settings_form.html,sha256
|
|
495
|
+
flock/webapp/templates/partials/_chat_messages.html,sha256=zJ7Qbi7bcbrjyfncOd3OKImhZ1APWELOQADWJvWGVQc,600
|
|
496
|
+
flock/webapp/templates/partials/_chat_settings_form.html,sha256=JAO1OXw654WusY871MtjfxAeSuraBEH_taf1tQ2zKhA,4479
|
|
479
497
|
flock/webapp/templates/partials/_create_flock_form.html,sha256=nQVbuTWqOQ59q5zyGXkuBixikvCkaZIPVW8CRF6wCm0,2806
|
|
480
498
|
flock/webapp/templates/partials/_dashboard_flock_detail.html,sha256=c7srF0nL8ETmP0ATsIxF8MMHMtHVXJqWVzdrnu2i-1Q,1012
|
|
481
499
|
flock/webapp/templates/partials/_dashboard_flock_file_list.html,sha256=hevhRzK94tHJC6j8_iLc0ORCOb0wEYHCpRWecXB-5io,795
|
|
@@ -483,7 +501,7 @@ flock/webapp/templates/partials/_dashboard_flock_properties_preview.html,sha256=
|
|
|
483
501
|
flock/webapp/templates/partials/_dashboard_upload_flock_form.html,sha256=lQxR75yLgeRdm1vSkpGGgkhhfQ5JQvu14jx1y-QZUAM,956
|
|
484
502
|
flock/webapp/templates/partials/_dynamic_input_form_content.html,sha256=WYr2M7Mb5vKITFhIVXXEHppRx9IjGew91yLo1_I9kkI,1230
|
|
485
503
|
flock/webapp/templates/partials/_env_vars_table.html,sha256=6TFUWvkYwzwodqXZ0yJhH_NU6L4tz7V09mDamSfDI8c,1082
|
|
486
|
-
flock/webapp/templates/partials/_execution_form.html,sha256=
|
|
504
|
+
flock/webapp/templates/partials/_execution_form.html,sha256=296AFx0WSbCzX8t-L1pRl8s0AUzeOb2fmTiRlcwYoIg,3274
|
|
487
505
|
flock/webapp/templates/partials/_execution_view_container.html,sha256=XuphmZKYf2IYSeA9XHqtnwAntBylrFASDXVlLBJUeDk,1031
|
|
488
506
|
flock/webapp/templates/partials/_flock_file_list.html,sha256=FjIxAqB0OxA0mQ8f2jBX1_M_AM5ea7gCA8PEjPpiZVc,1209
|
|
489
507
|
flock/webapp/templates/partials/_flock_properties_form.html,sha256=0xNK_h5LrZrGCFyKfOLsvEaIpK2LlDfCte8bl0-AwdI,2885
|
|
@@ -496,18 +514,20 @@ flock/webapp/templates/partials/_results_display.html,sha256=vuAbIdnG_7jzeHxeeoR
|
|
|
496
514
|
flock/webapp/templates/partials/_settings_env_content.html,sha256=Q1Xr6wLHLlqiduqNk6PyF1B4juP-vvqLOLZyiHHNRLc,572
|
|
497
515
|
flock/webapp/templates/partials/_settings_theme_content.html,sha256=-y5vGRKBZf3Cp5DDE1M4Qw-yunuMtCG54Sa7r60XfJE,807
|
|
498
516
|
flock/webapp/templates/partials/_settings_view.html,sha256=7Uy2EfAgVJ2Kac5S6nkeaIEr2tSagVyR5CBbf07fbSQ,1349
|
|
517
|
+
flock/webapp/templates/partials/_share_chat_link_snippet.html,sha256=N83lNAbkZiDfzZYviKwURPGGErSZhRlxnNzUqXsB7lE,793
|
|
518
|
+
flock/webapp/templates/partials/_share_link_snippet.html,sha256=6en9lOdtu8FwVbtmkJzSQpHQ1WFXHnCbe84FDgAEF3U,1533
|
|
499
519
|
flock/webapp/templates/partials/_sidebar.html,sha256=uA-SZKfVpxImT8Acpw2hhpJbOk1BlaLeSzRjleYfuSE,4450
|
|
500
520
|
flock/webapp/templates/partials/_structured_data_view.html,sha256=IsmGbm2rKHZr6qx0a_n6QGs89Rq4xNFhymrZVI6OShc,2063
|
|
501
521
|
flock/webapp/templates/partials/_theme_preview.html,sha256=81vP5z8958LjhGWGwjVAVw3zW0uvYwfcXlU30i9exmo,867
|
|
502
522
|
flock/workflow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
503
|
-
flock/workflow/activities.py,sha256=
|
|
523
|
+
flock/workflow/activities.py,sha256=fyvefDOWZhhj5gCYIHR9Aqm2DbE6XI6-sXESFnnYRuc,9911
|
|
504
524
|
flock/workflow/agent_activities.py,sha256=NhBZscflEf2IMfSRa_pBM_TRP7uVEF_O0ROvWZ33eDc,963
|
|
505
525
|
flock/workflow/agent_execution_activity.py,sha256=Gy6FtuVAjf0NiUXmC3syS2eJpNQF4R3pmwMq47NYW3U,9462
|
|
506
526
|
flock/workflow/flock_workflow.py,sha256=iSUF_soFvWar0ffpkzE4irkDZRx0p4HnwmEBi_Ne2sY,9666
|
|
507
527
|
flock/workflow/temporal_config.py,sha256=3_8O7SDEjMsSMXsWJBfnb6XTp0TFaz39uyzSlMTSF_I,3988
|
|
508
528
|
flock/workflow/temporal_setup.py,sha256=YIHnSBntzOchHfMSh8hoLeNXrz3B1UbR14YrR6soM7A,1606
|
|
509
|
-
flock_core-0.4.
|
|
510
|
-
flock_core-0.4.
|
|
511
|
-
flock_core-0.4.
|
|
512
|
-
flock_core-0.4.
|
|
513
|
-
flock_core-0.4.
|
|
529
|
+
flock_core-0.4.0b49.dist-info/METADATA,sha256=BV-rirx2H3Z43076Y0lQjFUSaRQ9WxlAsmN9FJzy_-8,17879
|
|
530
|
+
flock_core-0.4.0b49.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
531
|
+
flock_core-0.4.0b49.dist-info/entry_points.txt,sha256=rWaS5KSpkTmWySURGFZk6PhbJ87TmvcFQDi2uzjlagQ,37
|
|
532
|
+
flock_core-0.4.0b49.dist-info/licenses/LICENSE,sha256=iYEqWy0wjULzM9GAERaybP4LBiPeu7Z1NEliLUdJKSc,1072
|
|
533
|
+
flock_core-0.4.0b49.dist-info/RECORD,,
|
flock/core/tools/basic_tools.py
DELETED
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
"""This module contains basic agentic tools for performing various tasks."""
|
|
2
|
-
|
|
3
|
-
import importlib
|
|
4
|
-
import json
|
|
5
|
-
import os
|
|
6
|
-
import re
|
|
7
|
-
from typing import Any, Literal
|
|
8
|
-
|
|
9
|
-
from flock.core.interpreter.python_interpreter import PythonInterpreter
|
|
10
|
-
from flock.core.logging.trace_and_logged import traced_and_logged
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@traced_and_logged
|
|
14
|
-
def web_search_tavily(query: str):
|
|
15
|
-
if importlib.util.find_spec("tavily") is not None:
|
|
16
|
-
from tavily import TavilyClient
|
|
17
|
-
|
|
18
|
-
client = TavilyClient(api_key=os.getenv("TAVILY_API_KEY"))
|
|
19
|
-
try:
|
|
20
|
-
response = client.search(query, include_answer=True) # type: ignore
|
|
21
|
-
return response
|
|
22
|
-
except Exception:
|
|
23
|
-
raise
|
|
24
|
-
else:
|
|
25
|
-
raise ImportError(
|
|
26
|
-
"Optional tool dependencies not installed. Install with 'pip install flock-core[tools]'."
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@traced_and_logged
|
|
31
|
-
def web_search_duckduckgo(
|
|
32
|
-
keywords: str, search_type: Literal["news", "web"] = "web"
|
|
33
|
-
):
|
|
34
|
-
try:
|
|
35
|
-
from duckduckgo_search import DDGS
|
|
36
|
-
|
|
37
|
-
if search_type == "news":
|
|
38
|
-
response = DDGS().news(keywords)
|
|
39
|
-
else:
|
|
40
|
-
response = DDGS().text(keywords)
|
|
41
|
-
|
|
42
|
-
return response
|
|
43
|
-
except Exception:
|
|
44
|
-
raise
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@traced_and_logged
|
|
48
|
-
def web_search_bing(keywords: str):
|
|
49
|
-
try:
|
|
50
|
-
import httpx
|
|
51
|
-
|
|
52
|
-
subscription_key = os.environ["BING_SEARCH_V7_SUBSCRIPTION_KEY"]
|
|
53
|
-
endpoint = "https://api.bing.microsoft.com/v7.0/search"
|
|
54
|
-
|
|
55
|
-
# Query term(s) to search for.
|
|
56
|
-
query = keywords
|
|
57
|
-
|
|
58
|
-
# Construct a request
|
|
59
|
-
mkt = "en-US"
|
|
60
|
-
params = {"q": query, "mkt": mkt}
|
|
61
|
-
headers = {"Ocp-Apim-Subscription-Key": subscription_key}
|
|
62
|
-
|
|
63
|
-
response = httpx.get(endpoint, headers=headers, params=params)
|
|
64
|
-
response.raise_for_status()
|
|
65
|
-
search_results = response.json()
|
|
66
|
-
return search_results["webPages"]
|
|
67
|
-
except Exception:
|
|
68
|
-
raise
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def extract_links_from_markdown(markdown: str, url: str) -> list:
|
|
72
|
-
# Regular expression to find all markdown links
|
|
73
|
-
link_pattern = re.compile(r"\[([^\]]+)\]\(([^)]+)\)")
|
|
74
|
-
links = link_pattern.findall(markdown)
|
|
75
|
-
return [url + link[1] for link in links]
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
@traced_and_logged
|
|
79
|
-
def get_web_content_as_markdown(url: str) -> str:
|
|
80
|
-
if (
|
|
81
|
-
importlib.util.find_spec("httpx") is not None
|
|
82
|
-
and importlib.util.find_spec("markdownify") is not None
|
|
83
|
-
):
|
|
84
|
-
import httpx
|
|
85
|
-
from markdownify import markdownify as md
|
|
86
|
-
|
|
87
|
-
try:
|
|
88
|
-
response = httpx.get(url)
|
|
89
|
-
response.raise_for_status()
|
|
90
|
-
markdown = md(response.text)
|
|
91
|
-
return markdown
|
|
92
|
-
except Exception:
|
|
93
|
-
raise
|
|
94
|
-
else:
|
|
95
|
-
raise ImportError(
|
|
96
|
-
"Optional tool dependencies not installed. Install with 'pip install flock-core[tools]'."
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
@traced_and_logged
|
|
101
|
-
def get_anything_as_markdown(url_or_file_path: str):
|
|
102
|
-
if importlib.util.find_spec("docling") is not None:
|
|
103
|
-
from docling.document_converter import DocumentConverter
|
|
104
|
-
|
|
105
|
-
try:
|
|
106
|
-
converter = DocumentConverter()
|
|
107
|
-
result = converter.convert(url_or_file_path)
|
|
108
|
-
markdown = result.document.export_to_markdown()
|
|
109
|
-
return markdown
|
|
110
|
-
except Exception:
|
|
111
|
-
raise
|
|
112
|
-
else:
|
|
113
|
-
raise ImportError(
|
|
114
|
-
"Optional tool dependencies not installed. Install with 'pip install flock-core[all-tools]'."
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
@traced_and_logged
|
|
119
|
-
def evaluate_math(expression: str) -> float:
|
|
120
|
-
try:
|
|
121
|
-
result = PythonInterpreter(
|
|
122
|
-
{},
|
|
123
|
-
[
|
|
124
|
-
"os",
|
|
125
|
-
"math",
|
|
126
|
-
"random",
|
|
127
|
-
"datetime",
|
|
128
|
-
"time",
|
|
129
|
-
"string",
|
|
130
|
-
"collections",
|
|
131
|
-
"itertools",
|
|
132
|
-
"functools",
|
|
133
|
-
"typing",
|
|
134
|
-
"enum",
|
|
135
|
-
"json",
|
|
136
|
-
"ast",
|
|
137
|
-
],
|
|
138
|
-
verbose=True,
|
|
139
|
-
).execute(expression)
|
|
140
|
-
return result
|
|
141
|
-
except Exception:
|
|
142
|
-
raise
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
@traced_and_logged
|
|
146
|
-
def code_eval(python_code: str) -> str:
|
|
147
|
-
try:
|
|
148
|
-
result = PythonInterpreter(
|
|
149
|
-
{},
|
|
150
|
-
[
|
|
151
|
-
"os",
|
|
152
|
-
"math",
|
|
153
|
-
"random",
|
|
154
|
-
"datetime",
|
|
155
|
-
"time",
|
|
156
|
-
"string",
|
|
157
|
-
"collections",
|
|
158
|
-
"itertools",
|
|
159
|
-
"functools",
|
|
160
|
-
"typing",
|
|
161
|
-
"enum",
|
|
162
|
-
"json",
|
|
163
|
-
"ast",
|
|
164
|
-
],
|
|
165
|
-
verbose=True,
|
|
166
|
-
).execute(python_code)
|
|
167
|
-
return result
|
|
168
|
-
except Exception:
|
|
169
|
-
raise
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
@traced_and_logged
|
|
173
|
-
def get_current_time() -> str:
|
|
174
|
-
import datetime
|
|
175
|
-
|
|
176
|
-
time = datetime.datetime.now().isoformat()
|
|
177
|
-
return time
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
@traced_and_logged
|
|
181
|
-
def count_words(text: str) -> int:
|
|
182
|
-
count = len(text.split())
|
|
183
|
-
return count
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
@traced_and_logged
|
|
187
|
-
def extract_urls(text: str) -> list[str]:
|
|
188
|
-
import re
|
|
189
|
-
|
|
190
|
-
url_pattern = r"https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+"
|
|
191
|
-
urls = re.findall(url_pattern, text)
|
|
192
|
-
return urls
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
@traced_and_logged
|
|
196
|
-
def extract_numbers(text: str) -> list[float]:
|
|
197
|
-
import re
|
|
198
|
-
|
|
199
|
-
numbers = [float(x) for x in re.findall(r"-?\d*\.?\d+", text)]
|
|
200
|
-
return numbers
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
@traced_and_logged
|
|
204
|
-
def json_parse_safe(text: str) -> dict:
|
|
205
|
-
try:
|
|
206
|
-
result = json.loads(text)
|
|
207
|
-
return result
|
|
208
|
-
except Exception:
|
|
209
|
-
return {}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
@traced_and_logged
|
|
213
|
-
def save_to_file(content: str, filename: str):
|
|
214
|
-
try:
|
|
215
|
-
with open(filename, "w") as f:
|
|
216
|
-
f.write(content)
|
|
217
|
-
except Exception:
|
|
218
|
-
raise
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
@traced_and_logged
|
|
222
|
-
def read_from_file(filename: str) -> str:
|
|
223
|
-
with open(filename, encoding="utf-8") as file:
|
|
224
|
-
return file.read()
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
@traced_and_logged
|
|
228
|
-
def json_search(
|
|
229
|
-
json_file_path: str, search_query: str, case_sensitive: bool = False
|
|
230
|
-
) -> list:
|
|
231
|
-
"""Search a JSON file for objects containing the specified search query.
|
|
232
|
-
|
|
233
|
-
Args:
|
|
234
|
-
json_file_path (str): Path to the JSON file to search
|
|
235
|
-
search_query (str): Text to search for within the JSON objects
|
|
236
|
-
case_sensitive (bool, optional): Whether to perform a case-sensitive search. Defaults to False.
|
|
237
|
-
|
|
238
|
-
Returns:
|
|
239
|
-
list: List of JSON objects (as dicts) that contain the search query
|
|
240
|
-
|
|
241
|
-
Example:
|
|
242
|
-
>>> matching_tickets = json_search("tickets.json", "error 404")
|
|
243
|
-
>>> print(
|
|
244
|
-
... f"Found {len(matching_tickets)} tickets mentioning '404 error'"
|
|
245
|
-
... )
|
|
246
|
-
"""
|
|
247
|
-
try:
|
|
248
|
-
# Read the JSON file
|
|
249
|
-
file_content = read_from_file(json_file_path)
|
|
250
|
-
|
|
251
|
-
# Parse the JSON content
|
|
252
|
-
json_data = json_parse_safe(file_content)
|
|
253
|
-
|
|
254
|
-
# Convert search query to lowercase if case-insensitive search
|
|
255
|
-
if not case_sensitive:
|
|
256
|
-
search_query = search_query.lower()
|
|
257
|
-
|
|
258
|
-
results = []
|
|
259
|
-
|
|
260
|
-
# Determine if the JSON root is an object or array
|
|
261
|
-
if isinstance(json_data, dict):
|
|
262
|
-
# Handle case where root is a dictionary object
|
|
263
|
-
for key, value in json_data.items():
|
|
264
|
-
if isinstance(value, list):
|
|
265
|
-
# If this key contains a list of objects, search within them
|
|
266
|
-
matching_items = _search_in_list(
|
|
267
|
-
value, search_query, case_sensitive
|
|
268
|
-
)
|
|
269
|
-
results.extend(matching_items)
|
|
270
|
-
elif _contains_text(value, search_query, case_sensitive):
|
|
271
|
-
# The entire object matches
|
|
272
|
-
results.append(json_data)
|
|
273
|
-
break
|
|
274
|
-
elif isinstance(json_data, list):
|
|
275
|
-
# Handle case where root is an array
|
|
276
|
-
matching_items = _search_in_list(
|
|
277
|
-
json_data, search_query, case_sensitive
|
|
278
|
-
)
|
|
279
|
-
results.extend(matching_items)
|
|
280
|
-
|
|
281
|
-
return results
|
|
282
|
-
|
|
283
|
-
except Exception as e:
|
|
284
|
-
return [{"error": f"Error searching JSON file: {e!s}"}]
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
def _search_in_list(
|
|
288
|
-
items: list, search_query: str, case_sensitive: bool
|
|
289
|
-
) -> list:
|
|
290
|
-
"""Helper function to search for text in a list of items."""
|
|
291
|
-
matching_items = []
|
|
292
|
-
for item in items:
|
|
293
|
-
if _contains_text(item, search_query, case_sensitive):
|
|
294
|
-
matching_items.append(item)
|
|
295
|
-
return matching_items
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
def _contains_text(obj: Any, search_query: str, case_sensitive: bool) -> bool:
|
|
299
|
-
"""Recursively check if an object contains the search query in any of its string values."""
|
|
300
|
-
if isinstance(obj, str):
|
|
301
|
-
# For string values, check if they contain the search query
|
|
302
|
-
if case_sensitive:
|
|
303
|
-
return search_query in obj
|
|
304
|
-
else:
|
|
305
|
-
return search_query in obj.lower()
|
|
306
|
-
elif isinstance(obj, dict):
|
|
307
|
-
# For dictionaries, check each value
|
|
308
|
-
for value in obj.values():
|
|
309
|
-
if _contains_text(value, search_query, case_sensitive):
|
|
310
|
-
return True
|
|
311
|
-
elif isinstance(obj, list):
|
|
312
|
-
# For lists, check each item
|
|
313
|
-
for item in obj:
|
|
314
|
-
if _contains_text(item, search_query, case_sensitive):
|
|
315
|
-
return True
|
|
316
|
-
# For other types (numbers, booleans, None), return False
|
|
317
|
-
return False
|