fabricatio 0.2.2__tar.gz → 0.2.3__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.
Files changed (95) hide show
  1. {fabricatio-0.2.2 → fabricatio-0.2.3}/PKG-INFO +42 -38
  2. {fabricatio-0.2.2 → fabricatio-0.2.3}/README.md +41 -37
  3. {fabricatio-0.2.2 → fabricatio-0.2.3}/examples/make_diary/diary.py +2 -2
  4. {fabricatio-0.2.2 → fabricatio-0.2.3}/examples/minor/hello_fabricatio.py +1 -1
  5. {fabricatio-0.2.2 → fabricatio-0.2.3}/examples/propose_task/propose.py +1 -1
  6. fabricatio-0.2.3/examples/simple_chat/chat.py +47 -0
  7. fabricatio-0.2.3/examples/simple_rag/simple_rag.py +66 -0
  8. {fabricatio-0.2.2 → fabricatio-0.2.3}/examples/task_handle/handle_task.py +43 -7
  9. {fabricatio-0.2.2 → fabricatio-0.2.3}/pyproject.toml +1 -1
  10. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/__init__.py +8 -0
  11. fabricatio-0.2.3/python/fabricatio/capabilities/rag.py +310 -0
  12. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/config.py +49 -0
  13. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/core.py +33 -19
  14. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/action.py +6 -2
  15. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/generic.py +107 -1
  16. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/kwargs_types.py +23 -0
  17. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/task.py +69 -17
  18. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/usages.py +77 -70
  19. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/utils.py +50 -1
  20. fabricatio-0.2.3/templates/built-in/retrieved_display.hbs +5 -0
  21. fabricatio-0.2.3/templates.tar.gz +0 -0
  22. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_models/test_action.py +2 -3
  23. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_models/test_task.py +5 -6
  24. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_models/test_usages.py +3 -4
  25. fabricatio-0.2.3/uv.lock +1573 -0
  26. fabricatio-0.2.2/examples/simple_chat/chat.py +0 -33
  27. fabricatio-0.2.2/templates.tar.gz +0 -0
  28. fabricatio-0.2.2/uv.lock +0 -1573
  29. {fabricatio-0.2.2 → fabricatio-0.2.3}/.github/workflows/build-package.yaml +0 -0
  30. {fabricatio-0.2.2 → fabricatio-0.2.3}/.github/workflows/ruff.yaml +0 -0
  31. {fabricatio-0.2.2 → fabricatio-0.2.3}/.github/workflows/tests.yaml +0 -0
  32. {fabricatio-0.2.2 → fabricatio-0.2.3}/.gitignore +0 -0
  33. {fabricatio-0.2.2 → fabricatio-0.2.3}/.python-version +0 -0
  34. {fabricatio-0.2.2 → fabricatio-0.2.3}/Cargo.lock +0 -0
  35. {fabricatio-0.2.2 → fabricatio-0.2.3}/Cargo.toml +0 -0
  36. {fabricatio-0.2.2 → fabricatio-0.2.3}/LICENSE +0 -0
  37. {fabricatio-0.2.2 → fabricatio-0.2.3}/Makefile +0 -0
  38. {fabricatio-0.2.2 → fabricatio-0.2.3}/examples/llm_usages/llm_usage.py +0 -0
  39. {fabricatio-0.2.2 → fabricatio-0.2.3}/examples/make_a_rating/rating.py +0 -0
  40. {fabricatio-0.2.2 → fabricatio-0.2.3}/examples/make_diary/commits.json +0 -0
  41. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/_rust.pyi +0 -0
  42. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/_rust_instances.py +0 -0
  43. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/actions/__init__.py +0 -0
  44. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/actions/communication.py +0 -0
  45. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/actions/transmission.py +0 -0
  46. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/capabilities/rating.py +0 -0
  47. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/capabilities/task.py +0 -0
  48. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/decorators.py +0 -0
  49. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/fs/__init__.py +0 -0
  50. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/fs/curd.py +0 -0
  51. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/fs/readers.py +0 -0
  52. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/journal.py +0 -0
  53. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/events.py +0 -0
  54. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/role.py +0 -0
  55. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/models/tool.py +0 -0
  56. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/parser.py +0 -0
  57. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/py.typed +0 -0
  58. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/toolboxes/__init__.py +0 -0
  59. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/toolboxes/arithmetic.py +0 -0
  60. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/toolboxes/fs.py +0 -0
  61. {fabricatio-0.2.2 → fabricatio-0.2.3}/python/fabricatio/toolboxes/task.py +0 -0
  62. {fabricatio-0.2.2 → fabricatio-0.2.3}/src/hash.rs +0 -0
  63. {fabricatio-0.2.2 → fabricatio-0.2.3}/src/lib.rs +0 -0
  64. {fabricatio-0.2.2 → fabricatio-0.2.3}/src/templates.rs +0 -0
  65. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
  66. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/claude-xml.hbs +0 -0
  67. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/clean-up-code.hbs +0 -0
  68. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
  69. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/dependencies.hbs +0 -0
  70. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/document-the-code.hbs +0 -0
  71. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/draft_rating_criteria.hbs +0 -0
  72. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/draft_rating_manual.hbs +0 -0
  73. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/draft_rating_weights_klee.hbs +0 -0
  74. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/draft_tool_usage_code.hbs +0 -0
  75. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/extract_criteria_from_reasons.hbs +0 -0
  76. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/extract_reasons_from_examples.hbs +0 -0
  77. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
  78. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/fix-bugs.hbs +0 -0
  79. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/improve-performance.hbs +0 -0
  80. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/make_choice.hbs +0 -0
  81. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/make_judgment.hbs +0 -0
  82. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/propose_task.hbs +0 -0
  83. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/rate_fine_grind.hbs +0 -0
  84. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/refactor.hbs +0 -0
  85. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
  86. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/task_briefing.hbs +0 -0
  87. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/web-ctf-solver.hbs +0 -0
  88. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/write-git-commit.hbs +0 -0
  89. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/write-github-pull-request.hbs +0 -0
  90. {fabricatio-0.2.2 → fabricatio-0.2.3}/templates/built-in/write-github-readme.hbs +0 -0
  91. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_config.py +0 -0
  92. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_models/test_advanced.py +0 -0
  93. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_models/test_generic.py +0 -0
  94. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_models/test_role.py +0 -0
  95. {fabricatio-0.2.2 → fabricatio-0.2.3}/tests/test_models/test_tool.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -98,32 +98,32 @@ from fabricatio import Action, Role, Task, logger
