lionagi 0.17.9__py3-none-any.whl → 0.17.11__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.
- lionagi/__init__.py +1 -2
- lionagi/_class_registry.py +1 -2
- lionagi/_errors.py +1 -2
- lionagi/adapters/async_postgres_adapter.py +2 -10
- lionagi/config.py +1 -2
- lionagi/fields/action.py +1 -2
- lionagi/fields/base.py +3 -0
- lionagi/fields/code.py +3 -0
- lionagi/fields/file.py +3 -0
- lionagi/fields/instruct.py +1 -2
- lionagi/fields/reason.py +3 -2
- lionagi/fields/research.py +3 -0
- lionagi/libs/__init__.py +1 -2
- lionagi/libs/file/__init__.py +1 -2
- lionagi/libs/file/chunk.py +1 -2
- lionagi/libs/file/process.py +1 -2
- lionagi/libs/schema/__init__.py +1 -2
- lionagi/libs/schema/as_readable.py +1 -2
- lionagi/libs/schema/extract_code_block.py +1 -2
- lionagi/libs/schema/extract_docstring.py +1 -2
- lionagi/libs/schema/function_to_schema.py +1 -2
- lionagi/libs/schema/load_pydantic_model_from_schema.py +1 -2
- lionagi/libs/validate/__init__.py +1 -2
- lionagi/libs/validate/common_field_validators.py +1 -2
- lionagi/libs/validate/validate_boolean.py +1 -2
- lionagi/ln/fuzzy/_string_similarity.py +1 -2
- lionagi/ln/types.py +45 -0
- lionagi/models/__init__.py +1 -2
- lionagi/models/field_model.py +392 -286
- lionagi/models/hashable_model.py +98 -14
- lionagi/models/model_params.py +272 -271
- lionagi/models/operable_model.py +9 -10
- lionagi/models/schema_model.py +1 -2
- lionagi/operations/ReAct/ReAct.py +1 -2
- lionagi/operations/ReAct/__init__.py +1 -2
- lionagi/operations/ReAct/utils.py +1 -2
- lionagi/operations/__init__.py +1 -2
- lionagi/operations/_act/__init__.py +1 -2
- lionagi/operations/_act/act.py +1 -2
- lionagi/operations/brainstorm/__init__.py +1 -2
- lionagi/operations/brainstorm/brainstorm.py +1 -2
- lionagi/operations/brainstorm/prompt.py +1 -2
- lionagi/operations/builder.py +1 -2
- lionagi/operations/chat/__init__.py +1 -2
- lionagi/operations/chat/chat.py +1 -2
- lionagi/operations/communicate/communicate.py +1 -2
- lionagi/operations/flow.py +1 -2
- lionagi/operations/instruct/__init__.py +1 -2
- lionagi/operations/instruct/instruct.py +1 -2
- lionagi/operations/interpret/__init__.py +1 -2
- lionagi/operations/interpret/interpret.py +1 -2
- lionagi/operations/operate/__init__.py +1 -2
- lionagi/operations/operate/operate.py +1 -2
- lionagi/operations/parse/__init__.py +1 -2
- lionagi/operations/parse/parse.py +1 -2
- lionagi/operations/plan/__init__.py +1 -2
- lionagi/operations/plan/plan.py +1 -2
- lionagi/operations/plan/prompt.py +1 -2
- lionagi/operations/select/__init__.py +1 -2
- lionagi/operations/select/select.py +1 -2
- lionagi/operations/select/utils.py +1 -2
- lionagi/operations/types.py +1 -2
- lionagi/operations/utils.py +1 -2
- lionagi/protocols/__init__.py +1 -2
- lionagi/protocols/_concepts.py +1 -2
- lionagi/protocols/action/__init__.py +1 -2
- lionagi/protocols/action/function_calling.py +3 -20
- lionagi/protocols/action/manager.py +34 -4
- lionagi/protocols/action/tool.py +1 -2
- lionagi/protocols/contracts.py +1 -2
- lionagi/protocols/forms/__init__.py +1 -2
- lionagi/protocols/forms/base.py +1 -2
- lionagi/protocols/forms/flow.py +1 -2
- lionagi/protocols/forms/form.py +1 -2
- lionagi/protocols/forms/report.py +1 -2
- lionagi/protocols/generic/__init__.py +1 -2
- lionagi/protocols/generic/element.py +17 -65
- lionagi/protocols/generic/event.py +1 -2
- lionagi/protocols/generic/log.py +14 -12
- lionagi/protocols/generic/pile.py +6 -4
- lionagi/protocols/generic/processor.py +1 -2
- lionagi/protocols/generic/progression.py +1 -2
- lionagi/protocols/graph/__init__.py +1 -2
- lionagi/protocols/graph/edge.py +1 -2
- lionagi/protocols/graph/graph.py +1 -2
- lionagi/protocols/graph/node.py +1 -2
- lionagi/protocols/ids.py +1 -2
- lionagi/protocols/mail/__init__.py +1 -2
- lionagi/protocols/mail/exchange.py +1 -2
- lionagi/protocols/mail/mail.py +1 -2
- lionagi/protocols/mail/mailbox.py +1 -2
- lionagi/protocols/mail/manager.py +1 -2
- lionagi/protocols/mail/package.py +1 -2
- lionagi/protocols/messages/__init__.py +1 -2
- lionagi/protocols/messages/action_request.py +1 -2
- lionagi/protocols/messages/action_response.py +1 -2
- lionagi/protocols/messages/assistant_response.py +1 -2
- lionagi/protocols/messages/base.py +1 -2
- lionagi/protocols/messages/instruction.py +1 -2
- lionagi/protocols/messages/manager.py +1 -2
- lionagi/protocols/messages/message.py +1 -2
- lionagi/protocols/messages/system.py +1 -2
- lionagi/protocols/operatives/__init__.py +1 -2
- lionagi/protocols/operatives/operative.py +30 -8
- lionagi/protocols/operatives/step.py +1 -2
- lionagi/protocols/types.py +1 -2
- lionagi/service/connections/__init__.py +1 -2
- lionagi/service/connections/api_calling.py +1 -2
- lionagi/service/connections/endpoint.py +1 -2
- lionagi/service/connections/endpoint_config.py +1 -2
- lionagi/service/connections/header_factory.py +1 -2
- lionagi/service/connections/match_endpoint.py +1 -2
- lionagi/service/connections/mcp/__init__.py +1 -2
- lionagi/service/connections/mcp/wrapper.py +1 -2
- lionagi/service/connections/providers/__init__.py +1 -2
- lionagi/service/connections/providers/anthropic_.py +1 -2
- lionagi/service/connections/providers/claude_code_cli.py +1 -2
- lionagi/service/connections/providers/exa_.py +1 -2
- lionagi/service/connections/providers/nvidia_nim_.py +2 -27
- lionagi/service/connections/providers/oai_.py +1 -2
- lionagi/service/connections/providers/ollama_.py +1 -2
- lionagi/service/connections/providers/perplexity_.py +1 -2
- lionagi/service/hooks/__init__.py +1 -1
- lionagi/service/hooks/_types.py +1 -1
- lionagi/service/hooks/_utils.py +1 -1
- lionagi/service/hooks/hook_event.py +1 -1
- lionagi/service/hooks/hook_registry.py +1 -1
- lionagi/service/hooks/hooked_event.py +1 -2
- lionagi/service/imodel.py +1 -2
- lionagi/service/manager.py +1 -2
- lionagi/service/rate_limited_processor.py +1 -2
- lionagi/service/resilience.py +1 -2
- lionagi/service/third_party/anthropic_models.py +3 -5
- lionagi/service/third_party/claude_code.py +1 -2
- lionagi/service/token_calculator.py +1 -2
- lionagi/service/types.py +1 -2
- lionagi/session/__init__.py +1 -2
- lionagi/session/branch.py +1 -2
- lionagi/session/session.py +1 -2
- lionagi/tools/__init__.py +1 -2
- lionagi/tools/base.py +1 -2
- lionagi/tools/file/__init__.py +1 -2
- lionagi/tools/file/reader.py +1 -2
- lionagi/tools/types.py +1 -2
- lionagi/utils.py +1 -2
- lionagi/version.py +1 -1
- {lionagi-0.17.9.dist-info → lionagi-0.17.11.dist-info}/METADATA +2 -2
- lionagi-0.17.11.dist-info/RECORD +199 -0
- lionagi-0.17.9.dist-info/RECORD +0 -199
- {lionagi-0.17.9.dist-info → lionagi-0.17.11.dist-info}/WHEEL +0 -0
- {lionagi-0.17.9.dist-info → lionagi-0.17.11.dist-info}/licenses/LICENSE +0 -0
lionagi/protocols/generic/log.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023
|
2
|
-
#
|
1
|
+
# Copyright (c) 2023-2025, HaiyangLi <quantocean.li at gmail dot com>
|
3
2
|
# SPDX-License-Identifier: Apache-2.0
|
4
3
|
|
5
4
|
from __future__ import annotations
|
@@ -11,6 +10,7 @@ from typing import Any
|
|
11
10
|
|
12
11
|
from pydantic import BaseModel, Field, PrivateAttr, field_validator
|
13
12
|
|
13
|
+
from lionagi.models.hashable_model import HashableModel
|
14
14
|
from lionagi.utils import create_path, to_dict
|
15
15
|
|
16
16
|
from .element import Element
|
@@ -24,6 +24,8 @@ __all__ = (
|
|
24
24
|
"LogManager",
|
25
25
|
)
|
26
26
|
|
27
|
+
logger = logging.getLogger(__name__)
|
28
|
+
|
27
29
|
|
28
30
|
class DataLoggerConfig(BaseModel):
|
29
31
|
persist_dir: str | Path = "./data/logs"
|
@@ -88,13 +90,13 @@ class Log(Element):
|
|
88
90
|
Create a new Log from an Element, storing a dict snapshot
|
89
91
|
of the element's data.
|
90
92
|
"""
|
91
|
-
if
|
92
|
-
content = content.to_dict()
|
93
|
+
if isinstance(content, Element | HashableModel):
|
94
|
+
content = content.to_dict(mode="json")
|
93
95
|
else:
|
94
96
|
content = to_dict(content, recursive=True, suppress=True)
|
95
97
|
|
96
98
|
if content is {}:
|
97
|
-
|
99
|
+
logger.warning(
|
98
100
|
"No content to log, or original data was of invalid type. Making an empty log..."
|
99
101
|
)
|
100
102
|
return cls(content={"error": "No content to log."})
|
@@ -149,7 +151,7 @@ class DataLogger:
|
|
149
151
|
try:
|
150
152
|
self.dump(clear=self._config.clear_after_dump)
|
151
153
|
except Exception as e:
|
152
|
-
|
154
|
+
logger.error(f"Failed to auto-dump logs: {e}")
|
153
155
|
self.logs.include(log_)
|
154
156
|
|
155
157
|
async def alog(self, log_: Log) -> None:
|
@@ -169,7 +171,7 @@ class DataLogger:
|
|
169
171
|
unsupported, raise ValueError. Optionally clear logs after.
|
170
172
|
"""
|
171
173
|
if not self.logs:
|
172
|
-
|
174
|
+
logger.debug("No logs to dump.")
|
173
175
|
return
|
174
176
|
|
175
177
|
fp = persist_path or self._create_path()
|
@@ -182,7 +184,7 @@ class DataLogger:
|
|
182
184
|
else:
|
183
185
|
raise ValueError(f"Unsupported file extension: {suffix}")
|
184
186
|
|
185
|
-
|
187
|
+
logger.info(f"Dumped logs to {fp}")
|
186
188
|
do_clear = (
|
187
189
|
self._config.clear_after_dump if clear is None else clear
|
188
190
|
)
|
@@ -191,12 +193,12 @@ class DataLogger:
|
|
191
193
|
except Exception as e:
|
192
194
|
# Check if it's a JSON serialization error with complex objects
|
193
195
|
if "JSON serializable" in str(e):
|
194
|
-
|
196
|
+
logger.debug(f"Could not serialize logs to JSON: {e}")
|
195
197
|
# Don't raise for JSON serialization issues during dumps
|
196
198
|
if clear is not False:
|
197
199
|
self.logs.clear() # Still clear if requested
|
198
200
|
else:
|
199
|
-
|
201
|
+
logger.error(f"Failed to dump logs: {e}")
|
200
202
|
raise
|
201
203
|
|
202
204
|
async def adump(
|
@@ -233,9 +235,9 @@ class DataLogger:
|
|
233
235
|
# Only log debug level for JSON serialization errors during exit
|
234
236
|
# These are non-critical and often occur with complex objects
|
235
237
|
if "JSON serializable" in str(e):
|
236
|
-
|
238
|
+
logger.debug(f"Could not serialize logs to JSON: {e}")
|
237
239
|
else:
|
238
|
-
|
240
|
+
logger.error(f"Failed to save logs on exit: {e}")
|
239
241
|
|
240
242
|
@classmethod
|
241
243
|
def from_config(
|
@@ -1,5 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023
|
2
|
-
#
|
1
|
+
# Copyright (c) 2023-2025, HaiyangLi <quantocean.li at gmail dot com>
|
3
2
|
# SPDX-License-Identifier: Apache-2.0
|
4
3
|
|
5
4
|
from __future__ import annotations
|
@@ -16,10 +15,9 @@ from collections.abc import (
|
|
16
15
|
)
|
17
16
|
from functools import wraps
|
18
17
|
from pathlib import Path
|
19
|
-
from typing import Any, ClassVar, Generic, Literal, TypeVar
|
18
|
+
from typing import TYPE_CHECKING, Any, ClassVar, Generic, Literal, TypeVar
|
20
19
|
|
21
20
|
from pydantic import Field, field_serializer
|
22
|
-
from pydantic.fields import FieldInfo
|
23
21
|
from pydapter import Adaptable, AsyncAdaptable
|
24
22
|
from typing_extensions import Self, deprecated, override
|
25
23
|
|
@@ -37,6 +35,10 @@ from .._concepts import Observable
|
|
37
35
|
from .element import ID, Collective, E, Element, IDType, validate_order
|
38
36
|
from .progression import Progression
|
39
37
|
|
38
|
+
if TYPE_CHECKING:
|
39
|
+
from pydantic.fields import FieldInfo
|
40
|
+
|
41
|
+
|
40
42
|
D = TypeVar("D")
|
41
43
|
T = TypeVar("T", bound=E)
|
42
44
|
|
lionagi/protocols/graph/edge.py
CHANGED
lionagi/protocols/graph/graph.py
CHANGED
lionagi/protocols/graph/node.py
CHANGED
lionagi/protocols/ids.py
CHANGED
lionagi/protocols/mail/mail.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023
|
2
|
-
#
|
1
|
+
# Copyright (c) 2023-2025, HaiyangLi <quantocean.li at gmail dot com>
|
3
2
|
# SPDX-License-Identifier: Apache-2.0
|
4
3
|
|
5
4
|
from typing import Any
|
@@ -79,7 +78,13 @@ class Operative:
|
|
79
78
|
"""Initialize from ModelParams for backward compatibility."""
|
80
79
|
# Add field models to the request operable
|
81
80
|
if params.field_models:
|
82
|
-
|
81
|
+
# Coerce to list if single FieldModel instance
|
82
|
+
field_models_list = (
|
83
|
+
[params.field_models]
|
84
|
+
if isinstance(params.field_models, FieldModel)
|
85
|
+
else params.field_models
|
86
|
+
)
|
87
|
+
for field_model in field_models_list:
|
83
88
|
self._request_operable.add_field(
|
84
89
|
field_model.name,
|
85
90
|
field_model=field_model,
|
@@ -103,8 +108,16 @@ class Operative:
|
|
103
108
|
use_fields = set(self._request_operable.all_fields.keys()) - set(
|
104
109
|
exclude_fields
|
105
110
|
)
|
111
|
+
|
112
|
+
# Determine model name - prefer explicit name, then base_type name, then default
|
113
|
+
model_name = "RequestModel"
|
114
|
+
if not params._is_sentinel(params.name):
|
115
|
+
model_name = params.name
|
116
|
+
elif not params._is_sentinel(params.base_type):
|
117
|
+
model_name = params.base_type.__name__
|
118
|
+
|
106
119
|
self.request_type = self._request_operable.new_model(
|
107
|
-
name=
|
120
|
+
name=model_name,
|
108
121
|
use_fields=use_fields,
|
109
122
|
base_type=params.base_type,
|
110
123
|
frozen=params.frozen,
|
@@ -112,9 +125,12 @@ class Operative:
|
|
112
125
|
doc=params.doc,
|
113
126
|
)
|
114
127
|
|
115
|
-
# Update name if not set
|
116
|
-
if not self.name
|
117
|
-
|
128
|
+
# Update name if not set - prefer explicit name, then base_type name
|
129
|
+
if not self.name:
|
130
|
+
if not params._is_sentinel(params.name):
|
131
|
+
self.name = params.name
|
132
|
+
elif not params._is_sentinel(params.base_type):
|
133
|
+
self.name = params.base_type.__name__
|
118
134
|
|
119
135
|
def model_dump(self) -> dict[str, Any]:
|
120
136
|
"""Convert to dictionary for backward compatibility.
|
@@ -285,7 +301,13 @@ class Operative:
|
|
285
301
|
|
286
302
|
# Add field models (skip if already exists from inheritance)
|
287
303
|
if field_models:
|
288
|
-
|
304
|
+
# Coerce to list if single FieldModel instance
|
305
|
+
field_models_list = (
|
306
|
+
[field_models]
|
307
|
+
if isinstance(field_models, FieldModel)
|
308
|
+
else field_models
|
309
|
+
)
|
310
|
+
for field_model in field_models_list:
|
289
311
|
if field_model.name not in self._response_operable.all_fields:
|
290
312
|
self._response_operable.add_field(
|
291
313
|
field_model.name,
|
lionagi/protocols/types.py
CHANGED
@@ -1,24 +1,6 @@
|
|
1
|
-
# Copyright (c) 2025, HaiyangLi <quantocean.li at gmail dot com>
|
2
|
-
#
|
1
|
+
# Copyright (c) 2023-2025, HaiyangLi <quantocean.li at gmail dot com>
|
3
2
|
# SPDX-License-Identifier: Apache-2.0
|
4
3
|
|
5
|
-
"""
|
6
|
-
NVIDIA NIM endpoint configurations.
|
7
|
-
|
8
|
-
This module provides endpoint configurations for NVIDIA NIM (NVIDIA Inference Microservices),
|
9
|
-
which offers GPU-accelerated inference for various AI models through an OpenAI-compatible API.
|
10
|
-
|
11
|
-
NVIDIA NIM features:
|
12
|
-
- OpenAI-compatible API endpoints
|
13
|
-
- GPU-accelerated inference
|
14
|
-
- Support for various open-source models (Llama, Mistral, etc.)
|
15
|
-
- Both cloud-hosted and self-hosted options
|
16
|
-
- Free tier with 1000 credits for development
|
17
|
-
|
18
|
-
API Documentation: https://docs.nvidia.com/nim/
|
19
|
-
Build Portal: https://build.nvidia.com/
|
20
|
-
"""
|
21
|
-
|
22
4
|
from lionagi.config import settings
|
23
5
|
from lionagi.service.connections.endpoint import Endpoint
|
24
6
|
from lionagi.service.connections.endpoint_config import EndpointConfig
|
@@ -69,15 +51,8 @@ NVIDIA_NIM_EMBED_ENDPOINT_CONFIG = _get_nvidia_nim_config(
|
|
69
51
|
class NvidiaNimChatEndpoint(Endpoint):
|
70
52
|
"""NVIDIA NIM chat completion endpoint.
|
71
53
|
|
72
|
-
Supports various open-source models including:
|
73
|
-
- meta/llama3-8b-instruct
|
74
|
-
- meta/llama3-70b-instruct
|
75
|
-
- meta/llama3.1-405b-instruct
|
76
|
-
- mistralai/mixtral-8x7b-instruct-v0.1
|
77
|
-
- google/gemma-7b
|
78
|
-
- And many more...
|
79
|
-
|
80
54
|
Get your API key from: https://build.nvidia.com/
|
55
|
+
API Documentation: https://docs.nvidia.com/nim/
|
81
56
|
"""
|
82
57
|
|
83
58
|
def __init__(self, config=None, **kwargs):
|
lionagi/service/hooks/_types.py
CHANGED
lionagi/service/hooks/_utils.py
CHANGED
lionagi/service/imodel.py
CHANGED
lionagi/service/manager.py
CHANGED
lionagi/service/resilience.py
CHANGED