lionagi 0.5.1__py3-none-any.whl → 0.5.3__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- lionagi/__init__.py +3 -1
- lionagi/core/action/tool.py +3 -5
- lionagi/core/communication/action_request.py +3 -3
- lionagi/core/communication/message.py +3 -3
- lionagi/core/communication/utils.py +3 -3
- lionagi/core/generic/component.py +4 -4
- lionagi/core/generic/element.py +51 -47
- lionagi/core/generic/graph.py +1 -1
- lionagi/core/generic/log.py +2 -2
- lionagi/core/generic/pile.py +10 -11
- lionagi/core/generic/progression.py +19 -12
- lionagi/core/generic/utils.py +6 -3
- lionagi/core/models/base.py +11 -68
- lionagi/core/models/field_model.py +42 -19
- lionagi/core/models/{new_model_params.py → model_params.py} +5 -6
- lionagi/core/models/note.py +2 -2
- lionagi/core/models/operable_model.py +8 -4
- lionagi/core/models/schema_model.py +9 -31
- lionagi/core/models/types.py +15 -6
- lionagi/core/session/branch.py +8 -4
- lionagi/core/session/branch_mixins.py +11 -12
- lionagi/core/session/session.py +1 -2
- lionagi/core/typing/__init__.py +4 -4
- lionagi/core/typing/{concepts.py → _concepts.py} +43 -2
- lionagi/core/typing/_id.py +104 -0
- lionagi/integrations/anthropic_/AnthropicModel.py +8 -3
- lionagi/integrations/groq_/GroqModel.py +11 -4
- lionagi/integrations/litellm_/imodel.py +6 -8
- lionagi/integrations/openai_/OpenAIModel.py +8 -3
- lionagi/integrations/openai_/image_token_calculator/image_token_calculator.py +14 -8
- lionagi/integrations/perplexity_/PerplexityModel.py +8 -3
- lionagi/libs/func/async_calls/__init__.py +6 -3
- lionagi/libs/func/async_calls/alcall.py +46 -0
- lionagi/libs/func/async_calls/bcall.py +49 -1
- lionagi/libs/func/async_calls/rcall.py +32 -0
- lionagi/libs/utils.py +12 -1
- lionagi/operations/brainstorm/brainstorm.py +4 -4
- lionagi/operations/brainstorm/prompt.py +8 -1
- lionagi/operations/plan/plan.py +3 -3
- lionagi/operations/plan/prompt.py +17 -16
- lionagi/protocols/__init__.py +3 -0
- lionagi/protocols/configs/__init__.py +0 -15
- lionagi/protocols/configs/branch_config.py +1 -1
- lionagi/protocols/configs/imodel_config.py +2 -2
- lionagi/protocols/configs/log_config.py +1 -1
- lionagi/protocols/configs/types.py +15 -0
- lionagi/protocols/operatives/__init__.py +3 -15
- lionagi/protocols/operatives/action.py +4 -0
- lionagi/protocols/operatives/instruct.py +6 -8
- lionagi/protocols/operatives/operative.py +9 -21
- lionagi/protocols/operatives/prompts.py +53 -202
- lionagi/protocols/operatives/reason.py +4 -0
- lionagi/protocols/operatives/step.py +11 -23
- lionagi/protocols/operatives/types.py +19 -0
- lionagi/protocols/registries/__init__.py +3 -0
- lionagi/protocols/registries/_component_registry.py +4 -0
- lionagi/protocols/registries/_pile_registry.py +4 -0
- lionagi/service/__init__.py +3 -0
- lionagi/service/service_match_util.py +4 -4
- lionagi/settings.py +10 -18
- lionagi/strategies/base.py +4 -5
- lionagi/strategies/concurrent.py +4 -3
- lionagi/strategies/concurrent_chunk.py +3 -3
- lionagi/strategies/concurrent_sequential_chunk.py +3 -3
- lionagi/strategies/params.py +7 -4
- lionagi/version.py +1 -1
- {lionagi-0.5.1.dist-info → lionagi-0.5.3.dist-info}/METADATA +5 -3
- {lionagi-0.5.1.dist-info → lionagi-0.5.3.dist-info}/RECORD +73 -72
- lionagi/core/typing/config.py +0 -15
- lionagi/core/typing/id.py +0 -221
- /lionagi/core/typing/{pydantic_.py → _pydantic.py} +0 -0
- /lionagi/core/typing/{typing_.py → _typing.py} +0 -0
- /lionagi/integrations/{services.py → _services.py} +0 -0
- {lionagi-0.5.1.dist-info → lionagi-0.5.3.dist-info}/WHEEL +0 -0
- {lionagi-0.5.1.dist-info → lionagi-0.5.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
from typing import ClassVar
|
2
2
|
|
3
|
-
from lionagi.
|
4
|
-
from lionagi.
|
3
|
+
from lionagi.libs.func.types import bcall
|
4
|
+
from lionagi.libs.parse.types import to_list
|
5
|
+
from lionagi.protocols.operatives.instruct import Instruct, InstructResponse
|
5
6
|
|
6
|
-
from ..libs.async_utils import bcall
|
7
7
|
from .concurrent import ConcurrentExecutor
|
8
8
|
from .params import ChunkStrategyParams
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
from pydantic import model_validator
|
2
2
|
|
3
|
-
from lionagi.
|
4
|
-
from lionagi.
|
5
|
-
from lionagi.
|
3
|
+
from lionagi.core.session.types import Branch, Session
|
4
|
+
from lionagi.libs.func.types import alcall
|
5
|
+
from lionagi.protocols.operatives.instruct import Instruct, InstructResponse
|
6
6
|
|
7
7
|
from .base import StrategyExecutor
|
8
8
|
from .params import HybridStrategyParams
|
lionagi/strategies/params.py
CHANGED
@@ -2,10 +2,13 @@ from typing import Any, Literal
|
|
2
2
|
|
3
3
|
from pydantic import Field, field_validator, model_validator
|
4
4
|
|
5
|
-
from lionagi.
|
6
|
-
from lionagi.
|
7
|
-
from lionagi.
|
8
|
-
from lionagi.
|
5
|
+
from lionagi.core.models.types import FieldModel, SchemaModel
|
6
|
+
from lionagi.core.session.types import Branch, Session
|
7
|
+
from lionagi.libs.func.types import RCallParams
|
8
|
+
from lionagi.protocols.operatives.instruct import (
|
9
|
+
INSTRUCT_FIELD_MODEL,
|
10
|
+
Instruct,
|
11
|
+
)
|
9
12
|
|
10
13
|
|
11
14
|
class StrategyParams(SchemaModel):
|
lionagi/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.5.
|
1
|
+
__version__ = "0.5.3"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lionagi
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.3
|
4
4
|
Summary: An AGentic Intelligence Operating System.
|
5
5
|
Author-email: HaiyangLi <quantocean.li@gmail.com>
|
6
6
|
License: Apache License
|
@@ -218,10 +218,12 @@ Classifier: Programming Language :: Python :: 3.11
|
|
218
218
|
Classifier: Programming Language :: Python :: 3.12
|
219
219
|
Classifier: Programming Language :: Python :: 3.13
|
220
220
|
Requires-Python: >=3.11
|
221
|
+
Requires-Dist: aiohttp>=3.11.10
|
221
222
|
Requires-Dist: jinja2>=3.1.4
|
222
|
-
Requires-Dist: litellm>=1.55.
|
223
|
+
Requires-Dist: litellm>=1.55.3
|
223
224
|
Requires-Dist: pandas>=2.0.0
|
224
225
|
Requires-Dist: pillow>=11.0.0
|
226
|
+
Requires-Dist: pydantic>=2.10.3
|
225
227
|
Requires-Dist: python-dotenv>=1.0.1
|
226
228
|
Description-Content-Type: text/markdown
|
227
229
|
|
@@ -334,7 +336,7 @@ pplx_small = iModel(
|
|
334
336
|
b = await hunter.communicate(
|
335
337
|
instruction="What makes a well-behaved dragon?",
|
336
338
|
clear_messages=True, # refresh the conversation
|
337
|
-
imodel=pplx_small,
|
339
|
+
imodel=pplx_small, # use perplexity model
|
338
340
|
)
|
339
341
|
|
340
342
|
print(b)
|
@@ -1,25 +1,25 @@
|
|
1
|
-
lionagi/__init__.py,sha256=
|
2
|
-
lionagi/settings.py,sha256=
|
3
|
-
lionagi/version.py,sha256=
|
1
|
+
lionagi/__init__.py,sha256=oybfu2VsZc4ElN7ZeaW3KQrz8T8EcSDHPA8lUE-8G2I,537
|
2
|
+
lionagi/settings.py,sha256=BOjxRV4N9zQJervvajPhbaHmgZ-nhbCy7AaQJi3Avug,2726
|
3
|
+
lionagi/version.py,sha256=tgzuqHKcEdKBaP57F5oXxq4XlW2n9J4Fj8ZGu7nGOZg,22
|
4
4
|
lionagi/core/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
5
5
|
lionagi/core/_class_registry.py,sha256=srSWefqCS9EZrMvyA8zCrZ9KFvzAhTIj8g6mJG5KlIc,1982
|
6
6
|
lionagi/core/action/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
7
7
|
lionagi/core/action/action_manager.py,sha256=8yNWV5x8YtaoL2A_U_5xjJdruqwWw8TLPAtq3f3DC7M,10143
|
8
8
|
lionagi/core/action/base.py,sha256=M2K3irxpp7fDwczefzZdUsHhGd_21l1xhFT9iNSbiK0,4110
|
9
9
|
lionagi/core/action/function_calling.py,sha256=7N5UFLbHPy6yvPrR6RH9SNSwt73s0X_3iAnOV8YMy0Q,6001
|
10
|
-
lionagi/core/action/tool.py,sha256=
|
10
|
+
lionagi/core/action/tool.py,sha256=pDiyttx0obu0qDskz7POHxbyqTwHuD7HCeE31LkzRMg,6884
|
11
11
|
lionagi/core/action/types.py,sha256=KqW5ZHXssfxuf1kIiIUoj-r3KIZEoQ_GkZ04tL6fUPQ,388
|
12
12
|
lionagi/core/communication/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
13
|
-
lionagi/core/communication/action_request.py,sha256=
|
13
|
+
lionagi/core/communication/action_request.py,sha256=gicqQIs7VLOhnkQYsUuRmSLGittODiG3Pk74FayPSeM,5006
|
14
14
|
lionagi/core/communication/action_response.py,sha256=QONcRtvV7Ympbzkdg5gnV0DqCC97Y-gvaA0D7EkjswM,4505
|
15
15
|
lionagi/core/communication/assistant_response.py,sha256=WTQjBxAckMILocaZEsOP6u1mfKr3DhYVt4K8TyAh7Ek,5760
|
16
16
|
lionagi/core/communication/base_mail.py,sha256=Et-WrHlw2x75mLIKy-wMUj3YlGGL_2BF9r1REuiZtM8,1704
|
17
17
|
lionagi/core/communication/instruction.py,sha256=Iy3G1sp0lPuA4Ak9pLobIipou4ePLsMdGGvRq6L58UU,12454
|
18
|
-
lionagi/core/communication/message.py,sha256=
|
18
|
+
lionagi/core/communication/message.py,sha256=60yaub4C_JFnMR76D_DeYfQ_mQYoZ0eBF9Vqk2UadUw,8550
|
19
19
|
lionagi/core/communication/message_manager.py,sha256=RnSYJUnKOKBS8dfY2804Zq2sD-C5qDvBXNxXRsMfRe0,16987
|
20
20
|
lionagi/core/communication/system.py,sha256=5DoDODZePy4EDpE3oI5RpkzBXVp9WC2Mf4B3fPImItI,3824
|
21
21
|
lionagi/core/communication/types.py,sha256=rBGMpE3NW0SGKc-wJdJvT-VrO3wpjwjQhoWzSC2Dqh0,745
|
22
|
-
lionagi/core/communication/utils.py,sha256=
|
22
|
+
lionagi/core/communication/utils.py,sha256=9kaBLH2eA2XqhW_aQvqziwm__z-WlBKSM0pwWX4BFjk,6959
|
23
23
|
lionagi/core/communication/templates/README.md,sha256=Ch4JrKSjd85fLitAYO1OhZjNOGKHoEwaKQlcV16jiUI,1286
|
24
24
|
lionagi/core/communication/templates/action_request.jinja2,sha256=d6OmxHKyvvNDSK4bnBM3TGSUk_HeE_Q2EtLAQ0ZBEJg,120
|
25
25
|
lionagi/core/communication/templates/action_response.jinja2,sha256=Mg0UxmXlIvtP_KPB0GcJxE1TP6lml9BwdPkW1PZxkg8,142
|
@@ -34,39 +34,38 @@ lionagi/core/forms/report.py,sha256=FXu8sQnGMF_nCHUJ4NrXoiptHQ2ON2a356RBGJDZmag,
|
|
34
34
|
lionagi/core/forms/types.py,sha256=5k8RNj87c0lHlSPrqnz4aY6--Lopg3u80qgKyRNuhuY,247
|
35
35
|
lionagi/core/forms/utils.py,sha256=sCjYRy-EJIh1py9qIb04LVgALy2YiPHbhXhNyDNwvoQ,701
|
36
36
|
lionagi/core/generic/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
37
|
-
lionagi/core/generic/component.py,sha256=
|
37
|
+
lionagi/core/generic/component.py,sha256=3y0t-fyLR2n2E8ooa7_VI5bx_lV1S82wOAp2pn7qAzA,13801
|
38
38
|
lionagi/core/generic/edge.py,sha256=E0uw1nbviepTtmhxZjIieksE5utZo2Yk1Wn28tmRf1k,4972
|
39
|
-
lionagi/core/generic/element.py,sha256=
|
40
|
-
lionagi/core/generic/graph.py,sha256=
|
41
|
-
lionagi/core/generic/log.py,sha256=
|
39
|
+
lionagi/core/generic/element.py,sha256=PAqL_7PQPb9PcGHTBz7qZMuN-gcjClSCkQllcBP1pyc,5851
|
40
|
+
lionagi/core/generic/graph.py,sha256=5uFU5rEHzzIQRtQrY2BO75wv5ekrFZskTnUK0GnuZJo,11921
|
41
|
+
lionagi/core/generic/log.py,sha256=QQfgDSrw6YwHRjYV3kRc6ztnJHTLx0IdV-fjymrmZmQ,4976
|
42
42
|
lionagi/core/generic/log_manager.py,sha256=MLlY2s3_xlDTwntQPdrQOrdbc0V1qwrKpMheSU7Tt3E,10426
|
43
43
|
lionagi/core/generic/node.py,sha256=GYlc2CKVuNLns2_DL7YS2e8Z3CYGDSWsablQSHuUN3Q,236
|
44
|
-
lionagi/core/generic/pile.py,sha256=
|
45
|
-
lionagi/core/generic/progression.py,sha256=
|
44
|
+
lionagi/core/generic/pile.py,sha256=wzN6M8XISsnvZs2dsswnRBqwS0CP5VNQ4pmC8BUcd8U,29452
|
45
|
+
lionagi/core/generic/progression.py,sha256=mrR9K-q3R5DJ9LtUCHwJ1T8NFdMwuz6vTmG11pX5vLE,11784
|
46
46
|
lionagi/core/generic/types.py,sha256=vcMgOD3puTETk5hpWQBYq1p31e0JnvcqAyKu8zslIdU,615
|
47
|
-
lionagi/core/generic/utils.py,sha256=
|
47
|
+
lionagi/core/generic/utils.py,sha256=RE_CE1HALogxBDz72tAubVBTvUCUmtox-GdWPkOSvLw,1548
|
48
48
|
lionagi/core/models/__init__.py,sha256=O7nV0tedpUe7_OlUWmCcduGPFtqtzWZcR_SIOnjLsro,134
|
49
|
-
lionagi/core/models/base.py,sha256=
|
50
|
-
lionagi/core/models/field_model.py,sha256=
|
51
|
-
lionagi/core/models/
|
52
|
-
lionagi/core/models/note.py,sha256=
|
53
|
-
lionagi/core/models/operable_model.py,sha256=
|
54
|
-
lionagi/core/models/schema_model.py,sha256=
|
55
|
-
lionagi/core/models/types.py,sha256=
|
49
|
+
lionagi/core/models/base.py,sha256=t1tI1mwcla2YLwKGpKGm1uUH--GQ0W9qrqzZ1SQlZ5k,818
|
50
|
+
lionagi/core/models/field_model.py,sha256=iB0UUEY2P7rv25f7CfVlSQDT8ddgPvB-FqYQYwnK5nc,4941
|
51
|
+
lionagi/core/models/model_params.py,sha256=iXrNalt6UAY5SH9HSrYBK9Ia-73ZBc6K48btcQNditc,6900
|
52
|
+
lionagi/core/models/note.py,sha256=7O8kXxoXeVHHYzmlbLoW0Rd99pYngPZbOpEszIX_fos,9424
|
53
|
+
lionagi/core/models/operable_model.py,sha256=zuXDjoNI2-jLFxp3XWITtzIv0-CQ6FO6DQydXZIv0J4,11913
|
54
|
+
lionagi/core/models/schema_model.py,sha256=H2tSX3r0U6MDNi929rWmAZy3nUKMP47RG-Ma0O-QYNY,667
|
55
|
+
lionagi/core/models/types.py,sha256=elcUuz_9dx4AhZddnICF-Cs62VJWIBqMET7MiRe4c1I,447
|
56
56
|
lionagi/core/session/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
57
|
-
lionagi/core/session/branch.py,sha256=
|
58
|
-
lionagi/core/session/branch_mixins.py,sha256=
|
59
|
-
lionagi/core/session/session.py,sha256=
|
57
|
+
lionagi/core/session/branch.py,sha256=r6yNXwTm0oYA-9YOereuvLJtDnhj9IJWJ5fjTyKN88U,4406
|
58
|
+
lionagi/core/session/branch_mixins.py,sha256=C9lGHmD1AmXAePw0kGIeuZjZ7SzOrFcIwV6rVaGhoGg,19623
|
59
|
+
lionagi/core/session/session.py,sha256=Uup50oMqs00ZH6zgEiqtk0pG_ANByHW_Ael07dfbT1M,5122
|
60
60
|
lionagi/core/session/types.py,sha256=MUGTSa2HWK79p7z-CG22RFP07N5AKnPVNXZwZt_wIvU,202
|
61
|
-
lionagi/core/typing/__init__.py,sha256=
|
62
|
-
lionagi/core/typing/
|
63
|
-
lionagi/core/typing/
|
64
|
-
lionagi/core/typing/
|
65
|
-
lionagi/core/typing/
|
66
|
-
lionagi/core/typing/typing_.py,sha256=VJj5W6y-JGK1ZzSbyDs4qAuq0cA5wp5HtRgZUsZ50E0,869
|
61
|
+
lionagi/core/typing/__init__.py,sha256=Y9BK1OUXzjQgIo3epCVwWqUYhFwQQ_ayhRwI1UOmINg,228
|
62
|
+
lionagi/core/typing/_concepts.py,sha256=uIzqfwtPBsIREhvT7NDAowc4i-u-69n_DRzLHzvHZO4,3730
|
63
|
+
lionagi/core/typing/_id.py,sha256=6BLrpYxfeb8ZVByc-v3EvAjyidYHY55l3BL_Ndc7mSE,2651
|
64
|
+
lionagi/core/typing/_pydantic.py,sha256=xMNyT0rDhSpKkEDfzj6GHobqlTtRn48svhmA75LP6gs,653
|
65
|
+
lionagi/core/typing/_typing.py,sha256=VJj5W6y-JGK1ZzSbyDs4qAuq0cA5wp5HtRgZUsZ50E0,869
|
67
66
|
lionagi/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
68
|
-
lionagi/integrations/
|
69
|
-
lionagi/integrations/anthropic_/AnthropicModel.py,sha256=
|
67
|
+
lionagi/integrations/_services.py,sha256=qxffUaPKvp2Bb_LI3Uiyokm7l6ZAbRi0xKxZXCYs67c,498
|
68
|
+
lionagi/integrations/anthropic_/AnthropicModel.py,sha256=3Mzw7g6KjCZMzRgURH1AgqUJvmS3AqZaF5k_q4f77j8,9228
|
70
69
|
lionagi/integrations/anthropic_/AnthropicService.py,sha256=Z6fGD2nLEKOm3cDK4Gy0_Vl289KAxX1wswCWsEDpp4E,3656
|
71
70
|
lionagi/integrations/anthropic_/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
72
71
|
lionagi/integrations/anthropic_/anthropic_max_output_token_data.yaml,sha256=u_CT9UAXoNpbAWuPHMxH9g4erZW7XUwY4vdSXyE86t4,203
|
@@ -84,7 +83,7 @@ lionagi/integrations/anthropic_/api_endpoints/messages/response/__init__.py,sha2
|
|
84
83
|
lionagi/integrations/anthropic_/api_endpoints/messages/response/content_models.py,sha256=4J40thUbg3leKZKRy7v_YmS-trW1KVXpLzevt7v3IZ8,1033
|
85
84
|
lionagi/integrations/anthropic_/api_endpoints/messages/response/response_body.py,sha256=96e2GAAiTGkExRullvAsAOGhPPHNByhnv6DK_wz1j40,3213
|
86
85
|
lionagi/integrations/anthropic_/api_endpoints/messages/response/usage_models.py,sha256=s6oe5iOU027M7YPS10upnvcPsuFbTV1ZM00lInHPKvA,695
|
87
|
-
lionagi/integrations/groq_/GroqModel.py,sha256=
|
86
|
+
lionagi/integrations/groq_/GroqModel.py,sha256=y2KaFe8GmlTBnBRvB09dNjYYhNEjq2wujYfB8YzGNHI,11950
|
88
87
|
lionagi/integrations/groq_/GroqService.py,sha256=v3bn04njIwV7ysOlfLCmapOhHZJy3bNUTr0i12tFqME,4644
|
89
88
|
lionagi/integrations/groq_/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
90
89
|
lionagi/integrations/groq_/groq_max_output_token_data.yaml,sha256=Y0PbyZ7pyyV1zi7ZJSJGVPsZDhSeN2JMOyghzkqqoKc,559
|
@@ -97,7 +96,7 @@ lionagi/integrations/groq_/api_endpoints/groq_request.py,sha256=u-GJuu0ZsY7jMWaX
|
|
97
96
|
lionagi/integrations/groq_/api_endpoints/match_response.py,sha256=95vRKsR1QYPPmBY36dC5azdKn5UlXNRrTQqTUZro_YM,3756
|
98
97
|
lionagi/integrations/groq_/api_endpoints/response_utils.py,sha256=P5kRsGHe-Rx9xejfRcU8q680yotcWLTSaSUuqXATcho,3710
|
99
98
|
lionagi/integrations/litellm_/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
100
|
-
lionagi/integrations/litellm_/imodel.py,sha256=
|
99
|
+
lionagi/integrations/litellm_/imodel.py,sha256=YBaG5f8BavbhooVv7xQXC68K6N7AxPMcUAhgJ1TlYNw,2227
|
101
100
|
lionagi/integrations/ollama_/OllamaModel.py,sha256=5kBYIWShsSpQpSgOxdbRk2_4jmss6Y8iISjUcS3KoWw,8341
|
102
101
|
lionagi/integrations/ollama_/OllamaService.py,sha256=bJ4kk1FPjn_kecLzxTJgVj05KZPzF5FclHoDA3jdAlg,4080
|
103
102
|
lionagi/integrations/ollama_/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
@@ -126,7 +125,7 @@ lionagi/integrations/ollama_/api_endpoints/model/list_model.py,sha256=OrGdJa0evj
|
|
126
125
|
lionagi/integrations/ollama_/api_endpoints/model/pull_model.py,sha256=fiZJcQSRn73SJA9GdlfPBG5RiMISQwBc0y7S_zAlOGA,923
|
127
126
|
lionagi/integrations/ollama_/api_endpoints/model/push_model.py,sha256=yDOMVu3ajdNFT1cuzb4R_3qDxlk0qT4aM2oget3aHZ4,961
|
128
127
|
lionagi/integrations/ollama_/api_endpoints/model/show_model.py,sha256=CclV6pEmm5iYM25ePnMAiicVJmZzolDim7BsQoEJAw0,864
|
129
|
-
lionagi/integrations/openai_/OpenAIModel.py,sha256=
|
128
|
+
lionagi/integrations/openai_/OpenAIModel.py,sha256=4SYgSlz5ZMcpEGf_epF8n4emd7ze1UutTjKDJvZDYcQ,15980
|
130
129
|
lionagi/integrations/openai_/OpenAIService.py,sha256=P0sGnxeWPKe15_KndqCgEdM74AKVJ6NJsgFGORqqlrk,13507
|
131
130
|
lionagi/integrations/openai_/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
132
131
|
lionagi/integrations/openai_/openai_max_output_token_data.yaml,sha256=3gd8TGnFjy4AdHzvsV9wZjK_r_o26pe3Th75n5eN2zs,263
|
@@ -207,7 +206,7 @@ lionagi/integrations/openai_/api_endpoints/uploads/complete_upload.py,sha256=elP
|
|
207
206
|
lionagi/integrations/openai_/api_endpoints/uploads/create_upload.py,sha256=1RxKMgeAJxnVUz7-EtTK5c0nbMm5AQD-cj_W1Bo4rSI,479
|
208
207
|
lionagi/integrations/openai_/api_endpoints/uploads/uploads_models.py,sha256=QzmbGiuDejCD8Zxqt92fztGy8ROQS3GmlFouXsWvcik,1561
|
209
208
|
lionagi/integrations/openai_/image_token_calculator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
210
|
-
lionagi/integrations/openai_/image_token_calculator/image_token_calculator.py,sha256=
|
209
|
+
lionagi/integrations/openai_/image_token_calculator/image_token_calculator.py,sha256=4ubm_89-v6WTZwbnRMNUDoflhT2PsiBcnNXt556JO6Y,3302
|
211
210
|
lionagi/integrations/openai_/image_token_calculator/openai_image_token_data.yaml,sha256=xKmjPoJGYepK9_zGMTJgjHZiFNc0MuGLm2DF3o9tv70,204
|
212
211
|
lionagi/integrations/pandas_/__init__.py,sha256=DlYvunk0IwQxpLGcro69crklbACEA9sgRLBE79yVGrs,639
|
213
212
|
lionagi/integrations/pandas_/extend_df.py,sha256=G-IpoZFE5v3bZyVl9d06lMeU7pQOqvWrjCurAoEwDiM,2261
|
@@ -218,7 +217,7 @@ lionagi/integrations/pandas_/save.py,sha256=HBFdPoOJG9cTC_quWw7REWvM1ino_nTD8gSQ
|
|
218
217
|
lionagi/integrations/pandas_/search_keywords.py,sha256=AJfN8QVu6rUni6As8AOTnzne_rDrsXp-YUduBF1f4wE,2241
|
219
218
|
lionagi/integrations/pandas_/to_df.py,sha256=3vAOCj0Ib2PZNCblg1oA20PjRIrUXR86FHICQLNhLu0,5757
|
220
219
|
lionagi/integrations/pandas_/update_cells.py,sha256=7X1bGcPvnEINrLM_zFCWUXIkrFdMGV3TjoEYBq_SThs,1658
|
221
|
-
lionagi/integrations/perplexity_/PerplexityModel.py,sha256=
|
220
|
+
lionagi/integrations/perplexity_/PerplexityModel.py,sha256=06kURklzmc3f-TPwdB3a2zbYttfBTSlBrgZG_Tkw680,9335
|
222
221
|
lionagi/integrations/perplexity_/PerplexityService.py,sha256=q5Ruy60H3cL2a4LOUjB2JI6bkMwKiWVSlrjpATREwqM,3641
|
223
222
|
lionagi/integrations/perplexity_/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
224
223
|
lionagi/integrations/perplexity_/perplexity_max_output_token_data.yaml,sha256=SY6nDrDRhI_HzEBYHaANR_Mc5GRa0SY9Pw_wRuVBlV4,121
|
@@ -238,7 +237,7 @@ lionagi/integrations/pydantic_/break_down_annotation.py,sha256=q9zjhoJkvYjjpfLH_
|
|
238
237
|
lionagi/integrations/pydantic_/new_model.py,sha256=MtlQ86kYeYApAxPLvsXVCDNMKQsFVUvIEcHqbY3SQ7o,6576
|
239
238
|
lionagi/libs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
240
239
|
lionagi/libs/constants.py,sha256=nxZbZVo2msiYDsWMRth_VuqVLaa4CbqaM4CAn0zYXcM,2199
|
241
|
-
lionagi/libs/utils.py,sha256=
|
240
|
+
lionagi/libs/utils.py,sha256=dr-UxZw_XUoNUdvy2HGHWaW3YzTsR23fVkD4Hv-oJtU,7652
|
242
241
|
lionagi/libs/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
243
242
|
lionagi/libs/compress/models.py,sha256=AX6BElvEnnYnCnZzTlJUXknhVGrSTpDHO7DBkSKH0v8,1773
|
244
243
|
lionagi/libs/compress/utils.py,sha256=-U54mWr9_u19BYaS_VNCPCRQQ4kDgB4x4_WNr1WGR8U,2289
|
@@ -257,12 +256,12 @@ lionagi/libs/func/params.py,sha256=y9duFaU7yQ_2cHHln8wbEGhwrKRHhjLwjHhpduEm8Rs,1
|
|
257
256
|
lionagi/libs/func/throttle.py,sha256=iOOmS6i81NGRCClf4WaIhMMXwPt_rZ6WXYBqMJ_weEE,3418
|
258
257
|
lionagi/libs/func/types.py,sha256=wdjGNmY82pVACQBuDMUt3XJO0G9_wKHR7VesOeMxo_A,831
|
259
258
|
lionagi/libs/func/utils.py,sha256=-LMdUEjksXP6JjjcUBh0XEQiXF30Zmv3xpKbmXjfya8,2674
|
260
|
-
lionagi/libs/func/async_calls/__init__.py,sha256=
|
261
|
-
lionagi/libs/func/async_calls/alcall.py,sha256=
|
262
|
-
lionagi/libs/func/async_calls/bcall.py,sha256=
|
259
|
+
lionagi/libs/func/async_calls/__init__.py,sha256=qDHIkH7B-Ka5NJqeeyu_YL3TY36xL8kBwTjtCR4H8AU,495
|
260
|
+
lionagi/libs/func/async_calls/alcall.py,sha256=U8-lWwqNwhe50Q07kzyW4YVcbx_LkUN5X1K1zvFg7i0,7283
|
261
|
+
lionagi/libs/func/async_calls/bcall.py,sha256=gwfKpRZkExjVn-1YGZfaboFES8RqUgyaBrdpNtz1IdY,4436
|
263
262
|
lionagi/libs/func/async_calls/mcall.py,sha256=9O5gWbBT4iIqXfcdZjgAdqsOSLWrNS4_tt6ou231ozA,4607
|
264
263
|
lionagi/libs/func/async_calls/pcall.py,sha256=6u3RJPV-3yOkWxC9iSoVFl1veFfZFJpR0QRyGtfBODI,5831
|
265
|
-
lionagi/libs/func/async_calls/rcall.py,sha256=
|
264
|
+
lionagi/libs/func/async_calls/rcall.py,sha256=pe4flHq88mpalMxloal72GbczALI4PlyixppaA5JxyY,7127
|
266
265
|
lionagi/libs/func/async_calls/tcall.py,sha256=3Kz30kiSts6smZ_x_RRY1gBxpo8p5GwqEMnoamEbWXk,4033
|
267
266
|
lionagi/libs/func/async_calls/ucall.py,sha256=PuV4YZeSMUaSiW8lkHpeA4W-TKU2YH7KZYqx1E6O0y8,2655
|
268
267
|
lionagi/libs/package/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -318,56 +317,58 @@ lionagi/libs/string_similarity/utils.py,sha256=NdD0qF5tuytWBsm0WMrH0gRBBSxw2p4-m
|
|
318
317
|
lionagi/operations/__init__.py,sha256=Dt7o6DFP7zVR-uxZ4xsGHQcse3XVlF6S8Y9NhaUTn_4,68
|
319
318
|
lionagi/operations/utils.py,sha256=kn5SkZRczl1aQ-vJBeVPlMdeyUUD0s5iyuAW4P6KOvQ,1164
|
320
319
|
lionagi/operations/brainstorm/__init__.py,sha256=amsoH65wepsx58DfgH-TRTN1wDH5TC24qYI_f02zkVg,61
|
321
|
-
lionagi/operations/brainstorm/brainstorm.py,sha256=
|
322
|
-
lionagi/operations/brainstorm/prompt.py,sha256=
|
320
|
+
lionagi/operations/brainstorm/brainstorm.py,sha256=H2D0ZBCbRA2Ig60IHuXhyH6Hu02jxKhbj028UtS4eik,6279
|
321
|
+
lionagi/operations/brainstorm/prompt.py,sha256=3a7LsmtiqGAK5mtWoX-2qhsjETBzBx8FxM3cFCBEoOo,497
|
323
322
|
lionagi/operations/plan/__init__.py,sha256=SVqoVmlSGz9lsLztm487H2qOLwgyFxSi2yZ8ubn-bgE,43
|
324
|
-
lionagi/operations/plan/plan.py,sha256=
|
325
|
-
lionagi/operations/plan/prompt.py,sha256=
|
323
|
+
lionagi/operations/plan/plan.py,sha256=Ui8fFdRNLiD3RJmnKCwfY48yj0Fxxw2LBye0egYttWE,5611
|
324
|
+
lionagi/operations/plan/prompt.py,sha256=sKHa_jDahzCJ60oILj1XNYCIlbS-H8ybKRXpf9zd5x0,880
|
326
325
|
lionagi/operations/select/__init__.py,sha256=dUd-KS1l404_ueYlIQsVNhS9jAqjn5pJbtUEbbh6KlI,49
|
327
326
|
lionagi/operations/select/prompt.py,sha256=wbmuDC96fcQ4LFKjqmeErOQwVRpGWRqcwUeLTWnbeNs,186
|
328
327
|
lionagi/operations/select/select.py,sha256=2lQ8el8bQV1kaUF-r5IBfgaGhD2bvrLd9zwfqvcWYgk,3164
|
329
328
|
lionagi/operations/select/utils.py,sha256=JYx-AwR9m9KyUmCwfNm3NAQ6NKYzc3Ti_mV6_f8G_MI,3258
|
330
|
-
lionagi/protocols/__init__.py,sha256=
|
329
|
+
lionagi/protocols/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
331
330
|
lionagi/protocols/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
332
331
|
lionagi/protocols/adapters/adapter.py,sha256=pOnp30ND8rGdotJTIItXG9EDwqJuFO9zp5ShyiqPezk,2250
|
333
332
|
lionagi/protocols/adapters/json_adapter.py,sha256=yCt_GgR6WJfjFWBqeCb6HPtJ0slfepBJi8O0VUeEW8Y,936
|
334
333
|
lionagi/protocols/adapters/pandas_adapter.py,sha256=-ypnH2XAROyIjTv9yrzFpPgqwur67hWAOEubI24Ncpk,2679
|
335
|
-
lionagi/protocols/configs/__init__.py,sha256=
|
336
|
-
lionagi/protocols/configs/branch_config.py,sha256=
|
334
|
+
lionagi/protocols/configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
335
|
+
lionagi/protocols/configs/branch_config.py,sha256=ypsIQycjDSTcGxAfp1k3gSnkvuFJOCJxdUY2ZloRTb4,2727
|
337
336
|
lionagi/protocols/configs/id_config.py,sha256=hkYNorTUfgD3t-kGCQuxi6RGIqsUAn-0RXXxzGCiXxs,360
|
338
|
-
lionagi/protocols/configs/imodel_config.py,sha256=
|
339
|
-
lionagi/protocols/configs/log_config.py,sha256=
|
337
|
+
lionagi/protocols/configs/imodel_config.py,sha256=ctZ9RisIEJe-EpwXg-co15MY4UEvHBmAVQokfSHe4Cc,2317
|
338
|
+
lionagi/protocols/configs/log_config.py,sha256=Zfrh0DTem-PrTHgXyFepXsz34bEwlwH5I59iqSekqGY,2995
|
340
339
|
lionagi/protocols/configs/retry_config.py,sha256=pZwV-iV7YoyPpJgSJTbIXYjOKQjzudnZ7dsSOuy3ZSw,843
|
341
|
-
lionagi/protocols/
|
342
|
-
lionagi/protocols/operatives/
|
343
|
-
lionagi/protocols/operatives/
|
344
|
-
lionagi/protocols/operatives/
|
345
|
-
lionagi/protocols/operatives/
|
346
|
-
lionagi/protocols/operatives/
|
347
|
-
lionagi/protocols/operatives/
|
348
|
-
lionagi/protocols/
|
349
|
-
lionagi/protocols/
|
350
|
-
lionagi/protocols/registries/
|
351
|
-
lionagi/
|
340
|
+
lionagi/protocols/configs/types.py,sha256=8CFN8Lv6F0aJ4Xy7pslnpNTe18dBFaddvzOrAsZuOp0,383
|
341
|
+
lionagi/protocols/operatives/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
342
|
+
lionagi/protocols/operatives/action.py,sha256=cWIyehhB750Sp1w9jPTV-DXcQRLhCFNp2TXHysQvGLU,4854
|
343
|
+
lionagi/protocols/operatives/instruct.py,sha256=XCIkNkuP0Dd7ZOnCpuC2iYuufW9_H8ue5imyqduqQgs,5142
|
344
|
+
lionagi/protocols/operatives/operative.py,sha256=jGsnPSn7LeJE9H-fGjHYIY2N_QgclZpmch8tlshUMcg,6620
|
345
|
+
lionagi/protocols/operatives/prompts.py,sha256=JRJBPiAAccB50sGY2FDIDvSehfc-sCbYLgWmH4BUwBs,2978
|
346
|
+
lionagi/protocols/operatives/reason.py,sha256=i5iIr0xdMISbrJ_u6fQO4MZy0aceX8nYcETVfHILh-8,1441
|
347
|
+
lionagi/protocols/operatives/step.py,sha256=ePFmRyuJ0v_X9BVgzkFAv8afqnic6Zmjt4MGzlCeLpk,8155
|
348
|
+
lionagi/protocols/operatives/types.py,sha256=SPFX2EHHoJF2ZMgxoJrNlf02QlcAk7ijup6kY5GhrK0,463
|
349
|
+
lionagi/protocols/registries/__init__.py,sha256=v8vNyJVIVj8_Oz9RJdVe6ZKUQMYTgDh1VQpnr1KdLaw,112
|
350
|
+
lionagi/protocols/registries/_component_registry.py,sha256=C04oie1-CQJCoXsjZ6hYAIMRySriAFzROA9CPfO0Isg,566
|
351
|
+
lionagi/protocols/registries/_pile_registry.py,sha256=l2RbkjW6OGOHsgPIq9OitIi27r8Fk0vziMI8N_tP3nQ,656
|
352
|
+
lionagi/service/__init__.py,sha256=AQS0ezBCtjZOUbT_QEH-Ev5l41-Pk0_KgmKHUgf_Y_A,375
|
352
353
|
lionagi/service/complete_request_info.py,sha256=V9cWqmQ-fo952EWCooAvezaM_xuxYU4Xy0Jo_0XJnug,301
|
353
354
|
lionagi/service/imodel.py,sha256=laiwc4FvO0jHpf7Q9GrL0VIABCIInkn0ld8XUcbabKo,4191
|
354
355
|
lionagi/service/rate_limiter.py,sha256=1cCtKfpOo_8h4ZN-oX5HXtnq0iGjF1rxi8htyu65kMU,3746
|
355
356
|
lionagi/service/service.py,sha256=58FPZzLM85fNm4WgSzmZRwbHHuLUW1K0VagKZ7A2ZAs,1077
|
356
|
-
lionagi/service/service_match_util.py,sha256=
|
357
|
+
lionagi/service/service_match_util.py,sha256=gjGzfQeQqkyxMrKx8aINS47r3Pmugbcx8JjmvbEBg7Y,4305
|
357
358
|
lionagi/service/service_util.py,sha256=z0tU_wAgWq_gDfm_QeNfDbrsmseumoNxVQ1bEpOCBzg,2985
|
358
359
|
lionagi/service/token_calculator.py,sha256=6FQ7GvCq4nBo_7QbNyekYJmQrVIzL0CNwiztK3QSR3M,1486
|
359
360
|
lionagi/strategies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
360
|
-
lionagi/strategies/base.py,sha256=
|
361
|
-
lionagi/strategies/concurrent.py,sha256=
|
362
|
-
lionagi/strategies/concurrent_chunk.py,sha256=
|
363
|
-
lionagi/strategies/concurrent_sequential_chunk.py,sha256=
|
364
|
-
lionagi/strategies/params.py,sha256=
|
361
|
+
lionagi/strategies/base.py,sha256=l8ZQDHOW9eWrWJrsQFvci3PKuog9S697ulwO3o-y30M,1711
|
362
|
+
lionagi/strategies/concurrent.py,sha256=mrpRfxIxsC0u7JCx2P39Kcnlp7x20cLAdFD4k03hETw,2657
|
363
|
+
lionagi/strategies/concurrent_chunk.py,sha256=V4Ydg4IWe91OXLJAxc3yhQN8gVySj3tpotwvmeOQxmY,1612
|
364
|
+
lionagi/strategies/concurrent_sequential_chunk.py,sha256=iN0tPj5II1vg1XvM1--zi1hgALi1mz1GTjfLs1v8a1w,3558
|
365
|
+
lionagi/strategies/params.py,sha256=KsPtRcX-tM1aphyfLZdDnjnkT6fZHQ5ZewWtf4_Ch4U,4859
|
365
366
|
lionagi/strategies/sequential.py,sha256=pd6MQwCeHDJzC9cNwC6LDtPmrutD_gAo46sOlO_CJR0,822
|
366
367
|
lionagi/strategies/sequential_chunk.py,sha256=jG_WZXG-Ra3yd30CmX4b3XeCNAUrZGA2-i8pSPZGZy0,3032
|
367
368
|
lionagi/strategies/sequential_concurrent_chunk.py,sha256=H7GShaqYlD5XxNJMG2GdOR4Vl8JHDhZb5jxNq8zY0hI,3365
|
368
369
|
lionagi/strategies/types.py,sha256=fEvE4d1H4SeCcXcd2dz3q4k8jFIBtxYzjxDN7eJRLtI,769
|
369
370
|
lionagi/strategies/utils.py,sha256=DX1dvxia8cNRqEJJbssJ3mgRzo7kgWCTA4y5DYLCCZE,1281
|
370
|
-
lionagi-0.5.
|
371
|
-
lionagi-0.5.
|
372
|
-
lionagi-0.5.
|
373
|
-
lionagi-0.5.
|
371
|
+
lionagi-0.5.3.dist-info/METADATA,sha256=EDYWV82gJQWvmwXKbRLUaJjEGQ20B2DL-3emvuhdchg,22736
|
372
|
+
lionagi-0.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
373
|
+
lionagi-0.5.3.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
|
374
|
+
lionagi-0.5.3.dist-info/RECORD,,
|
lionagi/core/typing/config.py
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Copyright (c) 2023 - 2024, HaiyangLi <quantocean.li at gmail dot com>
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
4
|
-
|
5
|
-
from pydantic import BaseModel
|
6
|
-
|
7
|
-
|
8
|
-
class LionIDConfig(BaseModel):
|
9
|
-
n: int
|
10
|
-
random_hyphen: bool
|
11
|
-
num_hyphens: int
|
12
|
-
hyphen_start_index: int
|
13
|
-
hyphen_end_index: int
|
14
|
-
prefix: str = "ln"
|
15
|
-
postfix: str = ""
|
lionagi/core/typing/id.py
DELETED
@@ -1,221 +0,0 @@
|
|
1
|
-
# Copyright (c) 2023 - 2024, HaiyangLi <quantocean.li at gmail dot com>
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
4
|
-
|
5
|
-
from lionagi.libs.utils import insert_random_hyphens, unique_hash
|
6
|
-
from lionagi.settings import LionIDConfig, Settings
|
7
|
-
|
8
|
-
from .concepts import Container, Generic, ItemError, Observable, Ordering, T
|
9
|
-
from .pydantic_ import Field
|
10
|
-
from .typing_ import Annotated, Container, Mapping, Sequence, TypeAlias
|
11
|
-
|
12
|
-
LnID: TypeAlias = Annotated[str, Field(description="A unique identifier.")]
|
13
|
-
|
14
|
-
|
15
|
-
class IDError(ItemError):
|
16
|
-
"""Exception raised when an item does not have a Lion ID."""
|
17
|
-
|
18
|
-
def __init__(
|
19
|
-
self,
|
20
|
-
message: str = "Item must contain a Lion ID.",
|
21
|
-
item_id: str | None = None,
|
22
|
-
):
|
23
|
-
super().__init__(message, item_id)
|
24
|
-
|
25
|
-
|
26
|
-
class ID(Generic[T]):
|
27
|
-
"""
|
28
|
-
A generic class that provides ID-related functionality for Observable objects.
|
29
|
-
|
30
|
-
This class handles the generation, validation, and management of unique identifiers
|
31
|
-
within the Lion system. It provides type aliases for various ID-related operations
|
32
|
-
and methods for working with IDs.
|
33
|
-
"""
|
34
|
-
|
35
|
-
# For functions that accept either ID or item
|
36
|
-
Ref: TypeAlias = LnID | T # type: ignore
|
37
|
-
|
38
|
-
# For functions requiring just the ID
|
39
|
-
ID: TypeAlias = LnID
|
40
|
-
|
41
|
-
# For functions requiring Observable object
|
42
|
-
Item = T # type: ignore
|
43
|
-
|
44
|
-
# For collections
|
45
|
-
IDSeq: TypeAlias = Sequence[LnID] | Ordering[LnID]
|
46
|
-
ItemSeq: TypeAlias = ( # type: ignore
|
47
|
-
Sequence[T] | Mapping[LnID, T] | Container[LnID | T]
|
48
|
-
)
|
49
|
-
RefSeq: TypeAlias = IDSeq | ItemSeq
|
50
|
-
|
51
|
-
# For system-level interactions
|
52
|
-
SenderRecipient: TypeAlias = LnID | T # type: ignore
|
53
|
-
|
54
|
-
@staticmethod
|
55
|
-
def id(
|
56
|
-
config: LionIDConfig = Settings.Config.ID,
|
57
|
-
n: int = None,
|
58
|
-
prefix: str = None,
|
59
|
-
postfix: str = None,
|
60
|
-
random_hyphen: bool = None,
|
61
|
-
num_hyphens: int = None,
|
62
|
-
hyphen_start_index: int = None,
|
63
|
-
hyphen_end_index: int = None,
|
64
|
-
) -> LnID:
|
65
|
-
"""
|
66
|
-
Generate a unique identifier.
|
67
|
-
|
68
|
-
Args:
|
69
|
-
n: Length of the ID (excluding prefix and postfix).
|
70
|
-
prefix: String to prepend to the ID.
|
71
|
-
postfix: String to append to the ID.
|
72
|
-
random_hyphen: If True, insert random hyphens into the ID.
|
73
|
-
num_hyphens: Number of hyphens to insert if random_hyphen is True.
|
74
|
-
hyphen_start_index: Start index for hyphen insertion.
|
75
|
-
hyphen_end_index: End index for hyphen insertion.
|
76
|
-
|
77
|
-
Returns:
|
78
|
-
A unique identifier string.
|
79
|
-
"""
|
80
|
-
_dict = {
|
81
|
-
"n": n,
|
82
|
-
"prefix": prefix,
|
83
|
-
"postfix": postfix,
|
84
|
-
"random_hyphen": random_hyphen,
|
85
|
-
"num_hyphens": num_hyphens,
|
86
|
-
"hyphen_start_index": hyphen_start_index,
|
87
|
-
"hyphen_end_index": hyphen_end_index,
|
88
|
-
}
|
89
|
-
_dict = {k: v for k, v in _dict.items() if v is not None}
|
90
|
-
config = {**config.to_dict(), **_dict}
|
91
|
-
return ID._id(**config)
|
92
|
-
|
93
|
-
@staticmethod
|
94
|
-
def _id(
|
95
|
-
*,
|
96
|
-
n: int,
|
97
|
-
prefix: str = "",
|
98
|
-
postfix: str = "",
|
99
|
-
random_hyphen: bool = False,
|
100
|
-
num_hyphens: int = 0,
|
101
|
-
hyphen_start_index: int = 6,
|
102
|
-
hyphen_end_index: int = -6,
|
103
|
-
):
|
104
|
-
_id = unique_hash(n)
|
105
|
-
if random_hyphen:
|
106
|
-
_id = insert_random_hyphens(
|
107
|
-
s=_id,
|
108
|
-
num_hyphens=num_hyphens,
|
109
|
-
start_index=hyphen_start_index,
|
110
|
-
end_index=hyphen_end_index,
|
111
|
-
)
|
112
|
-
if prefix:
|
113
|
-
_id = f"{prefix}{_id}"
|
114
|
-
if postfix:
|
115
|
-
_id = f"{_id}{postfix}"
|
116
|
-
|
117
|
-
return _id
|
118
|
-
|
119
|
-
@staticmethod
|
120
|
-
def get_id(
|
121
|
-
item,
|
122
|
-
config: LionIDConfig = Settings.Config.ID,
|
123
|
-
/,
|
124
|
-
) -> str:
|
125
|
-
"""
|
126
|
-
Get the Lion ID of an item.
|
127
|
-
|
128
|
-
Args:
|
129
|
-
item: The item to get the ID from.
|
130
|
-
config: Configuration dictionary for ID validation.
|
131
|
-
|
132
|
-
Returns:
|
133
|
-
The Lion ID of the item.
|
134
|
-
|
135
|
-
Raises:
|
136
|
-
LionIDError: If the item does not contain a valid Lion ID.
|
137
|
-
"""
|
138
|
-
|
139
|
-
item_id = None
|
140
|
-
if isinstance(item, Sequence) and len(item) == 1:
|
141
|
-
item = item[0]
|
142
|
-
|
143
|
-
if isinstance(item, Observable):
|
144
|
-
item_id: str = item.ln_id
|
145
|
-
else:
|
146
|
-
item_id = item
|
147
|
-
|
148
|
-
check = isinstance(item_id, str)
|
149
|
-
if check:
|
150
|
-
id_len = (
|
151
|
-
(len(config.prefix) if config.prefix else 0)
|
152
|
-
+ config.n
|
153
|
-
+ config.num_hyphens
|
154
|
-
+ (len(config.postfix) if config.postfix else 0)
|
155
|
-
)
|
156
|
-
if len(item_id) != id_len:
|
157
|
-
check = False
|
158
|
-
if check and config.prefix:
|
159
|
-
if item_id.startswith(config.prefix):
|
160
|
-
item_id = item_id[len(config.prefix) :] # noqa
|
161
|
-
else:
|
162
|
-
check = False
|
163
|
-
if check and config.postfix:
|
164
|
-
if item_id.endswith(config.postfix):
|
165
|
-
item_id = item_id[: -len(config.postfix)]
|
166
|
-
else:
|
167
|
-
check = False
|
168
|
-
if check and config.num_hyphens:
|
169
|
-
if config.num_hyphens != item_id.count("-"):
|
170
|
-
check = False
|
171
|
-
if check and config.hyphen_start_index:
|
172
|
-
idx = config.hyphen_start_index - len(config.prefix)
|
173
|
-
if idx > 0 and "-" in item_id[:idx]:
|
174
|
-
check = False
|
175
|
-
if check and config.hyphen_end_index:
|
176
|
-
if config.hyphen_end_index < 0:
|
177
|
-
idx = config.hyphen_end_index + id_len
|
178
|
-
idx -= len(config.prefix + config.postfix)
|
179
|
-
if idx < 0 and "-" in item_id[idx:]:
|
180
|
-
check = False
|
181
|
-
|
182
|
-
if check:
|
183
|
-
return config.prefix + item_id + config.postfix
|
184
|
-
if (
|
185
|
-
isinstance(item_id, str) and len(item_id) == 32
|
186
|
-
): # for backward compatibility
|
187
|
-
return item_id
|
188
|
-
raise IDError(
|
189
|
-
f"The input object of type <{type(item).__name__}> does "
|
190
|
-
"not contain or is not a valid Lion ID. Item must be an instance"
|
191
|
-
" of `Observable` or a valid `ln_id`."
|
192
|
-
)
|
193
|
-
|
194
|
-
@staticmethod
|
195
|
-
def is_id(
|
196
|
-
item,
|
197
|
-
config: LionIDConfig = Settings.Config.ID,
|
198
|
-
/,
|
199
|
-
) -> bool:
|
200
|
-
"""
|
201
|
-
Check if an item is a valid Lion ID.
|
202
|
-
|
203
|
-
Args:
|
204
|
-
item: The item to check.
|
205
|
-
config: Configuration dictionary for ID validation.
|
206
|
-
|
207
|
-
Returns:
|
208
|
-
True if the item is a valid Lion ID, False otherwise.
|
209
|
-
"""
|
210
|
-
try:
|
211
|
-
ID.get_id(item, config)
|
212
|
-
return True
|
213
|
-
except IDError:
|
214
|
-
return False
|
215
|
-
|
216
|
-
|
217
|
-
__all__ = [
|
218
|
-
"LnID",
|
219
|
-
"ID",
|
220
|
-
"IDError",
|
221
|
-
]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|