98
98
 
99
99
 
100
100
  class Hello(Action):
101
- """Action that says hello."""
101
+ """Action that says hello."""
102
102
 
103
- name: str = "hello"
104
- output_key: str = "task_output"
103
+ name: str = "hello"
104
+ output_key: str = "task_output"
105
105
 
106
- async def _execute(self, task_input: Task[str], **_) -> Any:
107
- ret = "Hello fabricatio!"
108
- logger.info("executing talk action")
109
- return ret
106
+ async def _execute(self, task_input: Task[str], **_) -> Any:
107
+ ret = "Hello fabricatio!"
108
+ logger.info("executing talk action")
109
+ return ret
110
110
 
111
111
 
112
112
  async def main() -> None:
113
- """Main function."""
114
- role = Role(
115
- name="talker",
116
- description="talker role",
117
- registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
118
- )
113
+ """Main function."""
114
+ role = Role(
115
+ name="talker",
116
+ description="talker role",
117
+ registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
118
+ )
119
119
 
120
- task = Task(name="say hello", goal="say hello", description="say hello to the world")
121
- result = await task.delegate()
122
- logger.success(f"Result: {result}")
120
+ task = Task(name="say hello", goals="say hello", description="say hello to the world")
121
+ result = await task.delegate()
122
+ logger.success(f"Result: {result}")
123
123
 
124
124
 
125
125
  if __name__ == "__main__":
