lionagi 0.0.305__py3-none-any.whl → 0.0.307__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.
Files changed (84) hide show
  1. lionagi/__init__.py +2 -5
  2. lionagi/core/__init__.py +7 -4
  3. lionagi/core/agent/__init__.py +3 -0
  4. lionagi/core/agent/base_agent.py +46 -0
  5. lionagi/core/branch/__init__.py +4 -0
  6. lionagi/core/branch/base/__init__.py +0 -0
  7. lionagi/core/branch/base_branch.py +100 -78
  8. lionagi/core/branch/branch.py +22 -34
  9. lionagi/core/branch/branch_flow_mixin.py +3 -7
  10. lionagi/core/branch/executable_branch.py +192 -0
  11. lionagi/core/branch/util.py +77 -162
  12. lionagi/core/direct/__init__.py +13 -0
  13. lionagi/core/direct/parallel_predict.py +127 -0
  14. lionagi/core/direct/parallel_react.py +0 -0
  15. lionagi/core/direct/parallel_score.py +0 -0
  16. lionagi/core/direct/parallel_select.py +0 -0
  17. lionagi/core/direct/parallel_sentiment.py +0 -0
  18. lionagi/core/direct/predict.py +174 -0
  19. lionagi/core/direct/react.py +33 -0
  20. lionagi/core/direct/score.py +163 -0
  21. lionagi/core/direct/select.py +144 -0
  22. lionagi/core/direct/sentiment.py +51 -0
  23. lionagi/core/direct/utils.py +83 -0
  24. lionagi/core/flow/__init__.py +0 -3
  25. lionagi/core/flow/monoflow/{mono_react.py → ReAct.py} +52 -9
  26. lionagi/core/flow/monoflow/__init__.py +9 -0
  27. lionagi/core/flow/monoflow/{mono_chat.py → chat.py} +11 -11
  28. lionagi/core/flow/monoflow/{mono_chat_mixin.py → chat_mixin.py} +33 -27
  29. lionagi/core/flow/monoflow/{mono_followup.py → followup.py} +7 -6
  30. lionagi/core/flow/polyflow/__init__.py +1 -0
  31. lionagi/core/flow/polyflow/{polychat.py → chat.py} +15 -3
  32. lionagi/core/mail/__init__.py +8 -0
  33. lionagi/core/mail/mail_manager.py +88 -40
  34. lionagi/core/mail/schema.py +32 -6
  35. lionagi/core/messages/__init__.py +3 -0
  36. lionagi/core/messages/schema.py +56 -25
  37. lionagi/core/prompt/__init__.py +0 -0
  38. lionagi/core/prompt/prompt_template.py +0 -0
  39. lionagi/core/schema/__init__.py +7 -5
  40. lionagi/core/schema/action_node.py +29 -0
  41. lionagi/core/schema/base_mixin.py +56 -59
  42. lionagi/core/schema/base_node.py +35 -38
  43. lionagi/core/schema/condition.py +24 -0
  44. lionagi/core/schema/data_logger.py +98 -98
  45. lionagi/core/schema/data_node.py +19 -19
  46. lionagi/core/schema/prompt_template.py +0 -0
  47. lionagi/core/schema/structure.py +293 -190
  48. lionagi/core/session/__init__.py +1 -3
  49. lionagi/core/session/session.py +196 -214
  50. lionagi/core/tool/tool_manager.py +95 -103
  51. lionagi/integrations/__init__.py +1 -3
  52. lionagi/integrations/bridge/langchain_/documents.py +17 -18
  53. lionagi/integrations/bridge/langchain_/langchain_bridge.py +14 -14
  54. lionagi/integrations/bridge/llamaindex_/llama_index_bridge.py +22 -22
  55. lionagi/integrations/bridge/llamaindex_/node_parser.py +12 -12
  56. lionagi/integrations/bridge/llamaindex_/reader.py +11 -11
  57. lionagi/integrations/bridge/llamaindex_/textnode.py +7 -7
  58. lionagi/integrations/config/openrouter_configs.py +0 -1
  59. lionagi/integrations/provider/oai.py +26 -26
  60. lionagi/integrations/provider/services.py +38 -38
  61. lionagi/libs/__init__.py +34 -1
  62. lionagi/libs/ln_api.py +211 -221
  63. lionagi/libs/ln_async.py +53 -60
  64. lionagi/libs/ln_convert.py +118 -120
  65. lionagi/libs/ln_dataframe.py +32 -33
  66. lionagi/libs/ln_func_call.py +334 -342
  67. lionagi/libs/ln_nested.py +99 -107
  68. lionagi/libs/ln_parse.py +175 -158
  69. lionagi/libs/sys_util.py +52 -52
  70. lionagi/tests/test_core/test_base_branch.py +427 -427
  71. lionagi/tests/test_core/test_branch.py +292 -292
  72. lionagi/tests/test_core/test_mail_manager.py +57 -57
  73. lionagi/tests/test_core/test_session.py +254 -266
  74. lionagi/tests/test_core/test_session_base_util.py +299 -300
  75. lionagi/tests/test_core/test_tool_manager.py +70 -74
  76. lionagi/tests/test_libs/test_nested.py +2 -7
  77. lionagi/tests/test_libs/test_parse.py +2 -2
  78. lionagi/version.py +1 -1
  79. {lionagi-0.0.305.dist-info → lionagi-0.0.307.dist-info}/METADATA +4 -2
  80. lionagi-0.0.307.dist-info/RECORD +115 -0
  81. lionagi-0.0.305.dist-info/RECORD +0 -94
  82. {lionagi-0.0.305.dist-info → lionagi-0.0.307.dist-info}/LICENSE +0 -0
  83. {lionagi-0.0.305.dist-info → lionagi-0.0.307.dist-info}/WHEEL +0 -0
  84. {lionagi-0.0.305.dist-info → lionagi-0.0.307.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,10 @@
1
1
  from enum import Enum
2
2
 
3
- from lionagi.libs import ln_nested as nested
4
- from lionagi.libs import ln_convert as convert
3
+ from lionagi.libs import nested, convert
4
+ from ..schema import DataNode
5
5
 
6
- from lionagi.core.schema.data_node import DataNode
6
+ _message_fields = ["node_id", "timestamp", "role", "sender", "recipient", "content"]
7
7
 
8
- _message_fields = ["node_id", "timestamp", "role", "sender", "content"]
9
8
 
10
9
  # ToDo: actually implement the new message classes
11
10
 
@@ -99,13 +98,14 @@ class BaseMessage(DataNode):
99
98
  Represents a message in a chatbot-like system, inheriting from BaseNode.
100
99
 
101
100
  Attributes:
102
- role (str | None): The role of the entity sending the message, e.g., 'user', 'system'.
103
- sender (str | None): The identifier of the sender of the message.
104
- content (Any): The actual content of the message.
101
+ role (str | None): The role of the entity sending the message, e.g., 'user', 'system'.
102
+ sender (str | None): The identifier of the sender of the message.
103
+ content (Any): The actual content of the message.
105
104
  """
106
105
 
107
106
  role: str | None = None
108
107
  sender: str | None = None
108
+ recipient: str | None = None
109
109
 
110
110
  @property
111
111
  def msg(self) -> dict:
@@ -113,7 +113,7 @@ class BaseMessage(DataNode):
113
113
  Constructs and returns a dictionary representation of the message.
114
114
 
115
115
  Returns:
116
- A dictionary representation of the message with 'role' and 'content' keys.
116
+ A dictionary representation of the message with 'role' and 'content' keys.
117
117
  """
118
118
  return self._to_message()
119
119
 
@@ -123,7 +123,7 @@ class BaseMessage(DataNode):
123
123
  Gets the 'content' field of the message.
124
124
 
125
125
  Returns:
126
- The 'content' part of the message.
126
+ The 'content' part of the message.
127
127
  """
128
128
  return self.msg["content"]
129
129
 
@@ -132,14 +132,13 @@ class BaseMessage(DataNode):
132
132
  Constructs and returns a dictionary representation of the message.
133
133
 
134
134
  Returns:
135
- dict: A dictionary representation of the message with 'role' and 'content' keys.
135
+ dict: A dictionary representation of the message with 'role' and 'content' keys.
136
136
  """
137
- out = {"role": self.role, "content": convert.to_str(self.content)}
138
- return out
137
+ return {"role": self.role, "content": convert.to_str(self.content)}
139
138
 
140
139
  def __str__(self):
141
140
  content_preview = (
142
- (str(self.content)[:75] + "...")
141
+ f"{str(self.content)[:75]}..."
143
142
  if self.content and len(self.content) > 75
144
143
  else str(self.content)
145
144
  )
@@ -160,9 +159,13 @@ class Instruction(BaseMessage):
160
159
  context=None,
161
160
  sender: str | None = None,
162
161
  output_fields=None,
163
- ):
162
+ recipient=None,
163
+ ): # sourcery skip: avoid-builtin-shadow
164
164
  super().__init__(
165
- role="user", sender=sender or "user", content={"instruction": instruction}
165
+ role="user",
166
+ sender=sender or "user",
167
+ content={"instruction": instruction},
168
+ recipient=recipient or "assistant",
166
169
  )
