lionagi 0.0.316__py3-none-any.whl → 0.1.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. lionagi/core/__init__.py +19 -8
  2. lionagi/core/agent/__init__.py +0 -3
  3. lionagi/core/agent/base_agent.py +25 -30
  4. lionagi/core/branch/__init__.py +0 -4
  5. lionagi/core/branch/{base_branch.py → base.py} +12 -13
  6. lionagi/core/branch/branch.py +22 -19
  7. lionagi/core/branch/executable_branch.py +0 -347
  8. lionagi/core/branch/{branch_flow_mixin.py → flow_mixin.py} +5 -5
  9. lionagi/core/direct/__init__.py +10 -1
  10. lionagi/core/direct/cot.py +61 -26
  11. lionagi/core/direct/plan.py +10 -8
  12. lionagi/core/direct/predict.py +5 -5
  13. lionagi/core/direct/react.py +8 -8
  14. lionagi/core/direct/score.py +4 -4
  15. lionagi/core/direct/select.py +4 -4
  16. lionagi/core/direct/utils.py +7 -4
  17. lionagi/core/direct/vote.py +2 -2
  18. lionagi/core/execute/base_executor.py +47 -0
  19. lionagi/core/execute/branch_executor.py +296 -0
  20. lionagi/core/execute/instruction_map_executor.py +179 -0
  21. lionagi/core/execute/neo4j_executor.py +381 -0
  22. lionagi/core/execute/structure_executor.py +314 -0
  23. lionagi/core/flow/monoflow/ReAct.py +20 -20
  24. lionagi/core/flow/monoflow/chat.py +6 -6
  25. lionagi/core/flow/monoflow/chat_mixin.py +23 -33
  26. lionagi/core/flow/monoflow/followup.py +14 -15
  27. lionagi/core/flow/polyflow/chat.py +15 -12
  28. lionagi/core/{prompt/action_template.py → form/action_form.py} +2 -2
  29. lionagi/core/{prompt → form}/field_validator.py +40 -31
  30. lionagi/core/form/form.py +302 -0
  31. lionagi/core/form/mixin.py +214 -0
  32. lionagi/core/{prompt/scored_template.py → form/scored_form.py} +2 -2
  33. lionagi/core/generic/__init__.py +37 -0
  34. lionagi/core/generic/action.py +26 -0
  35. lionagi/core/generic/component.py +455 -0
  36. lionagi/core/generic/condition.py +44 -0
  37. lionagi/core/generic/data_logger.py +305 -0
  38. lionagi/core/generic/edge.py +162 -0
  39. lionagi/core/generic/mail.py +90 -0
  40. lionagi/core/generic/mailbox.py +36 -0
  41. lionagi/core/generic/node.py +285 -0
  42. lionagi/core/generic/relation.py +70 -0
  43. lionagi/core/generic/signal.py +22 -0
  44. lionagi/core/generic/structure.py +362 -0
  45. lionagi/core/generic/transfer.py +20 -0
  46. lionagi/core/generic/work.py +40 -0
  47. lionagi/core/graph/graph.py +126 -0
  48. lionagi/core/graph/tree.py +190 -0
  49. lionagi/core/mail/__init__.py +0 -8
  50. lionagi/core/mail/mail_manager.py +15 -12
  51. lionagi/core/mail/schema.py +9 -2
  52. lionagi/core/messages/__init__.py +0 -3
  53. lionagi/core/messages/schema.py +17 -225
  54. lionagi/core/session/__init__.py +0 -3
  55. lionagi/core/session/session.py +24 -22
  56. lionagi/core/tool/__init__.py +3 -1
  57. lionagi/core/tool/tool.py +28 -0
  58. lionagi/core/tool/tool_manager.py +75 -75
  59. lionagi/experimental/directive/evaluator/__init__.py +0 -0
  60. lionagi/experimental/directive/evaluator/ast_evaluator.py +115 -0
  61. lionagi/experimental/directive/evaluator/base_evaluator.py +202 -0
  62. lionagi/experimental/directive/evaluator/sandbox_.py +14 -0
  63. lionagi/experimental/directive/evaluator/script_engine.py +83 -0
  64. lionagi/experimental/directive/parser/__init__.py +0 -0
  65. lionagi/experimental/directive/parser/base_parser.py +215 -0
  66. lionagi/experimental/directive/schema.py +36 -0
  67. lionagi/experimental/directive/template_/__init__.py +0 -0
  68. lionagi/experimental/directive/template_/base_template.py +63 -0
  69. lionagi/experimental/tool/__init__.py +0 -0
  70. lionagi/experimental/tool/function_calling.py +43 -0
  71. lionagi/experimental/tool/manual.py +66 -0
  72. lionagi/experimental/tool/schema.py +59 -0
  73. lionagi/experimental/tool/tool_manager.py +138 -0
  74. lionagi/experimental/tool/util.py +16 -0
  75. lionagi/experimental/work/__init__.py +0 -0
  76. lionagi/experimental/work/_logger.py +25 -0
  77. lionagi/experimental/work/exchange.py +0 -0
  78. lionagi/experimental/work/schema.py +30 -0
  79. lionagi/experimental/work/tests.py +72 -0
  80. lionagi/experimental/work/util.py +0 -0
  81. lionagi/experimental/work/work_function.py +89 -0
  82. lionagi/experimental/work/worker.py +12 -0
  83. lionagi/integrations/bridge/autogen_/__init__.py +0 -0
  84. lionagi/integrations/bridge/autogen_/autogen_.py +124 -0
  85. lionagi/integrations/bridge/llamaindex_/get_index.py +294 -0
  86. lionagi/integrations/bridge/llamaindex_/llama_pack.py +227 -0
  87. lionagi/integrations/bridge/transformers_/__init__.py +0 -0
  88. lionagi/integrations/bridge/transformers_/install_.py +36 -0
  89. lionagi/integrations/chunker/chunk.py +7 -7
  90. lionagi/integrations/config/oai_configs.py +5 -5
  91. lionagi/integrations/config/ollama_configs.py +1 -1
  92. lionagi/integrations/config/openrouter_configs.py +1 -1
  93. lionagi/integrations/loader/load.py +6 -6
  94. lionagi/integrations/loader/load_util.py +8 -8
  95. lionagi/integrations/storage/__init__.py +3 -0
  96. lionagi/integrations/storage/neo4j.py +673 -0
  97. lionagi/integrations/storage/storage_util.py +289 -0
  98. lionagi/integrations/storage/to_csv.py +63 -0
  99. lionagi/integrations/storage/to_excel.py +67 -0
  100. lionagi/libs/ln_api.py +3 -3
  101. lionagi/libs/ln_knowledge_graph.py +405 -0
  102. lionagi/libs/ln_parse.py +43 -6
  103. lionagi/libs/ln_queue.py +101 -0
  104. lionagi/libs/ln_tokenizer.py +57 -0
  105. lionagi/libs/ln_validate.py +288 -0
  106. lionagi/libs/sys_util.py +29 -7
  107. lionagi/lions/__init__.py +0 -0
  108. lionagi/lions/coder/__init__.py +0 -0
  109. lionagi/lions/coder/add_feature.py +20 -0
  110. lionagi/lions/coder/base_prompts.py +22 -0
  111. lionagi/lions/coder/coder.py +121 -0
  112. lionagi/lions/coder/util.py +91 -0
  113. lionagi/lions/researcher/__init__.py +0 -0
  114. lionagi/lions/researcher/data_source/__init__.py +0 -0
  115. lionagi/lions/researcher/data_source/finhub_.py +191 -0
  116. lionagi/lions/researcher/data_source/google_.py +199 -0
  117. lionagi/lions/researcher/data_source/wiki_.py +96 -0
  118. lionagi/lions/researcher/data_source/yfinance_.py +21 -0
  119. lionagi/tests/integrations/__init__.py +0 -0
  120. lionagi/tests/libs/__init__.py +0 -0
  121. lionagi/tests/libs/test_async.py +0 -0
  122. lionagi/tests/libs/test_field_validators.py +353 -0
  123. lionagi/tests/libs/test_queue.py +67 -0
  124. lionagi/tests/test_core/test_base_branch.py +0 -1
  125. lionagi/tests/test_core/test_branch.py +2 -0
  126. lionagi/tests/test_core/test_session_base_util.py +1 -0
  127. lionagi/version.py +1 -1
  128. {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/METADATA +1 -1
  129. lionagi-0.1.1.dist-info/RECORD +190 -0
  130. lionagi/core/prompt/prompt_template.py +0 -312
  131. lionagi/core/schema/__init__.py +0 -22
  132. lionagi/core/schema/action_node.py +0 -29
  133. lionagi/core/schema/base_mixin.py +0 -296
  134. lionagi/core/schema/base_node.py +0 -199
  135. lionagi/core/schema/condition.py +0 -24
  136. lionagi/core/schema/data_logger.py +0 -354
  137. lionagi/core/schema/data_node.py +0 -93
  138. lionagi/core/schema/prompt_template.py +0 -67
  139. lionagi/core/schema/structure.py +0 -912
  140. lionagi/core/tool/manual.py +0 -1
  141. lionagi-0.0.316.dist-info/RECORD +0 -121
  142. /lionagi/core/{branch/base → execute}/__init__.py +0 -0
  143. /lionagi/core/flow/{base/baseflow.py → baseflow.py} +0 -0
  144. /lionagi/core/flow/{base/__init__.py → mono_chat_mixin.py} +0 -0
  145. /lionagi/core/{prompt → form}/__init__.py +0 -0
  146. /lionagi/{tests/test_integrations → core/graph}/__init__.py +0 -0
  147. /lionagi/{tests/test_libs → experimental}/__init__.py +0 -0
  148. /lionagi/{tests/test_libs/test_async.py → experimental/directive/__init__.py} +0 -0
  149. /lionagi/tests/{test_libs → libs}/test_api.py +0 -0
  150. /lionagi/tests/{test_libs → libs}/test_convert.py +0 -0
  151. /lionagi/tests/{test_libs → libs}/test_func_call.py +0 -0
  152. /lionagi/tests/{test_libs → libs}/test_nested.py +0 -0
  153. /lionagi/tests/{test_libs → libs}/test_parse.py +0 -0
  154. /lionagi/tests/{test_libs → libs}/test_sys_util.py +0 -0
  155. {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/LICENSE +0 -0
  156. {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/WHEEL +0 -0
  157. {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,9 @@
1
1
  from abc import ABC
2
2
  from typing import Any, Optional, Union, TypeVar
3
3
 
4
- from ..schema import TOOL_TYPE, Tool
5
- from ..messages import Instruction, System
6
- from ..flow.monoflow import MonoChat, MonoFollowup, MonoReAct
4
+ from lionagi.core.tool import Tool, TOOL_TYPE
5
+ from lionagi.core.messages.schema import Instruction, System
6
+ from lionagi.core.flow.monoflow import MonoChat, MonoFollowup, MonoReAct
7
7
 
8
8
  T = TypeVar("T", bound=Tool)
9
9
 
@@ -20,7 +20,7 @@ class BranchFlowMixin(ABC):
20
20
  out: bool = True,
21
21
  invoke: bool = True,
22
22
  output_fields=None,
23
- prompt_template=None,
23
+ form=None,
24
24
  **kwargs,
25
25
  ) -> Any:
26
26
  flow = MonoChat(self)
@@ -33,7 +33,7 @@ class BranchFlowMixin(ABC):
33
33
  out=out,
34
34
  invoke=invoke,
35
35
  output_fields=output_fields,
36
- prompt_template=prompt_template,
36
+ form=form,
37
37
  **kwargs,
38
38
  )
39
39
 
@@ -7,4 +7,13 @@ from .plan import plan
7
7
  from .cot import chain_of_thoughts, chain_of_react
8
8
 
9
9
 
10
- __all__ = ["predict", "select", "score", "vote", "react", "plan", "chain_of_thoughts", "chain_of_react"]
10
+ __all__ = [
11
+ "predict",
12
+ "select",
13
+ "score",
14
+ "vote",
15
+ "react",
16
+ "plan",
17
+ "chain_of_thoughts",
18
+ "chain_of_react",
19
+ ]
@@ -1,10 +1,8 @@
1
- from typing import Callable
2
1
  from lionagi.libs import convert
3
- from ..tool import func_to_tool
4
- from ..schema import Tool
5
- from .predict import predict
6
- from .plan import plan
7
- from .react import react
2
+
3
+ from lionagi.core.direct.predict import predict
4
+ from lionagi.core.direct.plan import plan
5
+ from lionagi.core.direct.react import react
8
6
 
9
7
  from .utils import _process_tools
10
8
 
@@ -18,37 +16,56 @@ async def chain_of_thoughts(
18
16
  num_steps=3,
19
17
  directive_kwargs={},
20
18
  return_branch=False,
21
- **kwargs
19
+ **kwargs,
22
20
  ):
23
-
21
+
24
22
  out_, outs, answer, reasons, confidence_score = "", [], "", [], 0
25
23
  if branch is not None:
26
- out_ = await plan(sentence, branch=branch, instruction=instruction, num_steps=num_steps, **kwargs)
24
+ out_ = await plan(
25
+ sentence,
26
+ branch=branch,
27
+ instruction=instruction,
28
+ num_steps=num_steps,
29
+ **kwargs,
30
+ )
27
31
  else:
28
- out_, branch = await plan(sentence, instruction=instruction, branch=branch, num_steps=num_steps, return_branch=True, **kwargs)
29
-
32
+ out_, branch = await plan(
33
+ sentence,
34
+ instruction=instruction,
35
+ branch=branch,
36
+ num_steps=num_steps,
37
+ return_branch=True,
38
+ **kwargs,
39
+ )
40
+
30
41
  for i in range(len(out_.plan)):
31
- _out = await predict(branch=branch, instruction=out_.plan[f"step_{i+1}"], reason=reason, confidence_score=confidence_score, **directive_kwargs)
42
+ _out = await predict(
43
+ branch=branch,
44
+ instruction=out_.plan[f"step_{i+1}"],
45
+ reason=reason,
46
+ confidence_score=confidence_score,
47
+ **directive_kwargs,
48
+ )
32
49
  answer += _out.answer
33
50
  if reason:
34
51
  reasons.append(_out.reason)
35
52
  if confidence_score:
36
53
  confidence_score += _out.confidence_score
37
54
  outs.append(_out)
38
-
55
+
39
56
  setattr(out_, "chain_output", outs)
40
57
  setattr(out_, "chain_answer", answer)
41
-
58
+
42
59
  if reason:
43
60
  setattr(out_, "chain_reasons", reasons)
44
61
  if confidence_score:
45
- setattr(out_, "chain_confidence_score", confidence_score/len(outs))
46
-
62
+ setattr(out_, "chain_confidence_score", confidence_score / len(outs))
63
+
47
64
  if return_branch:
48
65
  return out_, branch
49
-
66
+
50
67
  return out_
51
-
68
+
52
69
 
53
70
  async def chain_of_react(
54
71
  sentence=None,
@@ -59,24 +76,42 @@ async def chain_of_react(
59
76
  directive_system=None,
60
77
  directive_kwargs={},
61
78
  return_branch=False,
62
- **kwargs
79
+ **kwargs,
63
80
  ):
64
81
  out_, outs, reasons, actions, action_responses = "", [], [], [], []
65
82
  if branch is not None:
66
- out_ = await plan(sentence, branch=branch, instruction=instruction, num_steps=num_steps, **kwargs)
83
+ out_ = await plan(
84
+ sentence,
85
+ branch=branch,
86
+ instruction=instruction,
87
+ num_steps=num_steps,
88
+ **kwargs,
89
+ )
67
90
  else:
68
- out_, branch = await plan(sentence, instruction=instruction, branch=branch, num_steps=num_steps, return_branch=True, **kwargs)
69
-
91
+ out_, branch = await plan(
92
+ sentence,
93
+ instruction=instruction,
94
+ branch=branch,
95
+ num_steps=num_steps,
96
+ return_branch=True,
97
+ **kwargs,
98
+ )
99
+
70
100
  _process_tools(tools, branch)
71
-
101
+
72
102
  for i in range(len(out_.plan)):
73
- _out = await react(branch=branch, system=directive_system, instruction=out_.plan[f"step_{i+1}"], **directive_kwargs)
103
+ _out = await react(
104
+ branch=branch,
105
+ system=directive_system,
106
+ instruction=out_.plan[f"step_{i+1}"],
107
+ **directive_kwargs,
108
+ )
74
109
  outs.append(_out)
75
110
  reasons.append(_out.reason)
76
111
  actions.append(_out.actions)
77
112
  if _out.action_needed:
78
113
  action_responses.append(_out.action_response)
79
-
114
+
80
115
  setattr(out_, "chain_output", convert.to_list(outs))
81
116
  setattr(out_, "chain_reason", convert.to_list(reasons))
82
117
  setattr(out_, "chain_actions", convert.to_list(actions))
@@ -84,5 +119,5 @@ async def chain_of_react(
84
119
 
85
120
  if return_branch:
86
121
  return out_, branch
87
-
122
+
88
123
  return out_
@@ -2,18 +2,20 @@
2
2
 
3
3
  from lionagi.libs import func_call, ParseUtil
4
4
  from lionagi.integrations.bridge.pydantic_.pydantic_bridge import Field
5
- from ..prompt.scored_template import ScoredTemplate
6
- from ..branch import Branch
5
+ from lionagi.core.form.scored_form import ScoredForm
6
+ from lionagi.core.branch.branch import Branch
7
7
 
8
8
 
9
- class PlanTemplate(ScoredTemplate):
9
+ class PlanTemplate(ScoredForm):
10
10
  template_name: str = "default_plan"
11
11
  sentence: str | list | dict = Field(
12
12
  default_factory=str,
13
13
  description="the given sentence(s) or context to generate a plan for",
14
14
  )
15
- plan: dict | str= Field(
16
- default_factory=dict, description="the generated step by step plan, return as a dictionary following {step_n: {plan: ..., reason: ...}} format")
15
+ plan: dict | str = Field(
16
+ default_factory=dict,
17
+ description="the generated step by step plan, return as a dictionary following {step_n: {plan: ..., reason: ...}} format",
18
+ )
17
19
  signature: str = "sentence -> plan"
18
20
 
19
21
  def __init__(
@@ -89,7 +91,7 @@ async def _plan(
89
91
 
90
92
  await func_call.rcall(
91
93
  branch.chat,
92
- prompt_template=_template,
94
+ form=_template,
93
95
  retries=retries,
94
96
  delay=delay,
95
97
  backoff_factor=backoff_factor,
@@ -97,7 +99,7 @@ async def _plan(
97
99
  timeout=timeout,
98
100
  **kwargs,
99
101
  )
100
-
102
+
101
103
  _template.plan = ParseUtil.fuzzy_parse_json(_template.plan)
102
104
 
103
105
  return (_template, branch) if return_branch else _template
@@ -159,4 +161,4 @@ async def plan(
159
161
  return await _inner()
160
162
 
161
163
  elif num_instances > 1:
162
- return await func_call.alcall(range(num_instances), _inner)
164
+ return await func_call.alcall(range(num_instances), _inner)
@@ -9,11 +9,11 @@ confidence score, and reason for the prediction.
9
9
  from lionagi.libs import func_call
10
10
  from lionagi.integrations.bridge.pydantic_.pydantic_bridge import Field
11
11
 
12
- from ..prompt.scored_template import ScoredTemplate
13
- from ..branch import Branch
12
+ from lionagi.core.form.scored_form import ScoredForm
13
+ from lionagi.core.branch.branch import Branch
14
14
 
15
15
 
16
- class PredictTemplate(ScoredTemplate):
16
+ class PredictTemplate(ScoredForm):
17
17
  """
18
18
  A class for predicting the next sentence(s) based on a given sentence.
19
19
 
@@ -68,7 +68,7 @@ class PredictTemplate(ScoredTemplate):
68
68
  """
69
69
  super().__init__(**kwargs)
70
70
 
71
- self.sentence = sentence or ''
71
+ self.sentence = sentence or ""
72
72
  self.num_sentences = num_sentences
73
73
  self.task = f"follow instruction to predict the next {self.num_sentences} sentence(s). Instruction: {instruction}."
74
74
 
@@ -154,7 +154,7 @@ async def predict(
154
154
 
155
155
  await func_call.rcall(
156
156
  branch.chat,
157
- prompt_template=predict_template,
157
+ form=predict_template,
158
158
  retries=retries,
159
159
  delay=delay,
160
160
  backoff_factor=backoff_factor,
@@ -1,14 +1,14 @@
1
- from lionagi.libs import func_call, convert, AsyncUtil
1
+ from lionagi.libs import func_call, AsyncUtil
2
2
 
3
3
  from lionagi.integrations.bridge.pydantic_.pydantic_bridge import Field
4
- from ..prompt.action_template import ActionedTemplate
5
- from ..branch import Branch
6
- from .utils import _process_tools
4
+ from lionagi.core.form.action_form import ActionForm
5
+ from lionagi.core.branch.branch import Branch
6
+ from lionagi.core.direct.utils import _process_tools
7
7
 
8
8
 
9
- class ReactTemplate(ActionedTemplate):
9
+ class ReactTemplate(ActionForm):
10
10
  template_name: str = "default_react"
11
- sentence: str | list | dict | None= Field(
11
+ sentence: str | list | dict | None = Field(
12
12
  default_factory=str,
13
13
  description="the given sentence(s) to reason and take actions on",
14
14
  )
@@ -61,7 +61,7 @@ async def _react(
61
61
 
62
62
  if branch and tools:
63
63
  _process_tools(tools, branch)
64
-
64
+
65
65
  branch = branch or Branch(
66
66
  name=branch_name,
67
67
  system=system,
@@ -83,7 +83,7 @@ async def _react(
83
83
 
84
84
  await func_call.rcall(
85
85
  branch.chat,
86
- prompt_template=_template,
86
+ form=_template,
87
87
  retries=retries,
88
88
  delay=delay,
89
89
  backoff_factor=backoff_factor,
@@ -12,11 +12,11 @@ ScoreTemplate class and a language model.
12
12
  from pydantic import Field
13
13
  import numpy as np
14
14
  from lionagi.libs import func_call, convert
15
- from ..prompt.scored_template import ScoredTemplate
16
- from ..branch import Branch
15
+ from lionagi.core.form.scored_form import ScoredForm
16
+ from lionagi.core.branch.branch import Branch
17
17
 
18
18
 
19
- class ScoreTemplate(ScoredTemplate):
19
+ class ScoreTemplate(ScoredForm):
20
20
  """
21
21
  A class for scoring a given context using a language model.
22
22
 
@@ -169,7 +169,7 @@ async def _score(
169
169
 
170
170
  await func_call.rcall(
171
171
  branch.chat,
172
- prompt_template=_template,
172
+ form=_template,
173
173
  retries=retries,
174
174
  delay=delay,
175
175
  backoff_factor=backoff_factor,
@@ -13,11 +13,11 @@ from enum import Enum
13
13
  from pydantic import Field
14
14
 
15
15
  from lionagi.libs import func_call, StringMatch
16
- from ..prompt.scored_template import ScoredTemplate
17
- from ..branch import Branch
16
+ from lionagi.core.form.scored_form import ScoredForm
17
+ from lionagi.core.branch.branch import Branch
18
18
 
19
19
 
20
- class SelectTemplate(ScoredTemplate):
20
+ class SelectTemplate(ScoredForm):
21
21
  """
22
22
  A class for selecting an item from given choices based on a given context.
23
23
 
@@ -153,7 +153,7 @@ async def select(
153
153
 
154
154
  await func_call.rcall(
155
155
  branch.chat,
156
- prompt_template=_template,
156
+ form=_template,
157
157
  retries=retries,
158
158
  delay=delay,
159
159
  backoff_factor=backoff_factor,
@@ -1,6 +1,6 @@
1
1
  from typing import Callable
2
- from ..tool import func_to_tool
3
- from ..schema import Tool
2
+ from lionagi.core.tool import func_to_tool, Tool
3
+
4
4
  # import contextlib
5
5
  # from lionagi.libs import ParseUtil, StringMatch, convert, func_call
6
6
 
@@ -99,9 +99,12 @@ def _process_tools(tool_obj, branch):
99
99
 
100
100
 
101
101
  def _process_tool(tool_obj, branch):
102
- if isinstance(tool_obj, Tool) and tool_obj.schema_["function"]["name"] not in branch.tool_manager.registry:
102
+ if (
103
+ isinstance(tool_obj, Tool)
104
+ and tool_obj.schema_["function"]["name"] not in branch.tool_manager.registry
105
+ ):
103
106
  branch.register_tools(tool_obj)
104
107
  if isinstance(tool_obj, Callable):
105
108
  tool = func_to_tool(tool_obj)[0]
106
109
  if tool.schema_["function"]["name"] not in branch.tool_manager.registry:
107
- branch.register_tools(tool)
110
+ branch.register_tools(tool)
@@ -8,8 +8,8 @@ number of generations, number of outputs to return, number of scorers, score ran
8
8
 
9
9
  from lionagi.libs import func_call
10
10
  import numpy as np
11
- from .predict import predict
12
- from .score import score
11
+ from lionagi.core.direct.predict import predict
12
+ from lionagi.core.direct.score import score
13
13
 
14
14
 
15
15
  async def vote(
@@ -0,0 +1,47 @@
1
+ from collections import deque
2
+ from abc import ABC, abstractmethod
3
+ from typing import Any
4
+
5
+ from pydantic import Field
6
+
7
+ from lionagi.core.generic import BaseComponent
8
+ from lionagi.core.mail.schema import BaseMail
9
+
10
+
11
+ class BaseExecutor(BaseComponent, ABC):
12
+ pending_ins: dict = Field(
13
+ default_factory=dict, description="The pending incoming mails."
14
+ )
15
+ pending_outs: deque = Field(
16
+ default_factory=deque, description="The pending outgoing mails."
17
+ )
18
+ execute_stop: bool = Field(
19
+ False, description="A flag indicating whether to stop execution."
20
+ )
21
+ context: dict | str | list | None = Field(
22
+ None, description="The context buffer for the next instruction."
23
+ )
24
+ execution_responses: list = Field(
25
+ default_factory=list, description="The list of responses."
26
+ )
27
+ context_log: list = Field(default_factory=list, description="The context log.")
28
+ verbose: bool = Field(
29
+ True, description="A flag indicating whether to provide verbose output."
30
+ )
31
+
32
+ def send(self, recipient_id: str, category: str, package: Any) -> None:
33
+ """
34
+ Sends a mail to a recipient.
35
+
36
+ Args:
37
+ recipient_id (str): The ID of the recipient.
38
+ category (str): The category of the mail.
39
+ package (Any): The package to send in the mail.
40
+ """
41
+ mail = BaseMail(
42
+ sender_id=self.id_,
43
+ recipient_id=recipient_id,
44
+ category=category,
45
+ package=package,
46
+ )
47
+ self.pending_outs.append(mail)