126
- asyncio.run(main())
126
+ asyncio.run(main())
127
127
  ```
128
128
 
129
129
  #### Writing and Dumping Code
@@ -311,17 +311,18 @@ from fabricatio.models.task import Task
311
311
 
312
312
  toolbox_usage = ToolBoxUsage()
313
313
 
314
+
314
315
  async def handle_security_vulnerabilities():
315
- task = Task(
316
- name="Security Check",
317
- goal=["Identify security vulnerabilities"],
318
- description="Perform a thorough security review on the project.",
319
- dependencies=["./src/main.py"]
320
- )
321
-
322
- vulnerabilities = await toolbox_usage.gather_tools_fine_grind(task)
323
- for vulnerability in vulnerabilities:
324
- print(f"Found vulnerability: {vulnerability.name}")
316
+ task = Task(
317
+ name="Security Check",
318
+ goals=["Identify security vulnerabilities"],
319
+ description="Perform a thorough security review on the project.",
320
+ dependencies=["./src/main.py"]
321
+ )
322
+
323
+ vulnerabilities = await toolbox_usage.gather_tools_fine_grind(task)
324
+ for vulnerability in vulnerabilities:
325
+ print(f"Found vulnerability: {vulnerability.name}")
325
326
  ```
326
327
 
327
328
  #### Managing CTF Challenges
@@ -334,19 +335,22 @@ from fabricatio.models.task import Task
334
335
 
335
336
  toolbox_usage = ToolBoxUsage()
336
337
 
338
+
337
339
  async def solve_ctf_challenge(challenge_name: str, challenge_description: str, files: list[str]):
338
- task = Task(
339
- name=challenge_name,
340
- goal=[f"Solve {challenge_name} challenge"],
341
- description=challenge_description,
342
- dependencies=files
343
- )
344
-
345
- solution = await toolbox_usage.gather_tools_fine_grind(task)
346
- print(f"Challenge Solved: {solution}")
340
+ task = Task(
341
+ name=challenge_name,
342
+ goals=[f"Solve {challenge_name} challenge"],
343
+ description=challenge_description,
344
+ dependencies=files
345
+ )
346
+
347
+ solution = await toolbox_usage.gather_tools_fine_grind(task)
348
+ print(f"Challenge Solved: {solution}")
349
+
347
350
 
348
351
  if __name__ == "__main__":
349
- asyncio.run(solve_ctf_challenge("Binary Exploitation", "CTF Binary Exploitation Challenge", ["./challenges/binary_exploit"]))
352
+ asyncio.run(
353
+ solve_ctf_challenge("Binary Exploitation", "CTF Binary Exploitation Challenge", ["./challenges/binary_exploit"]))
350
354
  ```
351
355
 
352
356
  ### Configuration
@@ -59,32 +59,32 @@ from fabricatio import Action, Role, Task, logger
59
59
 
60
60
 
61
61
  class Hello(Action):
62
- """Action that says hello."""
62
+ """Action that says hello."""
63
63
 
64
- name: str = "hello"
65
- output_key: str = "task_output"
64
+ name: str = "hello"
65
+ output_key: str = "task_output"
66
66
 
67
- async def _execute(self, task_input: Task[str], **_) -> Any:
68
- ret = "Hello fabricatio!"
69
- logger.info("executing talk action")
70
- return ret
67
+ async def _execute(self, task_input: Task[str], **_) -> Any:
68
+ ret = "Hello fabricatio!"
69
+ logger.info("executing talk action")
70
+ return ret
71
71
 
72
72
 
73
73
  async def main() -> None:
74
- """Main function."""
75
- role = Role(
76
- name="talker",
77
- description="talker role",
78
- registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
79
- )
74
+ """Main function."""
75
+ role = Role(
76
+ name="talker",
77
+ description="talker role",
78
+ registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
79
+ )
80
80
 
81
- task = Task(name="say hello", goal="say hello", description="say hello to the world")
82
- result = await task.delegate()
83
- logger.success(f"Result: {result}")
81
+ task = Task(name="say hello", goals="say hello", description="say hello to the world")
82
+ result = await task.delegate()
83
+ logger.success(f"Result: {result}")
84
84
 
85
85
 
86
86
  if __name__ == "__main__":
87
- asyncio.run(main())
87
+ asyncio.run(main())
88
88
  ```
89
89
 
90
90
  #### Writing and Dumping Code
@@ -272,17 +272,18 @@ from fabricatio.models.task import Task
272
272
 
273
273
  toolbox_usage = ToolBoxUsage()