167
170
  if context:
168
171
  self.content.update({"context": context})
@@ -176,6 +179,10 @@ class Instruction(BaseMessage):
176
179
  """
177
180
  self.content.update({"response_format": format})
178
181
 
182
+ @property
183
+ def instruct(self):
184
+ return self.content["instruction"]
185
+
179
186
 
180
187
  class System(BaseMessage):
181
188
  """
@@ -184,11 +191,20 @@ class System(BaseMessage):
184
191
  Designed for messages containing system information, this class sets the message role to 'system'.
185
192
  """
186
193
 
187
- def __init__(self, system: dict | list | str, sender: str | None = None):
194
+ def __init__(
195
+ self, system: dict | list | str, sender: str | None = None, recipient=None
196
+ ):
188
197
  super().__init__(
189
- role="system", sender=sender or "system", content={"system_info": system}
198
+ role="system",
199
+ sender=sender or "system",
200
+ content={"system_info": system},
201
+ recipient=recipient or "assistant",
190
202
  )
191
203
 
204
+ @property
205
+ def system_info(self):
206
+ return self.content["system_info"]
207
+
192
208
 
193
209
  class Response(BaseMessage):
194
210
  """
@@ -199,7 +215,9 @@ class Response(BaseMessage):
199
215
 
200
216
  """
201
217
 
202
- def __init__(self, response: dict | list | str, sender: str | None = None) -> None:
218
+ def __init__(
219
+ self, response: dict | list | str, sender: str | None = None, recipient=None
220
+ ) -> None:
203
221
  content_key = ""
204
222
  try:
205
223
  response = response["message"]
@@ -207,6 +225,7 @@ class Response(BaseMessage):
207
225
  content_ = self._handle_action_request(response)
208
226
  sender = sender or "action_request"
209
227
  content_key = content_key or "action_request"
228
+ recipient = recipient or "action"
210
229
 
211
230
  else:
212
231
  try:
@@ -214,32 +233,44 @@ class Response(BaseMessage):
214
233
  content_ = convert.to_dict(response["content"])["tool_uses"]
215
234
  content_key = content_key or "action_request"
216
235
  sender = sender or "action_request"
236
+ recipient = recipient or "action"
237
+
217
238
  elif "response" in convert.to_dict(response["content"]):
218
239
  sender = sender or "assistant"
219
240
  content_key = content_key or "response"
220
241
  content_ = convert.to_dict(response["content"])["response"]
242
+ recipient = recipient or "user"
243
+
221
244
  elif "action_request" in convert.to_dict(response["content"]):
222
245
  sender = sender or "action_request"
223
246
  content_key = content_key or "action_request"
224
247
  content_ = convert.to_dict(response["content"])[
225
248
  "action_request"
226
249
  ]
250
+ recipient = recipient or "action"
251
+
227
252
  else:
228
253
  content_ = response["content"]
229
254
  content_key = content_key or "response"
230
255
  sender = sender or "assistant"
231
- except:
256
+ recipient = recipient or "user"
257
+ except Exception:
232
258
  content_ = response["content"]
233
259
  content_key = content_key or "response"
234
260
  sender = sender or "assistant"
261
+ recipient = recipient or "user"
235
262
 
236
- except:
263
+ except Exception:
237
264
  sender = sender or "action_response"
238
265
  content_ = response
239
266
  content_key = content_key or "action_response"
267
+ recipient = recipient or "assistant"
240
268
 
241
269
  super().__init__(
242
- role="assistant", sender=sender, content={content_key: content_}
270
+ role="assistant",
271
+ sender=sender,
272
+ content={content_key: content_},
273
+ recipient=recipient,
243
274
  )
244
275
 
245
276
  @staticmethod
@@ -248,13 +279,13 @@ class Response(BaseMessage):
248
279
  Processes an action request response and extracts relevant information.
249
280
 
250
281
  Args:
251
- response (dict): The response dictionary containing tool calls and other information.
282
+ response (dict): The response dictionary containing tool calls and other information.
252
283
 
253
284
  Returns:
254
- list: A list of dictionaries, each representing a function call with action and arguments.
285
+ list: A list of dictionaries, each representing a function call with action and arguments.
255
286
 
256
287
  Raises:
257
- ValueError: If the response does not conform to the expected format for action requests.
288
+ ValueError: If the response does not conform to the expected format for action requests.
258
289
  """
