mirascope 2.0.0a3__py3-none-any.whl → 2.0.0a5__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.
- mirascope/api/_generated/__init__.py +78 -6
- mirascope/api/_generated/api_keys/__init__.py +7 -0
- mirascope/api/_generated/api_keys/client.py +453 -0
- mirascope/api/_generated/api_keys/raw_client.py +853 -0
- mirascope/api/_generated/api_keys/types/__init__.py +9 -0
- mirascope/api/_generated/api_keys/types/api_keys_create_response.py +36 -0
- mirascope/api/_generated/api_keys/types/api_keys_get_response.py +35 -0
- mirascope/api/_generated/api_keys/types/api_keys_list_response_item.py +35 -0
- mirascope/api/_generated/client.py +14 -0
- mirascope/api/_generated/environments/__init__.py +17 -0
- mirascope/api/_generated/environments/client.py +532 -0
- mirascope/api/_generated/environments/raw_client.py +1088 -0
- mirascope/api/_generated/environments/types/__init__.py +15 -0
- mirascope/api/_generated/environments/types/environments_create_response.py +26 -0
- mirascope/api/_generated/environments/types/environments_get_response.py +26 -0
- mirascope/api/_generated/environments/types/environments_list_response_item.py +26 -0
- mirascope/api/_generated/environments/types/environments_update_response.py +26 -0
- mirascope/api/_generated/errors/__init__.py +11 -1
- mirascope/api/_generated/errors/conflict_error.py +15 -0
- mirascope/api/_generated/errors/forbidden_error.py +15 -0
- mirascope/api/_generated/errors/internal_server_error.py +15 -0
- mirascope/api/_generated/errors/not_found_error.py +15 -0
- mirascope/api/_generated/organizations/__init__.py +25 -0
- mirascope/api/_generated/organizations/client.py +404 -0
- mirascope/api/_generated/organizations/raw_client.py +902 -0
- mirascope/api/_generated/organizations/types/__init__.py +23 -0
- mirascope/api/_generated/organizations/types/organizations_create_response.py +25 -0
- mirascope/api/_generated/organizations/types/organizations_create_response_role.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_get_response.py +25 -0
- mirascope/api/_generated/organizations/types/organizations_get_response_role.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_list_response_item.py +25 -0
- mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +7 -0
- mirascope/api/_generated/organizations/types/organizations_update_response.py +25 -0
- mirascope/api/_generated/organizations/types/organizations_update_response_role.py +7 -0
- mirascope/api/_generated/projects/__init__.py +17 -0
- mirascope/api/_generated/projects/client.py +482 -0
- mirascope/api/_generated/projects/raw_client.py +1058 -0
- mirascope/api/_generated/projects/types/__init__.py +15 -0
- mirascope/api/_generated/projects/types/projects_create_response.py +31 -0
- mirascope/api/_generated/projects/types/projects_get_response.py +31 -0
- mirascope/api/_generated/projects/types/projects_list_response_item.py +31 -0
- mirascope/api/_generated/projects/types/projects_update_response.py +31 -0
- mirascope/api/_generated/reference.md +1311 -0
- mirascope/api/_generated/types/__init__.py +20 -4
- mirascope/api/_generated/types/already_exists_error.py +24 -0
- mirascope/api/_generated/types/already_exists_error_tag.py +5 -0
- mirascope/api/_generated/types/database_error.py +24 -0
- mirascope/api/_generated/types/database_error_tag.py +5 -0
- mirascope/api/_generated/types/http_api_decode_error.py +1 -3
- mirascope/api/_generated/types/issue.py +1 -5
- mirascope/api/_generated/types/not_found_error_body.py +24 -0
- mirascope/api/_generated/types/not_found_error_tag.py +5 -0
- mirascope/api/_generated/types/permission_denied_error.py +24 -0
- mirascope/api/_generated/types/permission_denied_error_tag.py +7 -0
- mirascope/api/_generated/types/property_key.py +2 -2
- mirascope/api/_generated/types/{property_key_tag.py → property_key_key.py} +3 -5
- mirascope/api/_generated/types/{property_key_tag_tag.py → property_key_key_tag.py} +1 -1
- mirascope/llm/__init__.py +6 -2
- mirascope/llm/exceptions.py +28 -0
- mirascope/llm/providers/__init__.py +12 -4
- mirascope/llm/providers/anthropic/__init__.py +6 -1
- mirascope/llm/providers/anthropic/_utils/__init__.py +17 -5
- mirascope/llm/providers/anthropic/_utils/beta_decode.py +271 -0
- mirascope/llm/providers/anthropic/_utils/beta_encode.py +216 -0
- mirascope/llm/providers/anthropic/_utils/decode.py +39 -7
- mirascope/llm/providers/anthropic/_utils/encode.py +156 -64
- mirascope/llm/providers/anthropic/_utils/errors.py +46 -0
- mirascope/llm/providers/anthropic/beta_provider.py +328 -0
- mirascope/llm/providers/anthropic/model_id.py +10 -27
- mirascope/llm/providers/anthropic/model_info.py +87 -0
- mirascope/llm/providers/anthropic/provider.py +132 -145
- mirascope/llm/providers/base/__init__.py +2 -1
- mirascope/llm/providers/base/_utils.py +15 -1
- mirascope/llm/providers/base/base_provider.py +173 -58
- mirascope/llm/providers/google/_utils/__init__.py +2 -0
- mirascope/llm/providers/google/_utils/decode.py +55 -3
- mirascope/llm/providers/google/_utils/encode.py +14 -6
- mirascope/llm/providers/google/_utils/errors.py +49 -0
- mirascope/llm/providers/google/model_id.py +7 -13
- mirascope/llm/providers/google/model_info.py +62 -0
- mirascope/llm/providers/google/provider.py +13 -8
- mirascope/llm/providers/mlx/_utils.py +31 -2
- mirascope/llm/providers/mlx/encoding/transformers.py +17 -1
- mirascope/llm/providers/mlx/provider.py +12 -0
- mirascope/llm/providers/ollama/__init__.py +19 -0
- mirascope/llm/providers/ollama/provider.py +71 -0
- mirascope/llm/providers/openai/__init__.py +10 -1
- mirascope/llm/providers/openai/_utils/__init__.py +5 -0
- mirascope/llm/providers/openai/_utils/errors.py +46 -0
- mirascope/llm/providers/openai/completions/__init__.py +6 -1
- mirascope/llm/providers/openai/completions/_utils/decode.py +57 -5
- mirascope/llm/providers/openai/completions/_utils/encode.py +9 -8
- mirascope/llm/providers/openai/completions/base_provider.py +513 -0
- mirascope/llm/providers/openai/completions/provider.py +13 -447
- mirascope/llm/providers/openai/model_info.py +57 -0
- mirascope/llm/providers/openai/provider.py +30 -5
- mirascope/llm/providers/openai/responses/_utils/decode.py +55 -4
- mirascope/llm/providers/openai/responses/_utils/encode.py +9 -9
- mirascope/llm/providers/openai/responses/provider.py +33 -28
- mirascope/llm/providers/provider_id.py +11 -1
- mirascope/llm/providers/provider_registry.py +59 -4
- mirascope/llm/providers/together/__init__.py +19 -0
- mirascope/llm/providers/together/provider.py +40 -0
- mirascope/llm/responses/__init__.py +3 -0
- mirascope/llm/responses/base_response.py +4 -0
- mirascope/llm/responses/base_stream_response.py +25 -1
- mirascope/llm/responses/finish_reason.py +1 -0
- mirascope/llm/responses/response.py +9 -0
- mirascope/llm/responses/root_response.py +5 -1
- mirascope/llm/responses/usage.py +95 -0
- mirascope/ops/_internal/closure.py +62 -11
- {mirascope-2.0.0a3.dist-info → mirascope-2.0.0a5.dist-info}/METADATA +3 -3
- {mirascope-2.0.0a3.dist-info → mirascope-2.0.0a5.dist-info}/RECORD +115 -56
- mirascope/llm/providers/load_provider.py +0 -48
- mirascope/llm/providers/openai/shared/__init__.py +0 -7
- mirascope/llm/providers/openai/shared/_utils.py +0 -59
- {mirascope-2.0.0a3.dist-info → mirascope-2.0.0a5.dist-info}/WHEEL +0 -0
- {mirascope-2.0.0a3.dist-info → mirascope-2.0.0a5.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,20 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
# isort: skip_file
|
|
4
4
|
|
|
5
|
+
from .already_exists_error import AlreadyExistsError
|
|
6
|
+
from .already_exists_error_tag import AlreadyExistsErrorTag
|
|
7
|
+
from .database_error import DatabaseError
|
|
8
|
+
from .database_error_tag import DatabaseErrorTag
|
|
5
9
|
from .http_api_decode_error import HttpApiDecodeError
|
|
6
10
|
from .http_api_decode_error_tag import HttpApiDecodeErrorTag
|
|
7
11
|
from .issue import Issue
|
|
8
12
|
from .issue_tag import IssueTag
|
|
13
|
+
from .not_found_error_body import NotFoundErrorBody
|
|
14
|
+
from .not_found_error_tag import NotFoundErrorTag
|
|
15
|
+
from .permission_denied_error import PermissionDeniedError
|
|
16
|
+
from .permission_denied_error_tag import PermissionDeniedErrorTag
|
|
9
17
|
from .property_key import PropertyKey
|
|
10
|
-
from .
|
|
11
|
-
from .
|
|
18
|
+
from .property_key_key import PropertyKeyKey
|
|
19
|
+
from .property_key_key_tag import PropertyKeyKeyTag
|
|
12
20
|
|
|
13
21
|
__all__ = [
|
|
22
|
+
"AlreadyExistsError",
|
|
23
|
+
"AlreadyExistsErrorTag",
|
|
24
|
+
"DatabaseError",
|
|
25
|
+
"DatabaseErrorTag",
|
|
14
26
|
"HttpApiDecodeError",
|
|
15
27
|
"HttpApiDecodeErrorTag",
|
|
16
28
|
"Issue",
|
|
17
29
|
"IssueTag",
|
|
30
|
+
"NotFoundErrorBody",
|
|
31
|
+
"NotFoundErrorTag",
|
|
32
|
+
"PermissionDeniedError",
|
|
33
|
+
"PermissionDeniedErrorTag",
|
|
18
34
|
"PropertyKey",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
35
|
+
"PropertyKeyKey",
|
|
36
|
+
"PropertyKeyKeyTag",
|
|
21
37
|
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .already_exists_error_tag import AlreadyExistsErrorTag
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AlreadyExistsError(UniversalBaseModel):
|
|
11
|
+
message: str
|
|
12
|
+
resource: typing.Optional[str] = None
|
|
13
|
+
tag: AlreadyExistsErrorTag
|
|
14
|
+
|
|
15
|
+
if IS_PYDANTIC_V2:
|
|
16
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
17
|
+
extra="allow", frozen=True
|
|
18
|
+
) # type: ignore # Pydantic v2
|
|
19
|
+
else:
|
|
20
|
+
|
|
21
|
+
class Config:
|
|
22
|
+
frozen = True
|
|
23
|
+
smart_union = True
|
|
24
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .database_error_tag import DatabaseErrorTag
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DatabaseError(UniversalBaseModel):
|
|
11
|
+
message: str
|
|
12
|
+
cause: typing.Optional[typing.Optional[typing.Any]] = None
|
|
13
|
+
tag: DatabaseErrorTag
|
|
14
|
+
|
|
15
|
+
if IS_PYDANTIC_V2:
|
|
16
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
17
|
+
extra="allow", frozen=True
|
|
18
|
+
) # type: ignore # Pydantic v2
|
|
19
|
+
else:
|
|
20
|
+
|
|
21
|
+
class Config:
|
|
22
|
+
frozen = True
|
|
23
|
+
smart_union = True
|
|
24
|
+
extra = pydantic.Extra.allow
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
import pydantic
|
|
6
|
-
import typing_extensions
|
|
7
6
|
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
8
|
-
from ..core.serialization import FieldMetadata
|
|
9
7
|
from .http_api_decode_error_tag import HttpApiDecodeErrorTag
|
|
10
8
|
from .issue import Issue
|
|
11
9
|
|
|
@@ -17,7 +15,7 @@ class HttpApiDecodeError(UniversalBaseModel):
|
|
|
17
15
|
|
|
18
16
|
issues: typing.List[Issue]
|
|
19
17
|
message: str
|
|
20
|
-
tag:
|
|
18
|
+
tag: HttpApiDecodeErrorTag
|
|
21
19
|
|
|
22
20
|
if IS_PYDANTIC_V2:
|
|
23
21
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
import pydantic
|
|
6
|
-
import typing_extensions
|
|
7
6
|
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
8
|
-
from ..core.serialization import FieldMetadata
|
|
9
7
|
from .issue_tag import IssueTag
|
|
10
8
|
from .property_key import PropertyKey
|
|
11
9
|
|
|
@@ -15,9 +13,7 @@ class Issue(UniversalBaseModel):
|
|
|
15
13
|
Represents an error encountered while parsing a value to match the schema
|
|
16
14
|
"""
|
|
17
15
|
|
|
18
|
-
tag:
|
|
19
|
-
pydantic.Field()
|
|
20
|
-
)
|
|
16
|
+
tag: IssueTag = pydantic.Field()
|
|
21
17
|
"""
|
|
22
18
|
The tag identifying the type of parse issue
|
|
23
19
|
"""
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .not_found_error_tag import NotFoundErrorTag
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class NotFoundErrorBody(UniversalBaseModel):
|
|
11
|
+
message: str
|
|
12
|
+
resource: typing.Optional[str] = None
|
|
13
|
+
tag: NotFoundErrorTag
|
|
14
|
+
|
|
15
|
+
if IS_PYDANTIC_V2:
|
|
16
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
17
|
+
extra="allow", frozen=True
|
|
18
|
+
) # type: ignore # Pydantic v2
|
|
19
|
+
else:
|
|
20
|
+
|
|
21
|
+
class Config:
|
|
22
|
+
frozen = True
|
|
23
|
+
smart_union = True
|
|
24
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .permission_denied_error_tag import PermissionDeniedErrorTag
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PermissionDeniedError(UniversalBaseModel):
|
|
11
|
+
message: str
|
|
12
|
+
resource: typing.Optional[str] = None
|
|
13
|
+
tag: PermissionDeniedErrorTag
|
|
14
|
+
|
|
15
|
+
if IS_PYDANTIC_V2:
|
|
16
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
17
|
+
extra="allow", frozen=True
|
|
18
|
+
) # type: ignore # Pydantic v2
|
|
19
|
+
else:
|
|
20
|
+
|
|
21
|
+
class Config:
|
|
22
|
+
frozen = True
|
|
23
|
+
smart_union = True
|
|
24
|
+
extra = pydantic.Extra.allow
|
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
import pydantic
|
|
6
|
-
import typing_extensions
|
|
7
6
|
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
8
|
-
from
|
|
9
|
-
from .property_key_tag_tag import PropertyKeyTagTag
|
|
7
|
+
from .property_key_key_tag import PropertyKeyKeyTag
|
|
10
8
|
|
|
11
9
|
|
|
12
|
-
class
|
|
10
|
+
class PropertyKeyKey(UniversalBaseModel):
|
|
13
11
|
"""
|
|
14
12
|
an object to be decoded into a globally shared symbol
|
|
15
13
|
"""
|
|
16
14
|
|
|
17
|
-
tag:
|
|
15
|
+
tag: PropertyKeyKeyTag
|
|
18
16
|
key: str
|
|
19
17
|
|
|
20
18
|
if IS_PYDANTIC_V2:
|
mirascope/llm/__init__.py
CHANGED
|
@@ -92,8 +92,8 @@ from .providers import (
|
|
|
92
92
|
Params,
|
|
93
93
|
Provider,
|
|
94
94
|
ProviderId,
|
|
95
|
-
load_provider,
|
|
96
95
|
register_provider,
|
|
96
|
+
reset_provider_registry,
|
|
97
97
|
)
|
|
98
98
|
from .responses import (
|
|
99
99
|
AsyncChunkIterator,
|
|
@@ -117,6 +117,8 @@ from .responses import (
|
|
|
117
117
|
TextStream,
|
|
118
118
|
ThoughtStream,
|
|
119
119
|
ToolCallStream,
|
|
120
|
+
Usage,
|
|
121
|
+
UsageDeltaChunk,
|
|
120
122
|
)
|
|
121
123
|
from .tools import (
|
|
122
124
|
AsyncContextTool,
|
|
@@ -219,6 +221,8 @@ __all__ = [
|
|
|
219
221
|
"ToolOutput",
|
|
220
222
|
"Toolkit",
|
|
221
223
|
"URLImageSource",
|
|
224
|
+
"Usage",
|
|
225
|
+
"UsageDeltaChunk",
|
|
222
226
|
"UserContent",
|
|
223
227
|
"UserContentPart",
|
|
224
228
|
"UserMessage",
|
|
@@ -228,7 +232,6 @@ __all__ = [
|
|
|
228
232
|
"exceptions",
|
|
229
233
|
"format",
|
|
230
234
|
"formatting",
|
|
231
|
-
"load_provider",
|
|
232
235
|
"mcp",
|
|
233
236
|
"messages",
|
|
234
237
|
"model",
|
|
@@ -238,6 +241,7 @@ __all__ = [
|
|
|
238
241
|
"prompts",
|
|
239
242
|
"providers",
|
|
240
243
|
"register_provider",
|
|
244
|
+
"reset_provider_registry",
|
|
241
245
|
"responses",
|
|
242
246
|
"tool",
|
|
243
247
|
"tools",
|
mirascope/llm/exceptions.py
CHANGED
|
@@ -11,6 +11,7 @@ class MirascopeLLMError(Exception):
|
|
|
11
11
|
"""Base exception for all Mirascope LLM errors."""
|
|
12
12
|
|
|
13
13
|
original_exception: Exception | None
|
|
14
|
+
provider: "ProviderId | None"
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class APIError(MirascopeLLMError):
|
|
@@ -18,6 +19,10 @@ class APIError(MirascopeLLMError):
|
|
|
18
19
|
|
|
19
20
|
status_code: int | None
|
|
20
21
|
|
|
22
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
23
|
+
super().__init__(message)
|
|
24
|
+
self.status_code = status_code
|
|
25
|
+
|
|
21
26
|
|
|
22
27
|
class ConnectionError(MirascopeLLMError):
|
|
23
28
|
"""Raised when unable to connect to the API (network issues, timeouts)."""
|
|
@@ -26,18 +31,30 @@ class ConnectionError(MirascopeLLMError):
|
|
|
26
31
|
class AuthenticationError(APIError):
|
|
27
32
|
"""Raised for authentication failures (401, invalid API keys)."""
|
|
28
33
|
|
|
34
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
35
|
+
super().__init__(message, status_code=status_code or 401)
|
|
36
|
+
|
|
29
37
|
|
|
30
38
|
class PermissionError(APIError):
|
|
31
39
|
"""Raised for permission/authorization failures (403)."""
|
|
32
40
|
|
|
41
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
42
|
+
super().__init__(message, status_code=status_code or 403)
|
|
43
|
+
|
|
33
44
|
|
|
34
45
|
class BadRequestError(APIError):
|
|
35
46
|
"""Raised for malformed requests (400, 422)."""
|
|
36
47
|
|
|
48
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
49
|
+
super().__init__(message, status_code=status_code or 400)
|
|
50
|
+
|
|
37
51
|
|
|
38
52
|
class NotFoundError(APIError):
|
|
39
53
|
"""Raised when requested resource is not found (404)."""
|
|
40
54
|
|
|
55
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
56
|
+
super().__init__(message, status_code=status_code or 404)
|
|
57
|
+
|
|
41
58
|
|
|
42
59
|
class ToolNotFoundError(MirascopeLLMError):
|
|
43
60
|
"""Raised if a tool_call cannot be converted to any corresponding tool."""
|
|
@@ -96,15 +113,26 @@ class FormattingModeNotSupportedError(FeatureNotSupportedError):
|
|
|
96
113
|
class RateLimitError(APIError):
|
|
97
114
|
"""Raised when rate limits are exceeded (429)."""
|
|
98
115
|
|
|
116
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
117
|
+
super().__init__(message, status_code=status_code or 429)
|
|
118
|
+
|
|
99
119
|
|
|
100
120
|
class ServerError(APIError):
|
|
101
121
|
"""Raised for server-side errors (500+)."""
|
|
102
122
|
|
|
123
|
+
def __init__(self, message: str, status_code: int | None = None) -> None:
|
|
124
|
+
super().__init__(message, status_code=status_code or 500)
|
|
125
|
+
|
|
103
126
|
|
|
104
127
|
class TimeoutError(MirascopeLLMError):
|
|
105
128
|
"""Raised when requests timeout or deadline exceeded."""
|
|
106
129
|
|
|
107
130
|
|
|
131
|
+
# This wraps the APIResponseValidationErrors that OpenAI and Anthropic both return.
|
|
132
|
+
class ResponseValidationError(MirascopeLLMError):
|
|
133
|
+
"""Raised when API response fails validation."""
|
|
134
|
+
|
|
135
|
+
|
|
108
136
|
class NoRegisteredProviderError(MirascopeLLMError):
|
|
109
137
|
"""Raised when no provider is registered for a given model_id."""
|
|
110
138
|
|
|
@@ -6,33 +6,41 @@ from .anthropic import (
|
|
|
6
6
|
)
|
|
7
7
|
from .base import BaseProvider, Params, Provider
|
|
8
8
|
from .google import GoogleModelId, GoogleProvider
|
|
9
|
-
from .load_provider import load, load_provider
|
|
10
9
|
from .mlx import MLXModelId, MLXProvider
|
|
11
10
|
from .model_id import ModelId
|
|
11
|
+
from .ollama import OllamaProvider
|
|
12
12
|
from .openai import (
|
|
13
13
|
OpenAIModelId,
|
|
14
14
|
OpenAIProvider,
|
|
15
15
|
)
|
|
16
|
+
from .openai.completions import BaseOpenAICompletionsProvider
|
|
16
17
|
from .provider_id import KNOWN_PROVIDER_IDS, ProviderId
|
|
17
|
-
from .provider_registry import
|
|
18
|
+
from .provider_registry import (
|
|
19
|
+
get_provider_for_model,
|
|
20
|
+
register_provider,
|
|
21
|
+
reset_provider_registry,
|
|
22
|
+
)
|
|
23
|
+
from .together import TogetherProvider
|
|
18
24
|
|
|
19
25
|
__all__ = [
|
|
20
26
|
"KNOWN_PROVIDER_IDS",
|
|
21
27
|
"AnthropicModelId",
|
|
22
28
|
"AnthropicProvider",
|
|
29
|
+
"BaseOpenAICompletionsProvider",
|
|
23
30
|
"BaseProvider",
|
|
24
31
|
"GoogleModelId",
|
|
25
32
|
"GoogleProvider",
|
|
26
33
|
"MLXModelId",
|
|
27
34
|
"MLXProvider",
|
|
28
35
|
"ModelId",
|
|
36
|
+
"OllamaProvider",
|
|
29
37
|
"OpenAIModelId",
|
|
30
38
|
"OpenAIProvider",
|
|
31
39
|
"Params",
|
|
32
40
|
"Provider",
|
|
33
41
|
"ProviderId",
|
|
42
|
+
"TogetherProvider",
|
|
34
43
|
"get_provider_for_model",
|
|
35
|
-
"load",
|
|
36
|
-
"load_provider",
|
|
37
44
|
"register_provider",
|
|
45
|
+
"reset_provider_registry",
|
|
38
46
|
]
|
|
@@ -3,22 +3,27 @@
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
if TYPE_CHECKING:
|
|
6
|
+
from .beta_provider import AnthropicBetaProvider
|
|
6
7
|
from .model_id import AnthropicModelId
|
|
7
8
|
from .provider import AnthropicProvider
|
|
8
9
|
else:
|
|
9
10
|
try:
|
|
11
|
+
from .beta_provider import AnthropicBetaProvider
|
|
10
12
|
from .model_id import AnthropicModelId
|
|
11
13
|
from .provider import AnthropicProvider
|
|
12
14
|
except ImportError: # pragma: no cover
|
|
13
15
|
from .._missing_import_stubs import (
|
|
14
|
-
create_import_error_stub,
|
|
15
16
|
create_provider_stub,
|
|
16
17
|
)
|
|
17
18
|
|
|
19
|
+
AnthropicBetaProvider = create_provider_stub(
|
|
20
|
+
"anthropic", "AnthropicBetaProvider"
|
|
21
|
+
)
|
|
18
22
|
AnthropicProvider = create_provider_stub("anthropic", "AnthropicProvider")
|
|
19
23
|
AnthropicModelId = str
|
|
20
24
|
|
|
21
25
|
__all__ = [
|
|
26
|
+
"AnthropicBetaProvider",
|
|
22
27
|
"AnthropicModelId",
|
|
23
28
|
"AnthropicProvider",
|
|
24
29
|
]
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"""Shared Anthropic utilities."""
|
|
2
|
+
|
|
3
|
+
from .decode import decode_async_stream, decode_response, decode_stream
|
|
4
|
+
from .encode import (
|
|
5
|
+
DEFAULT_FORMAT_MODE,
|
|
6
|
+
DEFAULT_MAX_TOKENS,
|
|
7
|
+
AnthropicImageMimeType,
|
|
8
|
+
encode_image_mime_type,
|
|
9
|
+
encode_request,
|
|
10
|
+
process_params,
|
|
5
11
|
)
|
|
6
|
-
from .
|
|
12
|
+
from .errors import ANTHROPIC_ERROR_MAP
|
|
7
13
|
|
|
8
14
|
__all__ = [
|
|
15
|
+
"ANTHROPIC_ERROR_MAP",
|
|
16
|
+
"DEFAULT_FORMAT_MODE",
|
|
17
|
+
"DEFAULT_MAX_TOKENS",
|
|
18
|
+
"AnthropicImageMimeType",
|
|
9
19
|
"decode_async_stream",
|
|
10
20
|
"decode_response",
|
|
11
21
|
"decode_stream",
|
|
22
|
+
"encode_image_mime_type",
|
|
12
23
|
"encode_request",
|
|
24
|
+
"process_params",
|
|
13
25
|
]
|