274
274
 
275
+
275
276
  async def handle_security_vulnerabilities():
276
- task = Task(
277
- name="Security Check",
278
- goal=["Identify security vulnerabilities"],
279
- description="Perform a thorough security review on the project.",
280
- dependencies=["./src/main.py"]
281
- )
282
-
283
- vulnerabilities = await toolbox_usage.gather_tools_fine_grind(task)
284
- for vulnerability in vulnerabilities:
285
- print(f"Found vulnerability: {vulnerability.name}")
277
+ task = Task(
278
+ name="Security Check",
279
+ goals=["Identify security vulnerabilities"],
280
+ description="Perform a thorough security review on the project.",
281
+ dependencies=["./src/main.py"]
282
+ )
283
+
284
+ vulnerabilities = await toolbox_usage.gather_tools_fine_grind(task)
285
+ for vulnerability in vulnerabilities:
286
+ print(f"Found vulnerability: {vulnerability.name}")
286
287
  ```
287
288
 
288
289
  #### Managing CTF Challenges
@@ -295,19 +296,22 @@ from fabricatio.models.task import Task
295
296
 
296
297
  toolbox_usage = ToolBoxUsage()
297
298
 
299
+
298
300
  async def solve_ctf_challenge(challenge_name: str, challenge_description: str, files: list[str]):
299
- task = Task(
300
- name=challenge_name,
301
- goal=[f"Solve {challenge_name} challenge"],
302
- description=challenge_description,
303
- dependencies=files
304
- )
305
-
306
- solution = await toolbox_usage.gather_tools_fine_grind(task)
307
- print(f"Challenge Solved: {solution}")
301
+ task = Task(
302
+ name=challenge_name,
303
+ goals=[f"Solve {challenge_name} challenge"],
304
+ description=challenge_description,
305
+ dependencies=files
306
+ )
307
+
308
+ solution = await toolbox_usage.gather_tools_fine_grind(task)
309
+ print(f"Challenge Solved: {solution}")
310
+
308
311
 
309
312
  if __name__ == "__main__":
310
- asyncio.run(solve_ctf_challenge("Binary Exploitation", "CTF Binary Exploitation Challenge", ["./challenges/binary_exploit"]))
313
+ asyncio.run(
314
+ solve_ctf_challenge("Binary Exploitation", "CTF Binary Exploitation Challenge", ["./challenges/binary_exploit"]))
311
315
  ```
312
316
 
313
317
  ### Configuration
@@ -18,8 +18,8 @@ class WriteDiary(Action):
18
18
  output_key: str = "dump_text"
19
19
 
20
20
  async def _execute(self, task_input: Task[str], **_) -> str:
21
- task_input.goal.clear()
22
- task_input.goal.extend(
21
+ task_input.goals.clear()
22
+ task_input.goals.extend(
23
23
  [
24
24
  "write a Internship Diary according to the given commit messages",
25
25
  "the diary should include the main dev target of the day, and the exact content"
@@ -5,7 +5,7 @@ from typing import Any
5
5
 
6
6
  from fabricatio import Action, Role, Task, WorkFlow, logger
7
7
 
8
- task = Task(name="say hello", goal=["say hello"], description="say hello to the world")
8
+ task = Task(name="say hello", goals=["say hello"], description="say hello to the world")
9
9
 
10
10
 
11
11
  class Hello(Action):
@@ -5,7 +5,7 @@ from typing import Any
5
5
 
6
6
  from fabricatio import Action, Role, Task, WorkFlow, logger
7
7
 
8
- task = Task(name="say hello", goal=["say hello"], description="say hello to the world")
8
+ task = Task(name="say hello", goals=["say hello"], description="say hello to the world")
9
9
 
10
10
 
11
11
  class Talk(Action):
@@ -0,0 +1,47 @@
1
+ """Simple chat example."""
2
+
3
+ import asyncio
4
+
5
+ from fabricatio import Action, Role, Task, WorkFlow, logger
6
+ from fabricatio.models.events import Event
7
+ from questionary import text
8
+
9
+
10
+ class Talk(Action):
11
+ """Action that says hello to the world."""
12
+
13
+ name: str = "talk"
14
+ output_key: str = "task_output"
15
+
16
+ async def _execute(self, task_input: Task[str], **_) -> int:
17
+ counter = 0
18
+ try:
19
+ while True:
20
+ user_say = await text("User: ").ask_async()
21
+ gpt_say = await self.aask(
22
+ user_say,
23
+ system_message=f"You have to answer to user obeying task assigned to you:\n{task_input.briefing}",
24
+ )
25
+ print(f"GPT: {gpt_say}") # noqa: T201
26
+ counter += 1
27
+ except KeyboardInterrupt:
28
+ logger.info(f"executed talk action {counter} times")
29
+ return counter
30
+
31
+
32
+ async def main() -> None:
33
+ """Main function."""
34
+ role = Role(
35
+ name="talker",
36
+ description="talker role",
37
+ registry={Event.instantiate_from("talk").push_wildcard().push("pending"): WorkFlow(name="talk", steps=(Talk,))},
38
+ )
39
+
40
+ task = await role.propose(
41
+ "you have to act as a helpful assistant, answer to all user questions properly and patiently"
42
+ )
43
+ _ = await task.delegate("talk")
44
+
45
+
46
+ if __name__ == "__main__":
47
+ asyncio.run(main())
@@ -0,0 +1,66 @@
1
+ """Simple chat example."""
2
+
3
+ import asyncio
4
+
5
+ from fabricatio import RAG, Action, Role, Task, WorkFlow, logger
6
+ from fabricatio.models.events import Event
7
+ from questionary import text
8
+
9
+
10
+ class Talk(Action, RAG):
11
+ """Action that says hello to the world."""
12
+
13
+ name: str = "talk"
14
+ output_key: str = "task_output"
15
+
16
+ async def _execute(self, task_input: Task[str], **_) -> int:
17
+ counter = 0
18
+
19
+ self.init_client().view("test_collection", create=True)
20
+ await self.consume_string(
21
+ [
22
+ "Company policy clearly stipulates that all employees must arrive at the headquarters building located at 88 Jianguo Road, Chaoyang District, Beijing before 9 AM daily.",
23
+ "According to the latest revised health and safety guidelines, employees must wear company-provided athletic gear when using the company gym facilities.",
24
+ "Section 3.2.1 of the employee handbook states that pets are not allowed in the office area under any circumstances.",
25
+ "To promote work efficiency, the company has quiet workspaces at 100 Century Avenue, Pudong New District, Shanghai, for employees who need high concentration for their work.",
26
+ "According to the company's remote work policy, employees can apply for a maximum of 5 days of working from home per month, but must submit the application one week in advance.",
27
+ "The company has strict regulations on overtime. Unless approved by direct supervisors, no form of work is allowed after 9 PM.",
28
+ "Regarding the new regulations for business travel reimbursement, all traveling personnel must submit detailed expense reports within five working days after returning.",
29
+ "Company address: 123 East Sports Road, Tianhe District, Guangzhou, Postal Code: 510620.",
30
+ "Annual team building activities will be held in the second quarter of each year, usually at a resort within a two-hour drive from the Guangzhou headquarters.",
31
+ "Employees who are late more than three times will receive a formal warning, which may affect their year-end performance evaluation.",
32
+ ]
33
+ )
34
+ try:
35
+ while True:
36
+ user_say = await text("User: ").ask_async()
37
+ if user_say is None:
38
+ break
39
+ gpt_say = await self.aask_retrieved(
40
+ user_say,
41
+ user_say,
42
+ extra_system_message=f"You have to answer to user obeying task assigned to you:\n{task_input.briefing}",
43
+ )
44
+ print(f"GPT: {gpt_say}") # noqa: T201
45
+ counter += 1
46
+ except KeyboardInterrupt:
47
+ logger.info(f"executed talk action {counter} times")
48
+ return counter
49
+
50
+
51
+ async def main() -> None:
52
+ """Main function."""
53
+ role = Role(
54
+ name="talker",
55
+ description="talker role but with rag",
56
+ registry={Event.instantiate_from("talk").push_wildcard().push("pending"): WorkFlow(name="talk", steps=(Talk,))},
57
+ )
58
+
59
+ task = await role.propose(
60
+ "you have to act as a helpful assistant, answer to all user questions properly and patiently"
61
+ )
62
+ _ = await task.delegate("talk")
63
+
64
+
65
+ if __name__ == "__main__":
66
+ asyncio.run(main())
@@ -56,6 +56,30 @@ class WriteDocumentation(Action):
56
56
  return await self.aask(task_input.briefing, system_message=task_input.dependencies_prompt)
57
57
 
58
58
 
59
+ class TestCancel(Action):
60
+ """Action that says hello to the world."""
61
+
62
+ name: str = "cancel"
63
+ description: str = "cancel the task"
64
+ output_key: str = "counter"
65
+
66
+ async def _execute(self, counter: int, **_) -> int:
67
+ logger.info(f"Counter: {counter}")
68
+ await asyncio.sleep(5)
69
+ counter += 1
70
+ return counter
71
+
72
+
73
+ class WriteToOutput(Action):
74
+ """Action that says hello to the world."""
75
+
76
+ name: str = "write to output"
77
+ output_key: str = "task_output"
78
+
79
+ async def _execute(self, **_) -> str:
80
+ return "hi, this is the output"
81
+
82
+
59
83
  async def main() -> None:
60
84
  """Main function."""
61
85
  role = Role(
@@ -68,20 +92,32 @@ async def main() -> None:
68
92
  Event.instantiate_from("doc").push_wildcard().push("pending"): WorkFlow(
69
93
  name="write documentation", steps=(WriteDocumentation, DumpText)
70
94
  ),
95
+ Event.instantiate_from("cancel_test").push_wildcard().push("pending"): WorkFlow(
96
+ name="cancel_test",
97
+ steps=(TestCancel, TestCancel, TestCancel, TestCancel, TestCancel, TestCancel, WriteToOutput),
98
+ extra_init_context={"counter": 0},
99
+ ),
71
100
  },
72
101
  )
73
102
 
74
- prompt = "i want you to write a cli app implemented with python , which can calculate the sum to a given n, all write to a single file names `cli.py`, put it in `output` folder."
75
-
76
- proposed_task = await role.propose(prompt)
77
- path = await proposed_task.move_to("coding").delegate()
103
+ proposed_task = await role.propose(
104
+ "i want you to write a cli app implemented with python , which can calculate the sum to a given n, all write to a single file names `cli.py`, put it in `output` folder."
105
+ )
106
+ path = await proposed_task.delegate("coding")
78
107
  logger.success(f"Code Path: {path}")
79
108
 
80
- proposed_task = await role.propose(f"write Readme.md file for the code, source file {path},save it in `README.md`")
81
- proposed_task.override_dependencies([path])
82
- doc = await proposed_task.move_to("doc").delegate()
109
+ proposed_task = await role.propose(
110
+ f"write Readme.md file for the code, source file {path},save it in `README.md`,which is in the `output` folder, too."
111
+ )
112
+ proposed_task.override_dependencies(path)
113
+ doc = await proposed_task.delegate("doc")
83
114
  logger.success(f"Documentation: \n{doc}")
84
115
 
116
+ proposed_task.publish("cancel_test")
117
+ await proposed_task.cancel()
118
+ out = await proposed_task.get_output()
119
+ logger.info(f"Canceled Task Output: {out}")
120
+
85
121
 
86
122
  if __name__ == "__main__":
87
123
  asyncio.run(main())
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fabricatio"
3
- version = "0.2.2"
3
+ version = "0.2.3"
4
4
  description = "A LLM multi-agent framework."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -1,5 +1,7 @@
1
1
  """Fabricatio is a Python library for building llm app using event-based agent structure."""
2
2
 
3
+ from importlib.util import find_spec
4
+
3
5
  from fabricatio._rust_instances import template_manager
4
6
  from fabricatio.core import env
5
7
  from fabricatio.fs import magika
@@ -35,3 +37,9 @@ __all__ = [
35
37
  "task_toolbox",
36
38
  "template_manager",
37
39
  ]
40
+
41
+
42
+ if find_spec("pymilvus"):
43
+ from fabricatio.capabilities.rag import RAG
44
+
45
+ __all__ += ["RAG"]