259
290
  try:
260
291
  tool_count = 0
@@ -267,7 +298,7 @@ class Response(BaseMessage):
267
298
  _path2 = ["tool_calls", tool_count, "function", "arguments"]
268
299
 
269
300
  func_content = {
270
- "action": ("action_" + nested.nget(response, _path1)),
301
+ "action": f"action_{nested.nget(response, _path1)}",
271
302
  "arguments": nested.nget(response, _path2),
272
303
  }
273
304
  func_list.append(func_content)
File without changes
File without changes
@@ -1,17 +1,19 @@
1
- from .base_node import BaseNode, BaseRelatableNode, Tool
2
- from .data_logger import DataLogger, DLog
1
+ from .base_node import BaseNode, BaseRelatableNode, Tool, TOOL_TYPE
3
2
  from .data_node import DataNode
3
+ from .data_logger import DLog, DataLogger
4
4
  from .structure import Relationship, Graph, Structure
5
-
5
+ from .action_node import ActionNode
6
6
 
7
7
  __all__ = [
8
- "DLog",
9
8
  "BaseNode",
10
9
  "BaseRelatableNode",
11
10
  "Tool",
12
- "DataLogger",
13
11
  "DataNode",
12
+ "DLog",
13
+ "DataLogger",
14
14
  "Relationship",
15
15
  "Graph",
16
16
  "Structure",
17
+ "ActionNode",
18
+ "TOOL_TYPE",
17
19
  ]
