fabricatio 0.2.4.dev1__tar.gz → 0.2.4.dev2__tar.gz
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.
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/PKG-INFO +1 -1
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/llm_usages/llm_usage.py +3 -10
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/make_a_rating/rating.py +3 -9
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/make_diary/diary.py +1 -7
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/minor/hello_fabricatio.py +0 -1
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/propose_task/propose.py +0 -1
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/simple_chat/chat.py +0 -1
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/simple_rag/simple_rag.py +0 -1
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/task_handle/handle_task.py +3 -15
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/pyproject.toml +1 -1
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/__init__.py +4 -2
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/actions/article.py +7 -2
- fabricatio-0.2.4.dev2/python/fabricatio/actions/rag.py +25 -0
- fabricatio-0.2.4.dev2/python/fabricatio/fs/__init__.py +17 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/action.py +17 -1
- fabricatio-0.2.4.dev2/python/fabricatio/workflows/articles.py +11 -0
- fabricatio-0.2.4.dev2/templates.tar.gz +0 -0
- fabricatio-0.2.4.dev2/uv.lock +1509 -0
- fabricatio-0.2.4.dev1/python/fabricatio/actions/__init__.py +0 -5
- fabricatio-0.2.4.dev1/python/fabricatio/fs/__init__.py +0 -5
- fabricatio-0.2.4.dev1/templates.tar.gz +0 -0
- fabricatio-0.2.4.dev1/uv.lock +0 -1507
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/.github/workflows/build-package.yaml +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/.github/workflows/tests.yaml +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/.gitignore +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/.python-version +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/Cargo.lock +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/Cargo.toml +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/LICENSE +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/Makefile +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/README.md +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/extract_article/extract.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/examples/make_diary/commits.json +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/_rust.pyi +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/_rust_instances.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/capabilities/propose.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/capabilities/rag.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/capabilities/rating.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/capabilities/task.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/config.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/core.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/decorators.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/fs/curd.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/journal.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/extra.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/generic.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/kwargs_types.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/role.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/task.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/tool.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/usages.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/models/utils.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/parser.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/py.typed +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/toolboxes/arithmetic.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/toolboxes/fs.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/python/fabricatio/toolboxes/task.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/src/hash.rs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/src/lib.rs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/src/templates.rs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/claude-xml.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/clean-up-code.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/create_json_obj.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/dependencies.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/document-the-code.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/draft_rating_criteria.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/draft_rating_manual.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/draft_tool_usage_code.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/fix-bugs.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/improve-performance.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/liststr.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/make_choice.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/make_judgment.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/rate_fine_grind.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/refactor.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/retrieved_display.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/task_briefing.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/web-ctf-solver.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/write-git-commit.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/write-github-pull-request.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/templates/built-in/write-github-readme.hbs +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_config.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_models/test_action.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_models/test_advanced.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_models/test_generic.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_models/test_role.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_models/test_task.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_models/test_tool.py +0 -0
- {fabricatio-0.2.4.dev1 → fabricatio-0.2.4.dev2}/tests/test_models/test_usages.py +0 -0
@@ -11,7 +11,6 @@ from fabricatio.parser import PythonCapture
|
|
11
11
|
class WriteCode(Action):
|
12
12
|
"""Action that says hello to the world."""
|
13
13
|
|
14
|
-
name: str = "write code"
|
15
14
|
output_key: str = "task_output"
|
16
15
|
|
17
16
|
async def _execute(self, task_input: Task[str], **_) -> str:
|
@@ -22,10 +21,8 @@ class WriteCode(Action):
|
|
22
21
|
|
23
22
|
|
24
23
|
class WriteDocumentation(Action):
|
25
|
-
"""
|
24
|
+
"""write documentation for the code in markdown format."""
|
26
25
|
|
27
|
-
name: str = "write documentation"
|
28
|
-
description: str = "write documentation for the code in markdown format"
|
29
26
|
output_key: str = "task_output"
|
30
27
|
|
31
28
|
async def _execute(self, task_input: Task[str], **_) -> str:
|
@@ -38,12 +35,8 @@ async def main() -> None:
|
|
38
35
|
name="Coder",
|
39
36
|
description="A python coder who can write code and documentation",
|
40
37
|
registry={
|
41
|
-
Event.
|
42
|
-
|
43
|
-
),
|
44
|
-
Event.instantiate_from("doc").push_wildcard().push("pending"): WorkFlow(
|
45
|
-
name="write documentation", steps=(WriteDocumentation,)
|
46
|
-
),
|
38
|
+
Event.quick_instantiate("coding"): WorkFlow(name="write code", steps=(WriteCode,)),
|
39
|
+
Event.quick_instantiate("doc"): WorkFlow(name="write documentation", steps=(WriteDocumentation,)),
|
47
40
|
},
|
48
41
|
)
|
49
42
|
|
@@ -12,7 +12,6 @@ from fabricatio.models.task import Task
|
|
12
12
|
class Rate(Action):
|
13
13
|
"""Rate the task."""
|
14
14
|
|
15
|
-
name: str = "rate"
|
16
15
|
output_key: str = "task_output"
|
17
16
|
|
18
17
|
async def _execute(self, to_rate: List[str], rate_topic: str, criteria: Set[str], **_) -> List[Dict[str, float]]:
|
@@ -28,8 +27,6 @@ class Rate(Action):
|
|
28
27
|
class WhatToRate(Action):
|
29
28
|
"""Figure out what to rate."""
|
30
29
|
|
31
|
-
name: str = "figure out what to rate"
|
32
|
-
|
33
30
|
output_key: str = "to_rate"
|
34
31
|
|
35
32
|
async def _execute(self, task_input: Task, rate_topic: str, **cxt: Unpack) -> List[str]:
|
@@ -55,7 +52,6 @@ class WhatToRate(Action):
|
|
55
52
|
class MakeCriteria(Action):
|
56
53
|
"""Make criteria for rating."""
|
57
54
|
|
58
|
-
name: str = "make criteria"
|
59
55
|
output_key: str = "criteria"
|
60
56
|
|
61
57
|
async def _execute(self, rate_topic: str, to_rate: List[str], **cxt: Unpack) -> Set[str]:
|
@@ -67,8 +63,6 @@ class MakeCriteria(Action):
|
|
67
63
|
class MakeCompositeScore(Action):
|
68
64
|
"""Make a composite score."""
|
69
65
|
|
70
|
-
name: str = "make composite score"
|
71
|
-
|
72
66
|
output_key: str = "task_output"
|
73
67
|
|
74
68
|
async def _execute(self, rate_topic: str, to_rate: List[str], **cxt: Unpack) -> List[float]:
|
@@ -84,7 +78,7 @@ async def main() -> None:
|
|
84
78
|
name="TaskRater",
|
85
79
|
description="A role that can rate tasks.",
|
86
80
|
registry={
|
87
|
-
Event.
|
81
|
+
Event.quick_instantiate("rate_food"): WorkFlow(
|
88
82
|
name="Rate food",
|
89
83
|
steps=(WhatToRate, Rate),
|
90
84
|
extra_init_context={
|
@@ -92,14 +86,14 @@ async def main() -> None:
|
|
92
86
|
"criteria": {"taste", "price", "quality", "safety", "healthiness"},
|
93
87
|
},
|
94
88
|
),
|
95
|
-
Event.
|
89
|
+
Event.quick_instantiate("make_criteria_for_food"): WorkFlow(
|
96
90
|
name="Make criteria for food",
|
97
91
|
steps=(WhatToRate, MakeCriteria, Rate),
|
98
92
|
extra_init_context={
|
99
93
|
"rate_topic": "if the food is 'good'",
|
100
94
|
},
|
101
95
|
),
|
102
|
-
Event.
|
96
|
+
Event.quick_instantiate("make_composite_score"): WorkFlow(
|
103
97
|
name="Make composite score",
|
104
98
|
steps=(WhatToRate, MakeCompositeScore),
|
105
99
|
extra_init_context={
|
@@ -13,8 +13,6 @@ from pydantic import Field
|
|
13
13
|
class WriteDiary(Action):
|
14
14
|
"""Write a diary according to the given commit messages in json format."""
|
15
15
|
|
16
|
-
name: str = "write diary"
|
17
|
-
description: str = "write a diary according to the given commit messages in json format"
|
18
16
|
output_key: str = "dump_text"
|
19
17
|
|
20
18
|
async def _execute(self, task_input: Task[str], **_) -> str:
|
@@ -50,8 +48,6 @@ class WriteDiary(Action):
|
|
50
48
|
class DumpText(Action):
|
51
49
|
"""Dump the text to a file."""
|
52
50
|
|
53
|
-
name: str = "dump text"
|
54
|
-
description: str = "dump text to a file"
|
55
51
|
toolboxes: Set[ToolBox] = Field(default_factory=lambda: {fs_toolbox})
|
56
52
|
output_key: str = "task_output"
|
57
53
|
|
@@ -77,9 +73,7 @@ async def main() -> None:
|
|
77
73
|
name="Coder",
|
78
74
|
description="A python coder who can ",
|
79
75
|
registry={
|
80
|
-
Event.
|
81
|
-
name="write documentation", steps=(WriteDiary, DumpText)
|
82
|
-
),
|
76
|
+
Event.quick_instantiate("doc"): WorkFlow(name="write documentation", steps=(WriteDiary, DumpText)),
|
83
77
|
},
|
84
78
|
)
|
85
79
|
|
@@ -11,7 +11,6 @@ task = Task(name="say hello", goals=["say hello"], description="say hello to the
|
|
11
11
|
class Hello(Action):
|
12
12
|
"""Action that says hello."""
|
13
13
|
|
14
|
-
name: str = "hello"
|
15
14
|
output_key: str = "task_output"
|
16
15
|
|
17
16
|
async def _execute(self, task_input: Task[str], **_) -> Any:
|
@@ -10,7 +10,6 @@ from pydantic import Field
|
|
10
10
|
class WriteCode(Action):
|
11
11
|
"""Action that says hello to the world."""
|
12
12
|
|
13
|
-
name: str = "write code"
|
14
13
|
output_key: str = "dump_text"
|
15
14
|
|
16
15
|
async def _execute(self, task_input: Task[str], **_) -> str:
|
@@ -24,8 +23,6 @@ class WriteCode(Action):
|
|
24
23
|
class DumpText(Action):
|
25
24
|
"""Dump the text to a file."""
|
26
25
|
|
27
|
-
name: str = "dump text"
|
28
|
-
description: str = "dump text to a file"
|
29
26
|
toolboxes: Set[ToolBox] = Field(default_factory=lambda: {fs_toolbox})
|
30
27
|
output_key: str = "task_output"
|
31
28
|
|
@@ -48,8 +45,6 @@ class DumpText(Action):
|
|
48
45
|
class WriteDocumentation(Action):
|
49
46
|
"""Action that says hello to the world."""
|
50
47
|
|
51
|
-
name: str = "write documentation"
|
52
|
-
description: str = "write documentation for the code in markdown format"
|
53
48
|
output_key: str = "dump_text"
|
54
49
|
|
55
50
|
async def _execute(self, task_input: Task[str], **_) -> str:
|
@@ -59,8 +54,6 @@ class WriteDocumentation(Action):
|
|
59
54
|
class TestCancel(Action):
|
60
55
|
"""Action that says hello to the world."""
|
61
56
|
|
62
|
-
name: str = "cancel"
|
63
|
-
description: str = "cancel the task"
|
64
57
|
output_key: str = "counter"
|
65
58
|
|
66
59
|
async def _execute(self, counter: int, **_) -> int:
|
@@ -73,7 +66,6 @@ class TestCancel(Action):
|
|
73
66
|
class WriteToOutput(Action):
|
74
67
|
"""Action that says hello to the world."""
|
75
68
|
|
76
|
-
name: str = "write to output"
|
77
69
|
output_key: str = "task_output"
|
78
70
|
|
79
71
|
async def _execute(self, **_) -> str:
|
@@ -86,13 +78,9 @@ async def main() -> None:
|
|
86
78
|
name="Coder",
|
87
79
|
description="A python coder who can ",
|
88
80
|
registry={
|
89
|
-
Event.
|
90
|
-
|
91
|
-
)
|
92
|
-
Event.instantiate_from("doc").push_wildcard().push("pending"): WorkFlow(
|
93
|
-
name="write documentation", steps=(WriteDocumentation, DumpText)
|
94
|
-
),
|
95
|
-
Event.instantiate_from("cancel_test").push_wildcard().push("pending"): WorkFlow(
|
81
|
+
Event.quick_instantiate("coding"): WorkFlow(name="write code", steps=(WriteCode, DumpText)),
|
82
|
+
Event.quick_instantiate("doc"): WorkFlow(name="write documentation", steps=(WriteDocumentation, DumpText)),
|
83
|
+
Event.quick_instantiate("cancel_test"): WorkFlow(
|
96
84
|
name="cancel_test",
|
97
85
|
steps=(TestCancel, TestCancel, TestCancel, TestCancel, TestCancel, TestCancel, WriteToOutput),
|
98
86
|
extra_init_context={"counter": 0},
|
@@ -3,7 +3,7 @@
|
|
3
3
|
from importlib.util import find_spec
|
4
4
|
|
5
5
|
from fabricatio._rust_instances import template_manager
|
6
|
-
from fabricatio.actions import ExtractArticleEssence
|
6
|
+
from fabricatio.actions.article import ExtractArticleEssence
|
7
7
|
from fabricatio.core import env
|
8
8
|
from fabricatio.fs import magika
|
9
9
|
from fabricatio.journal import logger
|
@@ -44,6 +44,8 @@ __all__ = [
|
|
44
44
|
|
45
45
|
|
46
46
|
if find_spec("pymilvus"):
|
47
|
+
from fabricatio.actions.rag import InjectToDB
|
47
48
|
from fabricatio.capabilities.rag import RAG
|
49
|
+
from fabricatio.workflows.articles import StoreArticle
|
48
50
|
|
49
|
-
__all__ += ["RAG"]
|
51
|
+
__all__ += ["RAG", "InjectToDB", "StoreArticle"]
|
@@ -11,11 +11,16 @@ from fabricatio.models.task import Task
|
|
11
11
|
|
12
12
|
|
13
13
|
class ExtractArticleEssence(Action):
|
14
|
-
"""Extract the essence of article(s).
|
14
|
+
"""Extract the essence of article(s) in text format from the paths specified in the task dependencies.
|
15
|
+
|
16
|
+
Notes:
|
17
|
+
This action is designed to extract vital information from articles with Markdown format, which is pure text, and
|
18
|
+
which is converted from pdf files using `magic-pdf` from the `MinerU` project, see https://github.com/opendatalab/MinerU
|
19
|
+
"""
|
15
20
|
|
16
21
|
name: str = "extract article essence"
|
17
22
|
"""The name of the action."""
|
18
|
-
description: str = "Extract the essence of
|
23
|
+
description: str = "Extract the essence of article(s) from the paths specified in the task dependencies."
|
19
24
|
"""The description of the action."""
|
20
25
|
|
21
26
|
output_key: str = "article_essence"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"""Inject data into the database."""
|
2
|
+
|
3
|
+
from typing import List, Optional, Unpack
|
4
|
+
|
5
|
+
from fabricatio.capabilities.rag import RAG
|
6
|
+
from fabricatio.models.action import Action
|
7
|
+
from fabricatio.models.generic import PrepareVectorization
|
8
|
+
|
9
|
+
|
10
|
+
class InjectToDB(Action, RAG):
|
11
|
+
"""Inject data into the database."""
|
12
|
+
|
13
|
+
output_key: str = "collection_name"
|
14
|
+
|
15
|
+
async def _execute[T: PrepareVectorization](
|
16
|
+
self, to_inject: T | List[T], collection_name: Optional[str] = "my_collection", **cxt: Unpack
|
17
|
+
) -> str:
|
18
|
+
if not isinstance(to_inject, list):
|
19
|
+
to_inject = [to_inject]
|
20
|
+
|
21
|
+
await self.view(collection_name, create=True).consume_string(
|
22
|
+
[t.prepare_vectorization(self.embedding_max_sequence_length) for t in to_inject],
|
23
|
+
)
|
24
|
+
|
25
|
+
return collection_name
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"""FileSystem manipulation module for Fabricatio."""
|
2
|
+
|
3
|
+
from fabricatio.fs.curd import copy_file, create_directory, delete_directory, delete_file, dump_text, move_file, tree
|
4
|
+
from fabricatio.fs.readers import magika, safe_json_read, safe_text_read
|
5
|
+
|
6
|
+
__all__ = [
|
7
|
+
"copy_file",
|
8
|
+
"create_directory",
|
9
|
+
"delete_directory",
|
10
|
+
"delete_file",
|
11
|
+
"dump_text",
|
12
|
+
"magika",
|
13
|
+
"move_file",
|
14
|
+
"safe_json_read",
|
15
|
+
"safe_text_read",
|
16
|
+
"tree",
|
17
|
+
]
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import traceback
|
4
4
|
from abc import abstractmethod
|
5
5
|
from asyncio import Queue, create_task
|
6
|
-
from typing import Any, Dict, Self, Tuple, Type, Union, Unpack
|
6
|
+
from typing import Any, Dict, Self, Tuple, Type, Union, Unpack, final
|
7
7
|
|
8
8
|
from fabricatio.capabilities.rating import GiveRating
|
9
9
|
from fabricatio.capabilities.task import HandleTask, ProposeTask
|
@@ -17,11 +17,26 @@ from pydantic import Field, PrivateAttr
|
|
17
17
|
class Action(HandleTask, ProposeTask, GiveRating):
|
18
18
|
"""Class that represents an action to be executed in a workflow."""
|
19
19
|
|
20
|
+
name: str = Field(default="")
|
21
|
+
"""The name of the action."""
|
22
|
+
description: str = Field(default="")
|
23
|
+
"""The description of the action."""
|
20
24
|
personality: str = Field(default="")
|
21
25
|
"""The personality of whom the action belongs to."""
|
22
26
|
output_key: str = Field(default="")
|
23
27
|
"""The key of the output data."""
|
24
28
|
|
29
|
+
@final
|
30
|
+
def model_post_init(self, __context: Any) -> None:
|
31
|
+
"""Initialize the action by setting the name if not provided.
|
32
|
+
|
33
|
+
Args:
|
34
|
+
__context: The context to be used for initialization.
|
35
|
+
"""
|
36
|
+
self.name = self.name or self.__class__.__name__
|
37
|
+
|
38
|
+
self.description = self.description or self.__class__.__doc__ or ""
|
39
|
+
|
25
40
|
@abstractmethod
|
26
41
|
async def _execute(self, **cxt: Unpack) -> Any:
|
27
42
|
"""Execute the action with the provided arguments.
|
@@ -34,6 +49,7 @@ class Action(HandleTask, ProposeTask, GiveRating):
|
|
34
49
|
"""
|
35
50
|
pass
|
36
51
|
|
52
|
+
@final
|
37
53
|
async def act(self, cxt: Dict[str, Any]) -> Dict[str, Any]:
|
38
54
|
"""Perform the action by executing it and setting the output data.
|
39
55
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"""Store article essence in the database."""
|
2
|
+
|
3
|
+
from fabricatio.actions.article import ExtractArticleEssence
|
4
|
+
from fabricatio.actions.rag import InjectToDB
|
5
|
+
from fabricatio.models.action import WorkFlow
|
6
|
+
|
7
|
+
StoreArticle = WorkFlow(
|
8
|
+
name="Extract Article Essence",
|
9
|
+
description="Extract the essence of an article in the given path, and store it in the database.",
|
10
|
+
steps=(ExtractArticleEssence(output_key="to_inject"), InjectToDB(output_key="task_output")),
|
11
|
+
)
|
Binary file
|