lionagi 0.14.8__py3-none-any.whl → 0.14.10__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/reason.py +1 -1
- lionagi/libs/concurrency/throttle.py +79 -0
- lionagi/libs/parse.py +2 -1
- lionagi/libs/unstructured/__init__.py +0 -0
- lionagi/libs/unstructured/pdf_to_image.py +45 -0
- lionagi/libs/unstructured/read_image_to_base64.py +33 -0
- lionagi/libs/validate/to_num.py +378 -0
- lionagi/libs/validate/xml_parser.py +203 -0
- 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/tools/file/reader.py +1 -1
- lionagi/tools/memory/tools.py +2 -2
- lionagi/utils.py +12 -775
- lionagi/version.py +1 -1
- {lionagi-0.14.8.dist-info → lionagi-0.14.10.dist-info}/METADATA +6 -2
- {lionagi-0.14.8.dist-info → lionagi-0.14.10.dist-info}/RECORD +50 -40
- lionagi/service/connections/providers/_claude_code/__init__.py +0 -3
- lionagi/service/connections/providers/_claude_code/models.py +0 -244
- lionagi/service/connections/providers/_claude_code/stream_cli.py +0 -359
- lionagi/service/third_party/openai_models.py +0 -18241
- {lionagi-0.14.8.dist-info → lionagi-0.14.10.dist-info}/WHEEL +0 -0
- {lionagi-0.14.8.dist-info → lionagi-0.14.10.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/tools/file/reader.py
CHANGED
@@ -7,9 +7,9 @@ from enum import Enum
|
|
7
7
|
|
8
8
|
from pydantic import BaseModel, Field, model_validator
|
9
9
|
|
10
|
+
from lionagi.libs.validate.to_num import to_num
|
10
11
|
from lionagi.protocols.action.tool import Tool
|
11
12
|
from lionagi.service.token_calculator import TokenCalculator
|
12
|
-
from lionagi.utils import to_num
|
13
13
|
|
14
14
|
from ..base import LionTool
|
15
15
|
|
lionagi/tools/memory/tools.py
CHANGED
@@ -4,13 +4,13 @@ Memory Tools - Proper lionagi tool implementation following reader pattern
|
|
4
4
|
|
5
5
|
from datetime import datetime, timezone
|
6
6
|
from enum import Enum
|
7
|
-
from typing import Any
|
7
|
+
from typing import Any
|
8
8
|
|
9
9
|
from pydantic import BaseModel, Field, model_validator
|
10
10
|
|
11
|
+
from lionagi.libs.validate.to_num import to_num
|
11
12
|
from lionagi.protocols.action.tool import Tool
|
12
13
|
from lionagi.tools.base import LionTool
|
13
|
-
from lionagi.utils import to_num
|
14
14
|
|
15
15
|
|
16
16
|
class MemoryAction(str, Enum):
|