@@ -0,0 +1,29 @@
1
+ from enum import Enum
2
+
3
+ from .base_node import BaseNode
4
+
5
+
6
+ class ActionSelection(BaseNode):
7
+
8
+ def __init__(self, action: str = "chat", action_kwargs=None):
9
+ if action_kwargs is None:
10
+ action_kwargs = {}
11
+ super().__init__()
12
+ self.action = action
13
+ self.action_kwargs = action_kwargs
14
+
15
+
16
+ class ActionNode(BaseNode):
17
+
18
+ def __init__(
19
+ self, instruction, action: str = "chat", tools=None, action_kwargs=None
20
+ ):
21
+ if tools is None:
22
+ tools = []
23
+ if action_kwargs is None:
24
+ action_kwargs = {}
25
+ super().__init__()
26
+ self.instruction = instruction
27
+ self.action = action
28
+ self.tools = tools
29
+ self.action_kwargs = action_kwargs
@@ -5,10 +5,7 @@ from typing import Any, TypeVar, Type, Callable
5
5
  import pandas as pd
6
6
  from pydantic import BaseModel, ValidationError
7
7
 
8
- import lionagi.libs.ln_nested as nested
9
- import lionagi.libs.ln_convert as convert
10
- from lionagi.libs.ln_parse import ParseUtil
11
- from lionagi.libs.sys_util import SysUtil
8
+ from lionagi.libs import nested, convert, ParseUtil, SysUtil
12
9
 
