lionagi 0.14.7__py3-none-any.whl → 0.14.9__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/_errors.py +120 -11
- lionagi/_types.py +0 -6
- lionagi/config.py +3 -1
- lionagi/fields/instruct.py +0 -1
- lionagi/models/operable_model.py +8 -3
- lionagi/operations/flow.py +0 -1
- lionagi/protocols/generic/event.py +2 -0
- lionagi/protocols/generic/log.py +26 -10
- lionagi/protocols/operatives/step.py +1 -1
- lionagi/protocols/types.py +9 -1
- lionagi/service/__init__.py +22 -1
- lionagi/service/connections/api_calling.py +57 -2
- lionagi/service/connections/endpoint_config.py +1 -1
- lionagi/service/connections/header_factory.py +4 -2
- lionagi/service/connections/match_endpoint.py +10 -10
- lionagi/service/connections/providers/anthropic_.py +5 -2
- lionagi/service/connections/providers/claude_code_.py +13 -17
- lionagi/service/connections/providers/claude_code_cli.py +51 -16
- lionagi/service/connections/providers/exa_.py +5 -3
- lionagi/service/connections/providers/oai_.py +116 -81
- lionagi/service/connections/providers/ollama_.py +38 -18
- lionagi/service/connections/providers/perplexity_.py +36 -14
- lionagi/service/connections/providers/types.py +30 -0
- lionagi/service/hooks/__init__.py +25 -0
- lionagi/service/hooks/_types.py +52 -0
- lionagi/service/hooks/_utils.py +85 -0
- lionagi/service/hooks/hook_event.py +67 -0
- lionagi/service/hooks/hook_registry.py +221 -0
- lionagi/service/imodel.py +120 -34
- lionagi/service/third_party/claude_code.py +715 -0
- lionagi/service/third_party/openai_model_names.py +198 -0
- lionagi/service/third_party/pplx_models.py +16 -8
- lionagi/service/types.py +21 -0
- lionagi/session/branch.py +1 -4
- lionagi/tools/base.py +1 -3
- lionagi/utils.py +8 -2
- lionagi/version.py +1 -1
- {lionagi-0.14.7.dist-info → lionagi-0.14.9.dist-info}/METADATA +66 -25
- {lionagi-0.14.7.dist-info → lionagi-0.14.9.dist-info}/RECORD +41 -37
- lionagi/service/connections/providers/_claude_code/__init__.py +0 -3
- lionagi/service/connections/providers/_claude_code/models.py +0 -234
- lionagi/service/connections/providers/_claude_code/stream_cli.py +0 -359
- lionagi/service/third_party/openai_models.py +0 -18241
- {lionagi-0.14.7.dist-info → lionagi-0.14.9.dist-info}/WHEEL +0 -0
- {lionagi-0.14.7.dist-info → lionagi-0.14.9.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,198 @@
|
|
1
|
+
"""
|
2
|
+
OpenAI Model Names extracted from generated models.
|
3
|
+
|
4
|
+
This module provides lists of allowed model names for different OpenAI services,
|
5
|
+
extracted from the auto-generated openai_models.py file.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from typing import Literal, get_args
|
9
|
+
|
10
|
+
# Manually define the chat models from the ChatModel class in openai_models.py
|
11
|
+
# These are extracted from the Literal type definition
|
12
|
+
CHAT_MODELS = [
|
13
|
+
"gpt-5",
|
14
|
+
"gpt-5-mini",
|
15
|
+
"gpt-5-nano",
|
16
|
+
"gpt-5-2025-08-07",
|
17
|
+
"gpt-5-mini-2025-08-07",
|
18
|
+
"gpt-5-nano-2025-08-07",
|
19
|
+
"gpt-5-chat-latest",
|
20
|
+
"gpt-4.1",
|
21
|
+
"gpt-4.1-mini",
|
22
|
+
"gpt-4.1-nano",
|
23
|
+
"gpt-4.1-2025-04-14",
|
24
|
+
"gpt-4.1-mini-2025-04-14",
|
25
|
+
"gpt-4.1-nano-2025-04-14",
|
26
|
+
"o4-mini",
|
27
|
+
"o4-mini-2025-04-16",
|
28
|
+
"o3",
|
29
|
+
"o3-2025-04-16",
|
30
|
+
"o3-mini",
|
31
|
+
"o3-mini-2025-01-31",
|
32
|
+
"o1",
|
33
|
+
"o1-2024-12-17",
|
34
|
+
"o1-preview",
|
35
|
+
"o1-preview-2024-09-12",
|
36
|
+
"o1-mini",
|
37
|
+
"o1-mini-2024-09-12",
|
38
|
+
"gpt-4o",
|
39
|
+
"gpt-4o-2024-11-20",
|
40
|
+
"gpt-4o-2024-08-06",
|
41
|
+
"gpt-4o-2024-05-13",
|
42
|
+
"gpt-4o-audio-preview",
|
43
|
+
"gpt-4o-audio-preview-2024-10-01",
|
44
|
+
"gpt-4o-audio-preview-2024-12-17",
|
45
|
+
"gpt-4o-audio-preview-2025-06-03",
|
46
|
+
"gpt-4o-mini-audio-preview",
|
47
|
+
"gpt-4o-mini-audio-preview-2024-12-17",
|
48
|
+
"gpt-4o-search-preview",
|
49
|
+
"gpt-4o-mini-search-preview",
|
50
|
+
"gpt-4o-search-preview-2025-03-11",
|
51
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
52
|
+
"chatgpt-4o-latest",
|
53
|
+
"codex-mini-latest",
|
54
|
+
"gpt-4o-mini",
|
55
|
+
"gpt-4o-mini-2024-07-18",
|
56
|
+
"gpt-4-turbo",
|
57
|
+
"gpt-4-turbo-2024-04-09",
|
58
|
+
"gpt-4-0125-preview",
|
59
|
+
"gpt-4-turbo-preview",
|
60
|
+
"gpt-4-1106-preview",
|
61
|
+
"gpt-4-vision-preview",
|
62
|
+
"gpt-4",
|
63
|
+
"gpt-4-0314",
|
64
|
+
"gpt-4-0613",
|
65
|
+
"gpt-4-32k",
|
66
|
+
"gpt-4-32k-0314",
|
67
|
+
"gpt-4-32k-0613",
|
68
|
+
"gpt-3.5-turbo",
|
69
|
+
"gpt-3.5-turbo-16k",
|
70
|
+
"gpt-3.5-turbo-0301",
|
71
|
+
"gpt-3.5-turbo-0613",
|
72
|
+
"gpt-3.5-turbo-1106",
|
73
|
+
"gpt-3.5-turbo-0125",
|
74
|
+
"gpt-3.5-turbo-16k-0613",
|
75
|
+
]
|
76
|
+
|
77
|
+
# Reasoning models (o1, o3, o4 series)
|
78
|
+
# Note: Add o1-pro models that may not be in the generated list yet
|
79
|
+
ADDITIONAL_REASONING_MODELS = [
|
80
|
+
"o1-pro",
|
81
|
+
"o1-pro-2025-03-19",
|
82
|
+
"o3-pro",
|
83
|
+
"o3-pro-2025-06-10",
|
84
|
+
]
|
85
|
+
|
86
|
+
REASONING_MODELS = [
|
87
|
+
model
|
88
|
+
for model in CHAT_MODELS
|
89
|
+
if model.startswith(("o1", "o1-", "o3", "o3-", "o4", "o4-", "gpt-5"))
|
90
|
+
] + ADDITIONAL_REASONING_MODELS
|
91
|
+
|
92
|
+
# GPT models (excluding reasoning models)
|
93
|
+
GPT_MODELS = [
|
94
|
+
model
|
95
|
+
for model in CHAT_MODELS
|
96
|
+
if model.startswith("gpt")
|
97
|
+
or model.startswith("chatgpt")
|
98
|
+
or model.startswith("codex")
|
99
|
+
]
|
100
|
+
|
101
|
+
# Embedding models
|
102
|
+
EMBEDDING_MODELS = [
|
103
|
+
"text-embedding-ada-002",
|
104
|
+
"text-embedding-3-small",
|
105
|
+
"text-embedding-3-large",
|
106
|
+
]
|
107
|
+
|
108
|
+
# Audio models
|
109
|
+
AUDIO_MODELS = {
|
110
|
+
"tts": ["tts-1", "tts-1-hd", "gpt-4o-mini-tts"],
|
111
|
+
"transcription": [
|
112
|
+
"whisper-1",
|
113
|
+
"gpt-4o-transcribe",
|
114
|
+
"gpt-4o-mini-transcribe",
|
115
|
+
],
|
116
|
+
}
|
117
|
+
|
118
|
+
# Image models
|
119
|
+
IMAGE_MODELS = ["dall-e-2", "dall-e-3", "gpt-image-1"]
|
120
|
+
|
121
|
+
# Moderation models
|
122
|
+
MODERATION_MODELS = ["text-moderation-latest", "text-moderation-stable"]
|
123
|
+
|
124
|
+
|
125
|
+
def is_reasoning_model(model: str) -> bool:
|
126
|
+
"""Check if a model is a reasoning model (o1/o3/o4 series)."""
|
127
|
+
return model in REASONING_MODELS
|
128
|
+
|
129
|
+
|
130
|
+
def is_valid_chat_model(model: str) -> bool:
|
131
|
+
"""Check if a model is a valid chat model."""
|
132
|
+
return model in CHAT_MODELS
|
133
|
+
|
134
|
+
|
135
|
+
def is_valid_embedding_model(model: str) -> bool:
|
136
|
+
"""Check if a model is a valid embedding model."""
|
137
|
+
return model in EMBEDDING_MODELS
|
138
|
+
|
139
|
+
|
140
|
+
def get_model_category(model: str) -> str:
|
141
|
+
"""Get the category of a model."""
|
142
|
+
if model in REASONING_MODELS:
|
143
|
+
return "reasoning"
|
144
|
+
elif model in GPT_MODELS:
|
145
|
+
return "gpt"
|
146
|
+
elif model in EMBEDDING_MODELS:
|
147
|
+
return "embedding"
|
148
|
+
elif model in AUDIO_MODELS["tts"]:
|
149
|
+
return "tts"
|
150
|
+
elif model in AUDIO_MODELS["transcription"]:
|
151
|
+
return "transcription"
|
152
|
+
elif model in IMAGE_MODELS:
|
153
|
+
return "image"
|
154
|
+
elif model in MODERATION_MODELS:
|
155
|
+
return "moderation"
|
156
|
+
else:
|
157
|
+
return "unknown"
|
158
|
+
|
159
|
+
|
160
|
+
def validate_model(model: str, category: str = None) -> bool:
|
161
|
+
"""
|
162
|
+
Validate if a model is valid, optionally checking category.
|
163
|
+
|
164
|
+
Args:
|
165
|
+
model: The model name to validate
|
166
|
+
category: Optional category to check against ('chat', 'embedding', etc.)
|
167
|
+
|
168
|
+
Returns:
|
169
|
+
True if model is valid (and in the specified category if provided)
|
170
|
+
"""
|
171
|
+
if category == "chat":
|
172
|
+
return model in CHAT_MODELS or model in ADDITIONAL_REASONING_MODELS
|
173
|
+
elif category == "reasoning":
|
174
|
+
return is_reasoning_model(model)
|
175
|
+
elif category == "embedding":
|
176
|
+
return is_valid_embedding_model(model)
|
177
|
+
elif category:
|
178
|
+
return get_model_category(model) == category
|
179
|
+
else:
|
180
|
+
# Check if model exists in any category
|
181
|
+
return get_model_category(model) != "unknown"
|
182
|
+
|
183
|
+
|
184
|
+
# Export all model lists
|
185
|
+
__all__ = [
|
186
|
+
"CHAT_MODELS",
|
187
|
+
"REASONING_MODELS",
|
188
|
+
"GPT_MODELS",
|
189
|
+
"EMBEDDING_MODELS",
|
190
|
+
"AUDIO_MODELS",
|
191
|
+
"IMAGE_MODELS",
|
192
|
+
"MODERATION_MODELS",
|
193
|
+
"is_reasoning_model",
|
194
|
+
"is_valid_chat_model",
|
195
|
+
"is_valid_embedding_model",
|
196
|
+
"get_model_category",
|
197
|
+
"validate_model",
|
198
|
+
]
|
@@ -6,14 +6,15 @@ from pydantic import BaseModel, Field
|
|
6
6
|
|
7
7
|
class PerplexityModels(str, Enum):
|
8
8
|
"""
|
9
|
-
Models available in Perplexity's API.
|
9
|
+
Models available in Perplexity's API (as of 2025).
|
10
10
|
|
11
|
-
sonar: Lightweight, cost-effective search model
|
12
|
-
answers
|
13
|
-
sonar-pro: Advanced search model optimized for complex queries
|
14
|
-
|
15
|
-
sonar-reasoning: Quick problem-solving and reasoning model
|
11
|
+
sonar: Lightweight, cost-effective search model built on Llama 3.3 70B,
|
12
|
+
designed for quick, grounded answers. F-score: 0.773 on SimpleQA.
|
13
|
+
sonar-pro: Advanced search model optimized for complex queries with double
|
14
|
+
the citations and larger context window. F-score: 0.858 on SimpleQA.
|
15
|
+
sonar-reasoning: Quick problem-solving and reasoning model for evaluating
|
16
16
|
complex queries.
|
17
|
+
sonar-reasoning-pro: Advanced reasoning model with enhanced capabilities.
|
17
18
|
sonar-deep-research: Best suited for exhaustive research, generating detailed
|
18
19
|
reports and in-depth insights.
|
19
20
|
"""
|
@@ -21,6 +22,7 @@ class PerplexityModels(str, Enum):
|
|
21
22
|
SONAR = "sonar"
|
22
23
|
SONAR_PRO = "sonar-pro"
|
23
24
|
SONAR_REASONING = "sonar-reasoning"
|
25
|
+
SONAR_REASONING_PRO = "sonar-reasoning-pro"
|
24
26
|
SONAR_DEEP_RESEARCH = "sonar-deep-research"
|
25
27
|
|
26
28
|
|
@@ -51,18 +53,24 @@ class PerplexityChatRequest(BaseModel):
|
|
51
53
|
"""
|
52
54
|
Represents the request body for Perplexity's Chat Completions endpoint.
|
53
55
|
Endpoint: POST https://api.perplexity.ai/chat/completions
|
56
|
+
Updated: 2025 - Added search_mode and new model options
|
54
57
|
"""
|
55
58
|
|
56
59
|
model: PerplexityModels = Field(
|
57
60
|
PerplexityModels.SONAR,
|
58
|
-
description="The model name
|
59
|
-
"
|
61
|
+
description="The model name. Options: sonar, sonar-pro, sonar-reasoning, "
|
62
|
+
"sonar-reasoning-pro, sonar-deep-research. Default: sonar.",
|
60
63
|
)
|
61
64
|
messages: list[PerplexityMessage] = Field(
|
62
65
|
..., description="A list of messages forming the conversation so far."
|
63
66
|
)
|
64
67
|
|
65
68
|
# Optional parameters
|
69
|
+
search_mode: Literal["default", "academic"] | None = Field(
|
70
|
+
default=None,
|
71
|
+
description="Search mode to use. 'academic' filters results to academic and "
|
72
|
+
"scholarly sources. Default: 'default' (general web search).",
|
73
|
+
)
|
66
74
|
frequency_penalty: float | None = Field(
|
67
75
|
default=1,
|
68
76
|
ge=0,
|
lionagi/service/types.py
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
from .connections.api_calling import APICalling
|
6
6
|
from .connections.endpoint import Endpoint, EndpointConfig
|
7
|
+
from .connections.providers.types import *
|
8
|
+
from .hooks import *
|
7
9
|
from .imodel import iModel
|
8
10
|
from .manager import iModelManager
|
9
11
|
from .rate_limited_processor import RateLimitedAPIExecutor
|
@@ -17,4 +19,23 @@ __all__ = (
|
|
17
19
|
"TokenCalculator",
|
18
20
|
"iModel",
|
19
21
|
"iModelManager",
|
22
|
+
"AnthropicMessagesEndpoint",
|
23
|
+
"ClaudeCodeEndpoint",
|
24
|
+
"ClaudeCodeRequest",
|
25
|
+
"ClaudeCodeCLIEndpoint",
|
26
|
+
"ExaSearchEndpoint",
|
27
|
+
"ExaSearchRequest",
|
28
|
+
"OpenaiChatEndpoint",
|
29
|
+
"OpenaiEmbedEndpoint",
|
30
|
+
"OpenaiResponseEndpoint",
|
31
|
+
"OpenrouterChatEndpoint",
|
32
|
+
"GroqChatEndpoint",
|
33
|
+
"OllamaChatEndpoint",
|
34
|
+
"PerplexityChatEndpoint",
|
35
|
+
"PerplexityChatRequest",
|
36
|
+
"HookEventTypes",
|
37
|
+
"HookDict",
|
38
|
+
"AssosiatedEventInfo",
|
39
|
+
"HookEvent",
|
40
|
+
"HookRegistry",
|
20
41
|
)
|
lionagi/session/branch.py
CHANGED
@@ -205,10 +205,7 @@ class Branch(Element, Communicatable, Relational):
|
|
205
205
|
model=settings.LIONAGI_CHAT_MODEL,
|
206
206
|
)
|
207
207
|
if not parse_model:
|
208
|
-
parse_model =
|
209
|
-
provider=settings.LIONAGI_CHAT_PROVIDER,
|
210
|
-
model="gpt-4o-mini", # Default parse model
|
211
|
-
)
|
208
|
+
parse_model = chat_model
|
212
209
|
|
213
210
|
if isinstance(chat_model, dict):
|
214
211
|
chat_model = iModel.from_dict(chat_model)
|
lionagi/tools/base.py
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
|
5
5
|
from abc import ABC, abstractmethod
|
6
6
|
from enum import Enum
|
7
|
-
from typing import ClassVar
|
8
7
|
|
9
8
|
from pydantic import (
|
10
9
|
BaseModel,
|
@@ -12,7 +11,6 @@ from pydantic import (
|
|
12
11
|
JsonValue,
|
13
12
|
field_serializer,
|
14
13
|
field_validator,
|
15
|
-
model_validator,
|
16
14
|
)
|
17
15
|
|
18
16
|
from lionagi.protocols.action.tool import Tool
|
@@ -44,7 +42,7 @@ class ResourceMeta(BaseModel):
|
|
44
42
|
|
45
43
|
@property
|
46
44
|
def keys(self):
|
47
|
-
return set(self.model_fields.keys())
|
45
|
+
return set(type(self).model_fields.keys())
|
48
46
|
|
49
47
|
|
50
48
|
class Resource(Node):
|
lionagi/utils.py
CHANGED
@@ -7,7 +7,6 @@ import contextlib
|
|
7
7
|
import copy as _copy
|
8
8
|
import dataclasses
|
9
9
|
import functools
|
10
|
-
import importlib.metadata
|
11
10
|
import importlib.util
|
12
11
|
import json
|
13
12
|
import logging
|
@@ -93,12 +92,19 @@ __all__ = (
|
|
93
92
|
"to_num",
|
94
93
|
"breakdown_pydantic_annotation",
|
95
94
|
"run_package_manager_command",
|
95
|
+
"StringEnum",
|
96
96
|
)
|
97
97
|
|
98
98
|
|
99
99
|
# --- General Global Utilities Types ---
|
100
100
|
|
101
101
|
|
102
|
+
class StringEnum(str, Enum):
|
103
|
+
@classmethod
|
104
|
+
def allowed(cls) -> tuple[str, ...]:
|
105
|
+
return tuple(e.value for e in cls)
|
106
|
+
|
107
|
+
|
102
108
|
class UndefinedType:
|
103
109
|
def __init__(self) -> None:
|
104
110
|
self.undefined = True
|
@@ -139,7 +145,7 @@ def hash_dict(data) -> int:
|
|
139
145
|
|
140
146
|
class Params(BaseModel):
|
141
147
|
def keys(self):
|
142
|
-
return self.model_fields.keys()
|
148
|
+
return type(self).model_fields.keys()
|
143
149
|
|
144
150
|
def __call__(self, *args, **kwargs):
|
145
151
|
raise NotImplementedError(
|
lionagi/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.14.
|
1
|
+
__version__ = "0.14.9"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lionagi
|
3
|
-
Version: 0.14.
|
3
|
+
Version: 0.14.9
|
4
4
|
Summary: An Intelligence Operating System.
|
5
5
|
Author-email: HaiyangLi <quantocean.li@gmail.com>, Liangbingyan Luo <llby_luo@outlook.com>
|
6
6
|
License: Apache License
|
@@ -272,7 +272,7 @@ Description-Content-Type: text/markdown
|
|
272
272
|
|
273
273
|
[Documentation](https://lion-agi.github.io/lionagi/) |
|
274
274
|
[Discord](https://discord.gg/JDj9ENhUE8) |
|
275
|
-
[PyPI](https://pypi.org/project/lionagi/)
|
275
|
+
[PyPI](https://pypi.org/project/lionagi/)
|
276
276
|
|
277
277
|
# LION - Language InterOperable Network
|
278
278
|
|
@@ -295,7 +295,9 @@ integrations, and custom validations in a single coherent pipeline.
|
|
295
295
|
## Installation
|
296
296
|
|
297
297
|
```
|
298
|
-
|
298
|
+
uv add lionagi # recommended to use pyproject and uv for dependency management
|
299
|
+
|
300
|
+
pip install lionagi # or install directly
|
299
301
|
```
|
300
302
|
|
301
303
|
## Quick Start
|
@@ -304,12 +306,12 @@ pip install lionagi
|
|
304
306
|
from lionagi import Branch, iModel
|
305
307
|
|
306
308
|
# Pick a model
|
307
|
-
|
309
|
+
gpt41 = iModel(provider="openai", model="gpt-4.1-mini")
|
308
310
|
|
309
311
|
# Create a Branch (conversation context)
|
310
312
|
hunter = Branch(
|
311
313
|
system="you are a hilarious dragon hunter who responds in 10 words rhymes.",
|
312
|
-
chat_model=
|
314
|
+
chat_model=gpt41,
|
313
315
|
)
|
314
316
|
|
315
317
|
# Communicate asynchronously
|
@@ -390,41 +392,75 @@ print(df.tail())
|
|
390
392
|
```python
|
391
393
|
from lionagi import Branch, iModel
|
392
394
|
|
393
|
-
gpt4o = iModel(provider="openai", model="gpt-4o")
|
394
395
|
sonnet = iModel(
|
395
396
|
provider="anthropic",
|
396
397
|
model="claude-3-5-sonnet-20241022",
|
397
398
|
max_tokens=1000, # max_tokens is required for anthropic models
|
398
399
|
)
|
399
400
|
|
400
|
-
branch = Branch(chat_model=
|
401
|
-
# Switch mid-flow
|
402
|
-
analysis = await branch.communicate("Analyze these stats", imodel=sonnet)
|
401
|
+
branch = Branch(chat_model=gpt41)
|
402
|
+
analysis = await branch.communicate("Analyze these stats", chat_model=sonnet) # Switch mid-flow
|
403
403
|
```
|
404
404
|
|
405
405
|
Seamlessly route to different models in the same workflow.
|
406
406
|
|
407
407
|
### Claude Code Integration
|
408
408
|
|
409
|
-
LionAGI now supports Anthropic's
|
409
|
+
LionAGI now supports Anthropic's Claude Code [Python SDK](https://github.com/anthropics/claude-code-sdk-python), and [CLI SDK](https://docs.anthropic.com/en/docs/claude-code/sdk) enabling autonomous coding capabilities with persistent session management. The CLI endpoint
|
410
|
+
directly connects to claude code, and is recommended, you can either use it via a [proxy server](https://github.com/khive-ai/lionagi/tree/main/cookbooks/claude_proxy) or directly with `query_cli` endpoint, provided you have already logged onto claude code cli in your terminal.
|
410
411
|
|
411
412
|
```python
|
412
413
|
from lionagi import iModel, Branch
|
413
414
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
verbose_output=True, # Enable detailed output for debugging
|
422
|
-
)
|
415
|
+
def create_cc_model():
|
416
|
+
return iModel(
|
417
|
+
provider="claude_code",
|
418
|
+
endpoint="query_cli",
|
419
|
+
model="sonnet",
|
420
|
+
verbose_output=True, # Enable detailed output for debugging
|
421
|
+
)
|
423
422
|
|
424
423
|
# Start a coding session
|
425
|
-
|
426
|
-
response = await
|
427
|
-
|
424
|
+
orchestrator = Branch(chat_model=create_cc_model())
|
425
|
+
response = await orchestrator.communicate("Explain the architecture of protocols, operations, and branch")
|
426
|
+
|
427
|
+
# continue the session with more queries
|
428
|
+
response2 = await orchestrator.communicate("how do these parts form lionagi system")
|
429
|
+
```
|
430
|
+
|
431
|
+
### Fan out fan in pattern orchestration with claude code
|
432
|
+
|
433
|
+
```python
|
434
|
+
# use structured outputs with claude code
|
435
|
+
from lionagi.fields import LIST_INSTRUCT_FIELD_MODEL, Instruct
|
436
|
+
|
437
|
+
response3 = await orchestrator.operate(
|
438
|
+
instruct=Instruct(
|
439
|
+
instruction="create 4 research questions for parallel discovery",
|
440
|
+
guidance="put into `instruct_models` field as part of your structured result message",
|
441
|
+
context="I'd like to create an orchestration system for AI agents using lionagi"
|
442
|
+
),
|
443
|
+
field_models=[LIST_INSTRUCT_FIELD_MODEL],
|
444
|
+
)
|
445
|
+
|
446
|
+
len(response3.instruct_models) # should be 4
|
447
|
+
|
448
|
+
async def handle_instruct(instruct):
|
449
|
+
sub_branch = Branch(
|
450
|
+
system="You are an diligent research expert.",
|
451
|
+
chat_model=create_cc_model(),
|
452
|
+
)
|
453
|
+
return await sub_branch.operate(instruct=instruct)
|
454
|
+
|
455
|
+
# run in parallel across all instruct models
|
456
|
+
from lionagi.utils import alcall
|
457
|
+
responses = await alcall(response3.instruct_models, handle_instruct)
|
458
|
+
|
459
|
+
# now hand these reports back to the orchestrator
|
460
|
+
final_response = await orchestrator.communicate(
|
461
|
+
"please synthesize these research findings into a final report",
|
462
|
+
context=responses,
|
463
|
+
)
|
428
464
|
```
|
429
465
|
|
430
466
|
Key features:
|
@@ -436,9 +472,14 @@ Key features:
|
|
436
472
|
### optional dependencies
|
437
473
|
|
438
474
|
```
|
439
|
-
|
440
|
-
|
441
|
-
|
475
|
+
"lionagi[reader]" - Reader tool for any unstructured data and web pages
|
476
|
+
"lionagi[ollama]" - Ollama model support for local inference
|
477
|
+
"lionagi[claude-code]" - Claude code python SDK integration (cli endpoint does not require this)
|
478
|
+
"lionagi[rich]" - Rich output formatting for better console display
|
479
|
+
"lionagi[schema]" - Convert pydantic schema to make the Model class persistent
|
480
|
+
"lionagi[postgres]" - Postgres database support for storing and retrieving structured data
|
481
|
+
"lionagi[graph]" - Graph display for visualizing complex workflows
|
482
|
+
"lionagi[sqlite]" - SQLite database support for lightweight data storage (also need `postgres` option)
|
442
483
|
```
|
443
484
|
|
444
485
|
## Community & Contributing
|
@@ -1,12 +1,12 @@
|
|
1
1
|
lionagi/__init__.py,sha256=x_DLjvYZp15u2L3pjIKrUDvvdDBzf7VmrhYVzbsACjU,725
|
2
2
|
lionagi/_class_registry.py,sha256=pfUO1DjFZIqr3OwnNMkFqL_fiEBrrf8-swkGmP_KDLE,3112
|
3
|
-
lionagi/_errors.py,sha256=
|
4
|
-
lionagi/_types.py,sha256=
|
5
|
-
lionagi/config.py,sha256=
|
3
|
+
lionagi/_errors.py,sha256=ia_VWhPSyr5FIJLSdPpl04SrNOLI2skN40VC8ePmzeQ,3748
|
4
|
+
lionagi/_types.py,sha256=j8XwSGeGrYwfmSJ8o-80bsfoalLWJgQH41ZkVevc4wk,75
|
5
|
+
lionagi/config.py,sha256=W3JOC_TFad8hFkpTG8yv0-GNupa7x3wX4NAUfWpB59U,3763
|
6
6
|
lionagi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
lionagi/settings.py,sha256=HDuKCEJCpc4HudKodBnhoQUGuTGhRHdlIFhbtf3VBtY,1633
|
8
|
-
lionagi/utils.py,sha256=
|
9
|
-
lionagi/version.py,sha256=
|
8
|
+
lionagi/utils.py,sha256=OfVCIOPe2_n7BFTuM9yBB-01nwOqr11MWw1HMg0sZRs,75153
|
9
|
+
lionagi/version.py,sha256=AcYEUw0wtvXP8hU6u7xyIlxSWnqRoC6gALGftbHgs_Y,23
|
10
10
|
lionagi/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
lionagi/adapters/async_postgres_adapter.py,sha256=Kf2YCzwRqKpEHY3GQCXEiMl201CCIkDvXcvddwZNkkE,12723
|
12
12
|
lionagi/adapters/postgres_model_adapter.py,sha256=e_wfJNyihbpLCXuAs_W9tbLoMXAXbAXtkQDaHfqWz3o,4555
|
@@ -15,7 +15,7 @@ lionagi/fields/action.py,sha256=OziEpbaUeEVo34KdtbzDxXJBgkf3QLxlcKIQAfHe4O0,5791
|
|
15
15
|
lionagi/fields/base.py,sha256=mvgqxLonCROszMjnG8QWt00l-MvIr_mnGvCtaH-SQ_k,3814
|
16
16
|
lionagi/fields/code.py,sha256=TFym51obzaSfCmeRoHZJyBtjfDI4tvl9F-1sjFc9rMw,7713
|
17
17
|
lionagi/fields/file.py,sha256=DhQ_HE0RvTNzkvBGQHRgbMYSokDkzE8GEu814i6jw5Q,7297
|
18
|
-
lionagi/fields/instruct.py,sha256=
|
18
|
+
lionagi/fields/instruct.py,sha256=2koYdY7XyJh5lrd7tD_BA9bqCbmpsdTDaASEv_dX4i8,4334
|
19
19
|
lionagi/fields/reason.py,sha256=eTGI9jDaaZJInUjCR9lEpYvw2_1UUF-xzCVCFP3-JRI,1437
|
20
20
|
lionagi/fields/research.py,sha256=eEPKocx8eQy2E9FExRWVIo6MK_xvmwBAoRZciBY3RG0,1421
|
21
21
|
lionagi/libs/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
@@ -93,11 +93,11 @@ lionagi/models/field_model.py,sha256=pRFUYs72BRB6jo4NkgeqslCp0xwqzvh00ibh8uaMAws
|
|
93
93
|
lionagi/models/hashable_model.py,sha256=fpBv4_BcD5F5Laxa_uQ13EPMnVUBP-J0IMxzV9-35Cc,868
|
94
94
|
lionagi/models/model_params.py,sha256=zVU-PHp3skjK5ZVjpsPs1k_VJiS8X0hgct0xs6Z6W_Y,10955
|
95
95
|
lionagi/models/note.py,sha256=okWJL4mGqt0bUVxHRyqsfJr7tEh6wwgYhF1CegxudIA,12202
|
96
|
-
lionagi/models/operable_model.py,sha256=
|
96
|
+
lionagi/models/operable_model.py,sha256=Zm_Hxdauqyh0za3_TJLCZ3g6nR4F45Rrnc0ZM3d54Gs,20111
|
97
97
|
lionagi/models/schema_model.py,sha256=ghRIM8aBNaToAknwNlhQKpuKXcwzyCw5pDE31bVKxs0,667
|
98
98
|
lionagi/operations/__init__.py,sha256=L22n8rRls9oVdzHoDlznHFGiKJMNw3ZhbwVQbm1Fn6M,584
|
99
99
|
lionagi/operations/builder.py,sha256=_fIW5OqPTTond1VUapMMtEwsWmIuTAKy34K24uuK6EQ,22790
|
100
|
-
lionagi/operations/flow.py,sha256=
|
100
|
+
lionagi/operations/flow.py,sha256=MC1g4vyhrFPUCUsL4_SZZBPrp0q5SMgk72ECrTowk2Q,17567
|
101
101
|
lionagi/operations/manager.py,sha256=7KD6NMWqYJHCPI2LumDRwGinF8WYKFjrr3bsNUi9xzI,564
|
102
102
|
lionagi/operations/node.py,sha256=X_uHT_zmDKllfTjuhOHslC55j3Bv3NxVZO3bsimcedE,3100
|
103
103
|
lionagi/operations/types.py,sha256=fM8HphnbBifMzhoKKvdl3JxGCBHlEGPJEYkLWj9b7vE,704
|
@@ -132,7 +132,7 @@ lionagi/operations/translate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
132
132
|
lionagi/operations/translate/translate.py,sha256=6eBVoQRarGEJ8Tfcl6Z__PLHQTTIbM5MaPVYNeKHRIs,1397
|
133
133
|
lionagi/protocols/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
134
134
|
lionagi/protocols/_concepts.py,sha256=ZBN5OYpLMWLrl9uZqSg9GD4uwf60V4VHcxRnBTRWIRc,1555
|
135
|
-
lionagi/protocols/types.py,sha256=
|
135
|
+
lionagi/protocols/types.py,sha256=COmDrDzdStRDFt314iLLCvTWQvuB-elXplXlWI1OcKM,2533
|
136
136
|
lionagi/protocols/action/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
137
137
|
lionagi/protocols/action/function_calling.py,sha256=rfuzIowjJpyqO5Ynfs5fGnxsDIU5aKinTj1NI6bGlEU,5106
|
138
138
|
lionagi/protocols/action/manager.py,sha256=XmdQIaVgSpmFBFW9kbW_rdwdQmlBteP4VRanxh_f918,8549
|
@@ -144,8 +144,8 @@ lionagi/protocols/forms/form.py,sha256=B4903km_Ljz-OxYkb1ZT_cpHZSaAYYJpZMsffWloo
|
|
144
144
|
lionagi/protocols/forms/report.py,sha256=SvJJjOSCTfVuqK7AKaY8ldQIGJeSK2zoyPWUV41ge2c,1609
|
145
145
|
lionagi/protocols/generic/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
146
146
|
lionagi/protocols/generic/element.py,sha256=Eaij2YpTWsGk28Tqjazmjmc_tOnalH7_iGFZrL6QJb4,14420
|
147
|
-
lionagi/protocols/generic/event.py,sha256=
|
148
|
-
lionagi/protocols/generic/log.py,sha256=
|
147
|
+
lionagi/protocols/generic/event.py,sha256=lA-NkpK87Rj7usi22cNqEZee8aRjPwaWKy_aXxdLQ54,5252
|
148
|
+
lionagi/protocols/generic/log.py,sha256=Y06zAQewkNlaIWjut_c6c45KY_LJfLHwzUaDGLULaas,8212
|
149
149
|
lionagi/protocols/generic/pile.py,sha256=k5fzq0qRPYiP-3NnB-ai499y6bbOqkCR4N4QPvD45ZU,30418
|
150
150
|
lionagi/protocols/generic/processor.py,sha256=c_a7HB9WAaCY-HoI19YyStef8WOXcDj9UeiQb5bz_TM,11759
|
151
151
|
lionagi/protocols/generic/progression.py,sha256=qlITq1qzV119iR5qR__fBAzV489S7d4t20E8uDRicEw,15189
|
@@ -177,48 +177,52 @@ lionagi/protocols/messages/templates/system_message.jinja2,sha256=JRKJ0aFpYfaXSF
|
|
177
177
|
lionagi/protocols/messages/templates/tool_schemas.jinja2,sha256=ozIaSDCRjIAhLyA8VM6S-YqS0w2NcctALSwx4LjDwII,126
|
178
178
|
lionagi/protocols/operatives/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
179
179
|
lionagi/protocols/operatives/operative.py,sha256=l417XukoI_ZRyVqjHy8q1BtTKBvlFxf3Fuhrxt057SI,13350
|
180
|
-
lionagi/protocols/operatives/step.py,sha256=
|
181
|
-
lionagi/service/__init__.py,sha256=
|
182
|
-
lionagi/service/imodel.py,sha256=
|
180
|
+
lionagi/protocols/operatives/step.py,sha256=3l1Ui9gD0LSrhikTMSejEmn22M1FY8DPD5TpxVwq04w,9841
|
181
|
+
lionagi/service/__init__.py,sha256=C_TPk1roVYz6uVLK1JVxrK3tPtYqN6W0D7FzI-s6CWY,556
|
182
|
+
lionagi/service/imodel.py,sha256=ya406sf42-KRrKN4TJJLtI6wsKeM5hAhWr7Hubg7W0E,16371
|
183
183
|
lionagi/service/manager.py,sha256=tN3p0kM7pg_CEs6wXK62_B_h49Q3nrU-9qniFhw2ABE,1164
|
184
184
|
lionagi/service/rate_limited_processor.py,sha256=JhkuzJMHUCdndkRbAUf9wUQI9zOw-dutRy_nHf8EE5I,6101
|
185
185
|
lionagi/service/resilience.py,sha256=uYJYZQ9M-tje8ME3vJmYabXwKHF1c3Ij4-WrdCwogcs,18742
|
186
186
|
lionagi/service/token_calculator.py,sha256=piTidArzUkIMCtOLC_HBLoZNYZcENQywgeKM31bxezM,6457
|
187
|
-
lionagi/service/types.py,sha256=
|
187
|
+
lionagi/service/types.py,sha256=9zX08BhdmPE9FE1YTyvsy14hdDGRYzyyVBmoBURzQvI,1096
|
188
188
|
lionagi/service/connections/__init__.py,sha256=yHQZ7OJpCftd6CStYR8inbxjJydYdmv9kCvbUBhJ2zU,362
|
189
|
-
lionagi/service/connections/api_calling.py,sha256=
|
189
|
+
lionagi/service/connections/api_calling.py,sha256=FX9PbpZr3TypgJYfh3G7-gOpaYHLP54GLidvJbbTvAg,9955
|
190
190
|
lionagi/service/connections/endpoint.py,sha256=yNIjq9wETMnytynGbq3qY_dkyaMlaHrcfiZjS-tnmLg,14756
|
191
|
-
lionagi/service/connections/endpoint_config.py,sha256=
|
192
|
-
lionagi/service/connections/header_factory.py,sha256=
|
193
|
-
lionagi/service/connections/match_endpoint.py,sha256=
|
191
|
+
lionagi/service/connections/endpoint_config.py,sha256=6sA06uCzriT6p0kFxhDCFH8N6V6MVp8ytlOw5ctBhDI,5169
|
192
|
+
lionagi/service/connections/header_factory.py,sha256=IYeTQQk7r8FXcdhmW7orCxHjNO-Nb1EOXhgNK7CAp-I,1821
|
193
|
+
lionagi/service/connections/match_endpoint.py,sha256=kHAs6FmWJWjIn4CO7FwZVi8w1lYcvu2vGSf9ww2sCG4,2470
|
194
194
|
lionagi/service/connections/providers/__init__.py,sha256=3lzOakDoBWmMaNnT2g-YwktPKa_Wme4lnPRSmOQfayY,105
|
195
|
-
lionagi/service/connections/providers/anthropic_.py,sha256=
|
196
|
-
lionagi/service/connections/providers/claude_code_.py,sha256=
|
197
|
-
lionagi/service/connections/providers/claude_code_cli.py,sha256=
|
198
|
-
lionagi/service/connections/providers/exa_.py,sha256=
|
199
|
-
lionagi/service/connections/providers/oai_.py,sha256=
|
200
|
-
lionagi/service/connections/providers/ollama_.py,sha256=
|
201
|
-
lionagi/service/connections/providers/perplexity_.py,sha256=
|
202
|
-
lionagi/service/connections/providers/
|
203
|
-
lionagi/service/
|
204
|
-
lionagi/service/
|
195
|
+
lionagi/service/connections/providers/anthropic_.py,sha256=vok8mIyFiuV3K83tOjdYfruA6cv1h_57ML6RtpuW-bU,3157
|
196
|
+
lionagi/service/connections/providers/claude_code_.py,sha256=QjyxuyHyL_9tEHxH7zJx21tLd4VRF69i4Xcwo34f0qE,10413
|
197
|
+
lionagi/service/connections/providers/claude_code_cli.py,sha256=kqEOnCUOOh2O_3NGi6W7r-gdLsbW-Jcp11tm30VEv4Q,4455
|
198
|
+
lionagi/service/connections/providers/exa_.py,sha256=kuWD7yyYRqIa4ChSn0TsxFA5V5LwvFUD-w8TZ6mx4rk,1048
|
199
|
+
lionagi/service/connections/providers/oai_.py,sha256=3x5d6Ei1hKu8Mix0N2V2K21O9dd-2jtAELHhHXj5iHk,6071
|
200
|
+
lionagi/service/connections/providers/ollama_.py,sha256=oqYLWn81KrWoQgId4e4GD_bgrDjQLPOmhqlc5uBuFGk,4569
|
201
|
+
lionagi/service/connections/providers/perplexity_.py,sha256=1GMmxAXsKGsB-xlqxO6hW-QdqoqkU2705NLyejetFSw,1646
|
202
|
+
lionagi/service/connections/providers/types.py,sha256=nxRDBEqCVG4Nw_gfL5NYmeRUEJGAjKNZ-jlL48xYqv0,878
|
203
|
+
lionagi/service/hooks/__init__.py,sha256=Ayllxjd1fR_6NByZlE2zslQ7I0Od-s6-OVe0mzZIeu4,569
|
204
|
+
lionagi/service/hooks/_types.py,sha256=cmgUkthWHY8LLc-JWN8z-1yh5MCM3mRRyci0Hppk8QI,1176
|
205
|
+
lionagi/service/hooks/_utils.py,sha256=JxYKtJIYpzeRFvG4X4kAIkL9FpJ18WJR7SjUN-abwlU,2548
|
206
|
+
lionagi/service/hooks/hook_event.py,sha256=ApRCsqB0jk4IWsmm2GZ-QoIzgPXcdyxQcfRZim0h7sU,2420
|
207
|
+
lionagi/service/hooks/hook_registry.py,sha256=ch22AOP-FsV27I9i0mYWnHKhh2C49XIjuj7d0U8YVlg,7795
|
205
208
|
lionagi/service/third_party/README.md,sha256=qFjWnI8rmLivIyr6Tc-hRZh-rQwntROp76af4MBNJJc,2214
|
206
209
|
lionagi/service/third_party/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
207
210
|
lionagi/service/third_party/anthropic_models.py,sha256=oqSPSlcayYG-fS5BLiLeTtkrpaxgkPhEK_YgneumrOo,4004
|
211
|
+
lionagi/service/third_party/claude_code.py,sha256=ZUNH3pHDqsKyaCRrr-IyU_Ad-SfeyfrLMS-Ht--Wdd8,24765
|
208
212
|
lionagi/service/third_party/exa_models.py,sha256=G_hnekcy-DillPLzMoDQ8ZisVAL8Mp7iMAK4xqAT_3w,5470
|
209
|
-
lionagi/service/third_party/
|
210
|
-
lionagi/service/third_party/pplx_models.py,sha256
|
213
|
+
lionagi/service/third_party/openai_model_names.py,sha256=C44tnqexgc4ZU2-3I_sn5d688hf3WWx-25xBd50bvas,5121
|
214
|
+
lionagi/service/third_party/pplx_models.py,sha256=-EhyJgOWR6rzSv3zczUtk80X6c19p18Dg9KC6l8BFRQ,6473
|
211
215
|
lionagi/session/__init__.py,sha256=kDypY6L3kGPnatAw7YNQAykgg-9MlIBnlhHExaXvt-c,202
|
212
|
-
lionagi/session/branch.py,sha256=
|
216
|
+
lionagi/session/branch.py,sha256=bDEXCScz7TKLVUoNVWQYMUs3Qqyaql0gS2N2ccxFPrk,67851
|
213
217
|
lionagi/session/prompts.py,sha256=GPr0jibyAAqS3awDzGC8SoCL6aWJLLCCbXY0JUuxOC0,3170
|
214
218
|
lionagi/session/session.py,sha256=Gc31wPLFdBOMRs3zEs11KVShvDtLUAqqhbhMoySptqo,11379
|
215
219
|
lionagi/tools/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
216
|
-
lionagi/tools/base.py,sha256=
|
220
|
+
lionagi/tools/base.py,sha256=hEGnE4MD0CM4UqnF0xsDRKB0aM-pyrTFHl8utHhyJLU,1897
|
217
221
|
lionagi/tools/types.py,sha256=XtJLY0m-Yi_ZLWhm0KycayvqMCZd--HxfQ0x9vFUYDE,230
|
218
222
|
lionagi/tools/file/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
219
223
|
lionagi/tools/file/reader.py,sha256=0TdnfVGVCKuM58MmGM-NyVjhU9BFoitkNYEepdc0z_Y,9529
|
220
224
|
lionagi/tools/memory/tools.py,sha256=zTGBenVsF8Wuh303kWntmQSGlAFKonHNdh5ePuQ26KE,15948
|
221
|
-
lionagi-0.14.
|
222
|
-
lionagi-0.14.
|
223
|
-
lionagi-0.14.
|
224
|
-
lionagi-0.14.
|
225
|
+
lionagi-0.14.9.dist-info/METADATA,sha256=cfKgfdH1H0MRbmr--ruXJiJXBj2xYOK8U9Lu1lLxTcs,22792
|
226
|
+
lionagi-0.14.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
227
|
+
lionagi-0.14.9.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
|
228
|
+
lionagi-0.14.9.dist-info/RECORD,,
|