13
10
  T = TypeVar("T") # Generic type for return type of from_obj method
14
11
 
@@ -24,12 +21,12 @@ class BaseToObjectMixin(ABC, BaseModel):
24
21
  string. It supports passing arbitrary arguments to the underlying `model_dump_json` method.
25
22
 
26
23
  Args:
27
- *args: Variable-length argument list to be passed to `model_dump_json`.
28
- **kwargs: Arbitrary keyword arguments, with `by_alias=True` set by default to use
29
- model field aliases in the output JSON, if any.
24
+ *args: Variable-length argument list to be passed to `model_dump_json`.
25
+ **kwargs: Arbitrary keyword arguments, with `by_alias=True` set by default to use
26
+ model field aliases in the output JSON, if any.
30
27
 
31
28
  Returns:
32
- str: A JSON string representation of the model instance.
29
+ str: A JSON string representation of the model instance.
33
30
  """
34
31
  return self.model_dump_json(*args, by_alias=True, **kwargs)
35
32
 
@@ -42,12 +39,12 @@ class BaseToObjectMixin(ABC, BaseModel):
42
39
  aliases instead of the original field names.
43
40
 
44
41
  Args:
45
- *args: Variable-length argument list for the `model_dump` method.
46
- **kwargs: Arbitrary keyword arguments. By default, `by_alias=True` is applied, indicating
47
- that field aliases should be used as keys in the resulting dictionary.
42
+ *args: Variable-length argument list for the `model_dump` method.
43
+ **kwargs: Arbitrary keyword arguments. By default, `by_alias=True` is applied, indicating
44
+ that field aliases should be used as keys in the resulting dictionary.
48
45
 
49
46
  Returns:
50
- dict[str, Any]: The dictionary representation of the model instance.
47
+ dict[str, Any]: The dictionary representation of the model instance.
51
48
  """
52
49
  return self.model_dump(*args, by_alias=True, **kwargs)
53
50
 
@@ -60,7 +57,7 @@ class BaseToObjectMixin(ABC, BaseModel):
60
57
  The root element of the XML tree is named after the class of the model instance.
61
58
 
62
59
  Returns:
63
- str: An XML string representation of the model instance.
60
+ str: An XML string representation of the model instance.
64
61
  """
65
62
 
66
63
  import xml.etree.ElementTree as ET
@@ -88,15 +85,15 @@ class BaseToObjectMixin(ABC, BaseModel):
88
85
  customize the Series creation through `pd_kwargs`.
89
86
 
90
87
  Args:
91
- *args: Variable-length argument list for the `to_dict` method.
92
- pd_kwargs (dict | None): Optional dictionary of keyword arguments to pass to the pandas
93
- Series constructor. Defaults to None, in which case an empty
94
- dictionary is used.
95
- **kwargs: Arbitrary keyword arguments for the `to_dict` method, influencing the dictionary
96
- representation used for Series creation.
88
+ *args: Variable-length argument list for the `to_dict` method.
89
+ pd_kwargs (dict | None): Optional dictionary of keyword arguments to pass to the pandas
90
+ Series constructor. Defaults to None, in which case an empty
91
+ dictionary is used.
92
+ **kwargs: Arbitrary keyword arguments for the `to_dict` method, influencing the dictionary
93
+ representation used for Series creation.
97
94
 
98
95
  Returns:
99
- pd.Series: A pandas Series representation of the model instance.
96
+ pd.Series: A pandas Series representation of the model instance.
100
97
  """
101
98
  pd_kwargs = {} if pd_kwargs is None else pd_kwargs
102
99
  dict_ = self.to_dict(*args, **kwargs)
@@ -118,15 +115,11 @@ class BaseFromObjectMixin(ABC, BaseModel):
118
115
  @from_obj.register(str)
119
116
  @classmethod
120
117
  def _from_str(cls, obj: str, *args, fuzzy_parse=False, **kwargs) -> T:
121
- if fuzzy_parse:
122
- obj = ParseUtil.fuzzy_parse_json(obj)
123
- else:
124
- obj = convert.to_dict(obj)
125
-
118
+ obj = ParseUtil.fuzzy_parse_json(obj) if fuzzy_parse else convert.to_dict(obj)
126
119
  try:
127
120
  return cls.from_obj(obj, *args, **kwargs)
128
121
  except ValidationError as e:
129
- raise ValueError(f"Invalid JSON for deserialization: {e}")
122
+ raise ValueError(f"Invalid JSON for deserialization: {e}") from e
130
123
 
131
124
  @from_obj.register(list)
132
125
  @classmethod
@@ -135,23 +128,27 @@ class BaseFromObjectMixin(ABC, BaseModel):
135
128
 
136
129
  @from_obj.register(pd.Series)
137
130
  @classmethod
138
- def _from_pd_series(cls, obj: pd.Series, *args, pd_kwargs={}, **kwargs) -> T:
131
+ def _from_pd_series(cls, obj: pd.Series, *args, pd_kwargs=None, **kwargs) -> T:
132
+ if pd_kwargs is None:
133
+ pd_kwargs = {}
139
134
  return cls.from_obj(obj.to_dict(**pd_kwargs), *args, **kwargs)
140
135
 
141
136
  @from_obj.register(pd.DataFrame)
142
137
  @classmethod
143
138
  def _from_pd_dataframe(
144
- cls, obj: pd.DataFrame, *args, pd_kwargs={}, **kwargs
139
+ cls, obj: pd.DataFrame, *args, pd_kwargs=None, **kwargs
145
140
  ) -> list[T]:
141
+ if pd_kwargs is None:
142
+ pd_kwargs = {}
146
143
  return [
147
144
  cls.from_obj(row, *args, **pd_kwargs, **kwargs) for _, row in obj.iterrows()
148
145
  ]
149
146
 
150
147
  @from_obj.register(BaseModel)
151
148
  @classmethod
152
- def _from_base_model(
153
- cls, obj: BaseModel, pydantic_kwargs={"by_alias": True}, **kwargs
154
- ) -> T:
149
+ def _from_base_model(cls, obj: BaseModel, pydantic_kwargs=None, **kwargs) -> T:
150
+ if pydantic_kwargs is None:
151
+ pydantic_kwargs = {"by_alias": True}
155
152
  config_ = {**obj.model_dump(**pydantic_kwargs), **kwargs}
156
153
  return cls.from_obj(**config_)
157
154
 
@@ -163,11 +160,11 @@ class BaseMetaManageMixin(ABC, BaseModel):
163
160
  Retrieves a list of metadata keys.
164
161
 
165
162
  Args:
166
- flattened (bool): If True, returns keys from a flattened metadata structure.
167
- **kwargs: Additional keyword arguments passed to the flattening function.
163
+ flattened (bool): If True, returns keys from a flattened metadata structure.
164
+ **kwargs: Additional keyword arguments passed to the flattening function.
168
165
 
169
166
  Returns:
170
- list[str]: List of metadata keys.
167
+ list[str]: List of metadata keys.
171
168
  """
172
169
  if flattened:
173
170
  return nested.get_flattened_keys(self.metadata, **kwargs)
@@ -178,12 +175,12 @@ class BaseMetaManageMixin(ABC, BaseModel):
178
175
  Checks if a specified key exists in the metadata.
179
176
 
180
177
  Args:
181
- key (str): The key to check.
182
- flattened (bool): If True, checks within a flattened metadata structure.
183
- **kwargs: Additional keyword arguments for flattening.
178
+ key (str): The key to check.
179
+ flattened (bool): If True, checks within a flattened metadata structure.
180
+ **kwargs: Additional keyword arguments for flattening.
184
181
 
185
182
  Returns:
186
- bool: True if key exists, False otherwise.
183
+ bool: True if key exists, False otherwise.
187
184
  """
188
185
  if flattened:
189
186
  return key in nested.get_flattened_keys(self.metadata, **kwargs)
@@ -196,12 +193,12 @@ class BaseMetaManageMixin(ABC, BaseModel):
196
193
  Retrieves the value associated with a given key from the metadata.
197
194
 
198
195
  Args:
199
- key (str): The key for the desired value.
200
- indices: Optional indices for nested retrieval.
201
- default (Any): The default value to return if the key is not found.
196
+ key (str): The key for the desired value.
197
+ indices: Optional indices for nested retrieval.
198
+ default (Any): The default value to return if the key is not found.
202
199
 
203
200
  Returns:
204
- Any: The value associated with the key or the default value.
201
+ Any: The value associated with the key or the default value.
205
202
  """
206
203
  if indices:
207
204
  return nested.nget(self.metadata, key, indices, default)
@@ -212,11 +209,11 @@ class BaseMetaManageMixin(ABC, BaseModel):
212
209
  Renames a key in the metadata.
213
210
 
214
211
  Args:
215
- old_key (str): The current key name.
216
- new_key (str): The new key name.
212
+ old_key (str): The current key name.
213
+ new_key (str): The new key name.
217
214
 
218
215
  Returns:
219
- bool: True if the key was changed, False otherwise.
216
+ bool: True if the key was changed, False otherwise.
220
217
  """
221
218
  if old_key in self.metadata:
222
219
  SysUtil.change_dict_key(self.metadata, old_key, new_key)
@@ -228,12 +225,12 @@ class BaseMetaManageMixin(ABC, BaseModel):
228
225
  Inserts a value into the metadata at specified indices.
229
226
 
230
227
  Args:
231
- indices (str | list): The indices where the value should be inserted.
232
- value (Any): The value to insert.
233
- **kwargs: Additional keyword arguments.
228
+ indices (str | list): The indices where the value should be inserted.
229
+ value (Any): The value to insert.
230
+ **kwargs: Additional keyword arguments.
234
231
 
235
232
  Returns:
236
- bool: True if the insertion was successful, False otherwise.
233
+ bool: True if the insertion was successful, False otherwise.
237
234
  """
238
235
  return nested.ninsert(self.metadata, indices, value, **kwargs)
239
236
 
@@ -243,11 +240,11 @@ class BaseMetaManageMixin(ABC, BaseModel):
243
240
  Removes a key from the metadata and returns its value.
244
241
 
245
242
  Args:
246
- key (str): The key to remove.
247
- default (Any): The default value to return if the key is not found.
243
+ key (str): The key to remove.
244
+ default (Any): The default value to return if the key is not found.
248
245
 
249
246
  Returns:
250
- Any: The value of the removed key or the default value.
247
+ Any: The value of the removed key or the default value.
251
248
  """
252
249
  return self.metadata.pop(key, default)
253
250
 
@@ -258,12 +255,12 @@ class BaseMetaManageMixin(ABC, BaseModel):
258
255
  Merges additional metadata into the existing metadata.
259
256
 
260
257
  Args:
261
- additional_metadata (dict[str, Any]): The metadata to merge in.
262
- overwrite (bool): If True, existing keys will be overwritten by those in additional_metadata.
263
- **kwargs: Additional keyword arguments for the merge.
258
+ additional_metadata (dict[str, Any]): The metadata to merge in.
259
+ overwrite (bool): If True, existing keys will be overwritten by those in additional_metadata.
260
+ **kwargs: Additional keyword arguments for the merge.
264
261
 
265
262
  Returns:
266
- None
263
+ None
267
264
  """
268
265
  nested.nmerge(
269
266
  [self.metadata, additional_metadata], overwrite=overwrite, **kwargs
@@ -278,7 +275,7 @@ class BaseMetaManageMixin(ABC, BaseModel):
278
275
  Clears all metadata.
279
276
 
280
277
  Returns:
281
- None
278
+ None
282
279
  """
283
280
  self.metadata.clear()
284
281
 
@@ -287,10 +284,10 @@ class BaseMetaManageMixin(ABC, BaseModel):
287
284
  Filters the metadata based on a condition.
288
285
 
289
286
  Args:
290
- condition (Callable[[Any, Any], bool]): The condition function to apply.
287
+ condition (Callable[[Any, Any], bool]): The condition function to apply.
291
288
 
292
289
  Returns:
293
- dict[str, Any]: The filtered metadata.
290
+ dict[str, Any]: The filtered metadata.
294
291
  """
295
292
  return nested.nfilter(self.metadata, condition)
296
293