unique_toolkit 0.6.1__tar.gz → 0.6.4__tar.gz
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.
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/CHANGELOG.md +13 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/PKG-INFO +14 -1
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/pyproject.toml +1 -1
- unique_toolkit-0.6.4/unique_toolkit/__init__.py +17 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/config.py +1 -1
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/context_relevancy/constants.py +1 -1
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/builder.py +20 -5
- unique_toolkit-0.6.4/unique_toolkit/language_model/infos.py +352 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/schemas.py +54 -24
- unique_toolkit-0.6.1/unique_toolkit/__init__.py +0 -0
- unique_toolkit-0.6.1/unique_toolkit/language_model/infos.py +0 -413
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/LICENSE +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/README.md +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/_common/_base_service.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/_common/_time_utils.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/_common/exception.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/_common/validate_required_values.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/_common/validators.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/__init__.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/init_logging.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/init_sdk.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/performance/async_tasks.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/performance/async_wrapper.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/schemas.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/verification.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/chat/__init__.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/chat/constants.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/chat/functions.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/chat/schemas.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/chat/service.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/chat/state.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/chat/utils.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/content/__init__.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/content/constants.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/content/functions.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/content/schemas.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/content/service.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/content/utils.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/embedding/__init__.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/embedding/constants.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/embedding/functions.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/embedding/schemas.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/embedding/service.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/embedding/utils.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/__init__.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/constants.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/context_relevancy/prompts.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/context_relevancy/service.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/context_relevancy/utils.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/exception.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/constants.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/prompts.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/service.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/utils.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/output_parser.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/schemas.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/__init__.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/constants.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/functions.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/prompt.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/service.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/language_model/utils.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/short_term_memory/__init__.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/short_term_memory/constants.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/short_term_memory/functions.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/short_term_memory/schemas.py +0 -0
- {unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/short_term_memory/service.py +0 -0
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
|
9
|
+
## [0.6.3] - 2025-02-27
|
10
|
+
- Simplified imports for services. `from unique_toolkit.language_model import LanguageModelService` -> `from unique_toolkit import LanguageModelService` to reduce number of import lines.
|
11
|
+
|
12
|
+
## [0.6.3] - 2025-02-26
|
13
|
+
- Add `builder` method to `LanguageModelMessages` class
|
14
|
+
|
15
|
+
## [0.6.2] - 2025-02-25
|
16
|
+
- Deprecate `LanguageModel` in favor of `LanguageModelInfo`
|
17
|
+
- `LanguageModelTokenLimits` properties become mandatory, initialization allows
|
18
|
+
- init with `token_limit` and `fraction_input` or `input_token_limit` and `output_token_limit`
|
19
|
+
- only `input_token_limit` and `output_token_limit` are members of model
|
20
|
+
|
8
21
|
## [0.6.1] - 2025-02-25
|
9
22
|
- [BREAKING] `LanguageModelService.stream_complete` and `LanguageModelService.stream_complete_async` are now moved to `ChatService.stream_complete` and `ChatService.stream_complete_async`. Correspondingly `assistant_message_id` and `user_message_id` are removed from `LanguageModelService`.
|
10
23
|
- Add `create_user_message` and `create_user_message_async` to `ChatService` (similar to `create_assistant_message` and `create_assistant_message_async`)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unique_toolkit
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.4
|
4
4
|
Summary:
|
5
5
|
License: Proprietary
|
6
6
|
Author: Martin Fadler
|
@@ -111,6 +111,19 @@ All notable changes to this project will be documented in this file.
|
|
111
111
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
112
112
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
113
113
|
|
114
|
+
|
115
|
+
## [0.6.3] - 2025-02-27
|
116
|
+
- Simplified imports for services. `from unique_toolkit.language_model import LanguageModelService` -> `from unique_toolkit import LanguageModelService` to reduce number of import lines.
|
117
|
+
|
118
|
+
## [0.6.3] - 2025-02-26
|
119
|
+
- Add `builder` method to `LanguageModelMessages` class
|
120
|
+
|
121
|
+
## [0.6.2] - 2025-02-25
|
122
|
+
- Deprecate `LanguageModel` in favor of `LanguageModelInfo`
|
123
|
+
- `LanguageModelTokenLimits` properties become mandatory, initialization allows
|
124
|
+
- init with `token_limit` and `fraction_input` or `input_token_limit` and `output_token_limit`
|
125
|
+
- only `input_token_limit` and `output_token_limit` are members of model
|
126
|
+
|
114
127
|
## [0.6.1] - 2025-02-25
|
115
128
|
- [BREAKING] `LanguageModelService.stream_complete` and `LanguageModelService.stream_complete_async` are now moved to `ChatService.stream_complete` and `ChatService.stream_complete_async`. Correspondingly `assistant_message_id` and `user_message_id` are removed from `LanguageModelService`.
|
116
129
|
- Add `create_user_message` and `create_user_message_async` to `ChatService` (similar to `create_assistant_message` and `create_assistant_message_async`)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Re-export commonly used classes for easier imports
|
2
|
+
from unique_toolkit.chat import ChatService
|
3
|
+
from unique_toolkit.content import ContentService
|
4
|
+
from unique_toolkit.embedding import EmbeddingService
|
5
|
+
from unique_toolkit.language_model import LanguageModelMessages, LanguageModelService
|
6
|
+
from unique_toolkit.short_term_memory import ShortTermMemoryService
|
7
|
+
|
8
|
+
# You can add other classes you frequently use here as well
|
9
|
+
|
10
|
+
__all__ = [
|
11
|
+
"LanguageModelService",
|
12
|
+
"LanguageModelMessages",
|
13
|
+
"ChatService",
|
14
|
+
"ContentService",
|
15
|
+
"EmbeddingService",
|
16
|
+
"ShortTermMemoryService",
|
17
|
+
]
|
@@ -25,7 +25,7 @@ class EvaluationMetricConfig(BaseModel):
|
|
25
25
|
enabled: bool = False
|
26
26
|
name: EvaluationMetricName
|
27
27
|
language_model: LanguageModel = LanguageModel(
|
28
|
-
LanguageModelName.
|
28
|
+
LanguageModelName.AZURE_GPT_35_TURBO_0125
|
29
29
|
)
|
30
30
|
custom_prompts: dict[str, str] = {}
|
31
31
|
score_to_emoji: dict[str, str] = {}
|
@@ -23,7 +23,7 @@ context_relevancy_required_input_fields = [
|
|
23
23
|
default_config = EvaluationMetricConfig(
|
24
24
|
enabled=False,
|
25
25
|
name=EvaluationMetricName.CONTEXT_RELEVANCY,
|
26
|
-
language_model=LanguageModel(LanguageModelName.
|
26
|
+
language_model=LanguageModel(LanguageModelName.AZURE_GPT_35_TURBO_0125),
|
27
27
|
score_to_emoji={"LOW": "🟢", "MEDIUM": "🟡", "HIGH": "🔴"},
|
28
28
|
custom_prompts={
|
29
29
|
SYSTEM_MSG_KEY: CONTEXT_RELEVANCY_METRIC_SYSTEM_MSG,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing_extensions import Self
|
2
|
+
|
1
3
|
from unique_toolkit.language_model import (
|
2
4
|
LanguageModelAssistantMessage,
|
3
5
|
LanguageModelMessage,
|
@@ -12,25 +14,38 @@ class MessagesBuilder:
|
|
12
14
|
def __init__(self):
|
13
15
|
self.messages: list[LanguageModelMessage] = []
|
14
16
|
|
15
|
-
def system_message_append(self, content):
|
16
|
-
"""Appends a
|
17
|
+
def system_message_append(self, content: str) -> Self:
|
18
|
+
"""Appends a system message to the messages list."""
|
17
19
|
message = LanguageModelSystemMessage(content=content)
|
18
20
|
self.messages.append(message)
|
19
21
|
return self # Return self to allow method chaining
|
20
22
|
|
21
|
-
def user_message_append(self, content):
|
23
|
+
def user_message_append(self, content: str) -> Self:
|
22
24
|
"""Appends a user message to the messages list."""
|
23
25
|
message = LanguageModelUserMessage(content=content)
|
24
26
|
self.messages.append(message)
|
25
27
|
return self # Return self to allow method chaining
|
26
28
|
|
27
|
-
def
|
29
|
+
def image_message_append(self, content: str, images: list[str]) -> Self:
|
30
|
+
message = LanguageModelUserMessage(
|
31
|
+
content=[
|
32
|
+
{"type": "text", "text": content},
|
33
|
+
*[
|
34
|
+
{"type": "image_url", "imageUrl": {"url": image}}
|
35
|
+
for image in images
|
36
|
+
],
|
37
|
+
]
|
38
|
+
)
|
39
|
+
self.messages.append(message)
|
40
|
+
return self
|
41
|
+
|
42
|
+
def assistant_message_append(self, content: str) -> Self:
|
28
43
|
"""Appends an assistant message to the messages list."""
|
29
44
|
message = LanguageModelAssistantMessage(content=content)
|
30
45
|
self.messages.append(message)
|
31
46
|
return self # Return self to allow method chaining
|
32
47
|
|
33
|
-
def tool_message_append(self, name: str, tool_call_id: str, content: str):
|
48
|
+
def tool_message_append(self, name: str, tool_call_id: str, content: str) -> Self:
|
34
49
|
"""Appends a tool message to the messages list."""
|
35
50
|
message = LanguageModelToolMessage(
|
36
51
|
name=name, tool_call_id=tool_call_id, content=content
|
@@ -0,0 +1,352 @@
|
|
1
|
+
from datetime import date
|
2
|
+
from enum import StrEnum
|
3
|
+
from typing import ClassVar, Optional
|
4
|
+
|
5
|
+
from pydantic import BaseModel
|
6
|
+
from typing_extensions import deprecated
|
7
|
+
|
8
|
+
from unique_toolkit.language_model.schemas import LanguageModelTokenLimits
|
9
|
+
|
10
|
+
|
11
|
+
class LanguageModelName(StrEnum):
|
12
|
+
AZURE_GPT_35_TURBO_0125 = "AZURE_GPT_35_TURBO_0125"
|
13
|
+
AZURE_GPT_4_0613 = "AZURE_GPT_4_0613"
|
14
|
+
AZURE_GPT_4_TURBO_1106 = "AZURE_GPT_4_TURBO_1106"
|
15
|
+
AZURE_GPT_4_VISION_PREVIEW = "AZURE_GPT_4_VISION_PREVIEW"
|
16
|
+
AZURE_GPT_4_32K_0613 = "AZURE_GPT_4_32K_0613"
|
17
|
+
AZURE_GPT_4_TURBO_2024_0409 = "AZURE_GPT_4_TURBO_2024_0409"
|
18
|
+
AZURE_GPT_4o_2024_0513 = "AZURE_GPT_4o_2024_0513"
|
19
|
+
AZURE_GPT_4o_2024_0806 = "AZURE_GPT_4o_2024_0806"
|
20
|
+
AZURE_GPT_4o_MINI_2024_0718 = "AZURE_GPT_4o_MINI_2024_0718"
|
21
|
+
|
22
|
+
|
23
|
+
class EncoderName(StrEnum):
|
24
|
+
O200K_BASE = "o200k_base"
|
25
|
+
CL100K_BASE = "cl100k_base"
|
26
|
+
|
27
|
+
|
28
|
+
def get_encoder_name(model_name: LanguageModelName) -> Optional[EncoderName]:
|
29
|
+
LMN = LanguageModelName
|
30
|
+
match model_name:
|
31
|
+
case LMN.AZURE_GPT_35_TURBO_0125:
|
32
|
+
return EncoderName.CL100K_BASE
|
33
|
+
case (
|
34
|
+
LMN.AZURE_GPT_4_0613
|
35
|
+
| LMN.AZURE_GPT_4_TURBO_1106
|
36
|
+
| LMN.AZURE_GPT_4_VISION_PREVIEW
|
37
|
+
| LMN.AZURE_GPT_4_32K_0613
|
38
|
+
| LMN.AZURE_GPT_4_TURBO_2024_0409
|
39
|
+
):
|
40
|
+
return EncoderName.CL100K_BASE
|
41
|
+
case (
|
42
|
+
LMN.AZURE_GPT_4o_2024_0513
|
43
|
+
| LMN.AZURE_GPT_4o_2024_0806
|
44
|
+
| LMN.AZURE_GPT_4o_MINI_2024_0718
|
45
|
+
):
|
46
|
+
return EncoderName.O200K_BASE
|
47
|
+
case _:
|
48
|
+
print(f"{model_name} is not supported. Please add encoder information.")
|
49
|
+
return None
|
50
|
+
|
51
|
+
|
52
|
+
class LanguageModelProvider(StrEnum):
|
53
|
+
AZURE = "AZURE"
|
54
|
+
CUSTOM = "CUSTOM"
|
55
|
+
|
56
|
+
|
57
|
+
class LanguageModelInfo(BaseModel):
|
58
|
+
name: LanguageModelName | str
|
59
|
+
version: str
|
60
|
+
provider: LanguageModelProvider
|
61
|
+
|
62
|
+
encoder_name: Optional[EncoderName] = None
|
63
|
+
token_limits: Optional[LanguageModelTokenLimits] = None
|
64
|
+
|
65
|
+
info_cutoff_at: Optional[date] = None
|
66
|
+
published_at: Optional[date] = None
|
67
|
+
retirement_at: Optional[date] = None
|
68
|
+
|
69
|
+
deprecated_at: Optional[date] = None
|
70
|
+
retirement_text: Optional[str] = None
|
71
|
+
|
72
|
+
@classmethod
|
73
|
+
def from_name(cls, model_name: LanguageModelName):
|
74
|
+
match model_name:
|
75
|
+
case LanguageModelName.AZURE_GPT_35_TURBO_0125:
|
76
|
+
return cls(
|
77
|
+
name=model_name,
|
78
|
+
provider=LanguageModelProvider.AZURE,
|
79
|
+
version="0125",
|
80
|
+
encoder_name=get_encoder_name(model_name),
|
81
|
+
token_limits=LanguageModelTokenLimits(
|
82
|
+
token_limit_input=16385, token_limit_output=4096
|
83
|
+
),
|
84
|
+
info_cutoff_at=date(2021, 9, 1),
|
85
|
+
published_at=date(2023, 1, 25),
|
86
|
+
retirement_at=date(5, 3, 31),
|
87
|
+
)
|
88
|
+
case LanguageModelName.AZURE_GPT_4_0613:
|
89
|
+
return cls(
|
90
|
+
name=model_name,
|
91
|
+
provider=LanguageModelProvider.AZURE,
|
92
|
+
version="0613",
|
93
|
+
encoder_name=get_encoder_name(model_name),
|
94
|
+
token_limits=LanguageModelTokenLimits(token_limit=8192),
|
95
|
+
info_cutoff_at=date(2021, 9, 1),
|
96
|
+
published_at=date(2023, 6, 13),
|
97
|
+
deprecated_at=date(2024, 10, 1),
|
98
|
+
retirement_at=date(2025, 6, 6),
|
99
|
+
)
|
100
|
+
case LanguageModelName.AZURE_GPT_4_TURBO_1106:
|
101
|
+
return cls(
|
102
|
+
name=model_name,
|
103
|
+
provider=LanguageModelProvider.AZURE,
|
104
|
+
version="1106-preview",
|
105
|
+
encoder_name=get_encoder_name(model_name),
|
106
|
+
token_limits=LanguageModelTokenLimits(
|
107
|
+
token_limit_input=128000, token_limit_output=4096
|
108
|
+
),
|
109
|
+
info_cutoff_at=date(2023, 4, 1),
|
110
|
+
published_at=date(2023, 11, 6),
|
111
|
+
)
|
112
|
+
case LanguageModelName.AZURE_GPT_4_VISION_PREVIEW:
|
113
|
+
return cls(
|
114
|
+
name=model_name,
|
115
|
+
provider=LanguageModelProvider.AZURE,
|
116
|
+
version="vision-preview",
|
117
|
+
encoder_name=get_encoder_name(model_name),
|
118
|
+
token_limits=LanguageModelTokenLimits(
|
119
|
+
token_limit_input=128000, token_limit_output=4096
|
120
|
+
),
|
121
|
+
info_cutoff_at=date(2023, 4, 1),
|
122
|
+
published_at=date(2023, 11, 6),
|
123
|
+
)
|
124
|
+
case LanguageModelName.AZURE_GPT_4_32K_0613:
|
125
|
+
return cls(
|
126
|
+
name=model_name,
|
127
|
+
provider=LanguageModelProvider.AZURE,
|
128
|
+
version="1106-preview",
|
129
|
+
encoder_name=get_encoder_name(model_name),
|
130
|
+
token_limits=LanguageModelTokenLimits(token_limit=32768),
|
131
|
+
info_cutoff_at=date(2021, 9, 1),
|
132
|
+
published_at=date(2023, 6, 13),
|
133
|
+
deprecated_at=date(2024, 10, 1),
|
134
|
+
retirement_at=date(2025, 6, 6),
|
135
|
+
)
|
136
|
+
case LanguageModelName.AZURE_GPT_4_TURBO_2024_0409:
|
137
|
+
return cls(
|
138
|
+
name=model_name,
|
139
|
+
encoder_name=get_encoder_name(model_name),
|
140
|
+
provider=LanguageModelProvider.AZURE,
|
141
|
+
version="turbo-2024-04-09",
|
142
|
+
token_limits=LanguageModelTokenLimits(
|
143
|
+
token_limit_input=128000, token_limit_output=4096
|
144
|
+
),
|
145
|
+
info_cutoff_at=date(2023, 12, 1),
|
146
|
+
published_at=date(2024, 4, 9),
|
147
|
+
)
|
148
|
+
case LanguageModelName.AZURE_GPT_4o_2024_0513:
|
149
|
+
return cls(
|
150
|
+
name=model_name,
|
151
|
+
encoder_name=get_encoder_name(model_name),
|
152
|
+
provider=LanguageModelProvider.AZURE,
|
153
|
+
version="2024-05-13",
|
154
|
+
token_limits=LanguageModelTokenLimits(
|
155
|
+
token_limit_input=128000, token_limit_output=4096
|
156
|
+
),
|
157
|
+
info_cutoff_at=date(2023, 10, 1),
|
158
|
+
published_at=date(2024, 5, 13),
|
159
|
+
)
|
160
|
+
case LanguageModelName.AZURE_GPT_4o_2024_0806:
|
161
|
+
return cls(
|
162
|
+
name=model_name,
|
163
|
+
encoder_name=get_encoder_name(model_name),
|
164
|
+
provider=LanguageModelProvider.AZURE,
|
165
|
+
version="2024-08-06",
|
166
|
+
token_limits=LanguageModelTokenLimits(
|
167
|
+
token_limit_input=128000, token_limit_output=16384
|
168
|
+
),
|
169
|
+
info_cutoff_at=date(2023, 10, 1),
|
170
|
+
published_at=date(2024, 8, 6),
|
171
|
+
)
|
172
|
+
case LanguageModelName.AZURE_GPT_4o_MINI_2024_0718:
|
173
|
+
return cls(
|
174
|
+
name=model_name,
|
175
|
+
provider=LanguageModelProvider.AZURE,
|
176
|
+
version="2024-07-18",
|
177
|
+
encoder_name=get_encoder_name(model_name),
|
178
|
+
token_limits=LanguageModelTokenLimits(
|
179
|
+
token_limit_input=128000, token_limit_output=16384
|
180
|
+
),
|
181
|
+
info_cutoff_at=date(2023, 10, 1),
|
182
|
+
published_at=date(2024, 7, 18),
|
183
|
+
)
|
184
|
+
case _:
|
185
|
+
if isinstance(model_name, LanguageModelName):
|
186
|
+
raise ValueError(
|
187
|
+
f"{model_name} is not supported. Please add model information in toolkit."
|
188
|
+
)
|
189
|
+
|
190
|
+
return cls(
|
191
|
+
name=model_name,
|
192
|
+
version="custom",
|
193
|
+
provider=LanguageModelProvider.CUSTOM,
|
194
|
+
)
|
195
|
+
|
196
|
+
@property
|
197
|
+
def display_name(self) -> str:
|
198
|
+
"""
|
199
|
+
Returns the name of the model as a string.
|
200
|
+
"""
|
201
|
+
|
202
|
+
if isinstance(self.name, LanguageModelName):
|
203
|
+
return self.name.value
|
204
|
+
else:
|
205
|
+
return self.name
|
206
|
+
|
207
|
+
|
208
|
+
@deprecated(
|
209
|
+
"""
|
210
|
+
Use `LanguageModelInfo` instead of `LanguageModel`
|
211
|
+
"""
|
212
|
+
)
|
213
|
+
class LanguageModel:
|
214
|
+
_info: ClassVar[LanguageModelInfo]
|
215
|
+
|
216
|
+
def __init__(self, model_name: LanguageModelName | str):
|
217
|
+
self._model_info = self.get_model_info(model_name)
|
218
|
+
|
219
|
+
@property
|
220
|
+
def info(self) -> LanguageModelInfo:
|
221
|
+
"""
|
222
|
+
Returns all infos about the model:
|
223
|
+
- name
|
224
|
+
- version
|
225
|
+
- provider
|
226
|
+
- encoder_name
|
227
|
+
- token_limits
|
228
|
+
- info_cutoff_at
|
229
|
+
- published_at
|
230
|
+
- retirement_at
|
231
|
+
- deprecated_at
|
232
|
+
- retirement_text
|
233
|
+
"""
|
234
|
+
return self._model_info
|
235
|
+
|
236
|
+
@property
|
237
|
+
def name(self) -> LanguageModelName | str:
|
238
|
+
"""
|
239
|
+
Returns the LanguageModelName of the model or the name string when it is a custom / not defined model.
|
240
|
+
"""
|
241
|
+
return self._model_info.name
|
242
|
+
|
243
|
+
@property
|
244
|
+
def display_name(self) -> str:
|
245
|
+
"""
|
246
|
+
Returns the name of the model as a string.
|
247
|
+
"""
|
248
|
+
if isinstance(self._model_info.name, LanguageModelName):
|
249
|
+
return self._model_info.name.name
|
250
|
+
else:
|
251
|
+
return self._model_info.name
|
252
|
+
|
253
|
+
@property
|
254
|
+
def version(self) -> Optional[str]:
|
255
|
+
"""
|
256
|
+
Returns the version of the model.
|
257
|
+
"""
|
258
|
+
return self._model_info.version
|
259
|
+
|
260
|
+
@property
|
261
|
+
def encoder_name(self) -> Optional[EncoderName]:
|
262
|
+
"""
|
263
|
+
Returns the encoder_name used for the model.
|
264
|
+
"""
|
265
|
+
return self._model_info.encoder_name
|
266
|
+
|
267
|
+
@property
|
268
|
+
def token_limit(self) -> Optional[int]:
|
269
|
+
"""
|
270
|
+
Returns the maximum number of tokens for the model.
|
271
|
+
"""
|
272
|
+
if self._model_info.token_limits:
|
273
|
+
return self._model_info.token_limits.token_limit
|
274
|
+
|
275
|
+
@property
|
276
|
+
def token_limit_input(self) -> Optional[int]:
|
277
|
+
"""
|
278
|
+
Returns the maximum number of input tokens for the model.
|
279
|
+
"""
|
280
|
+
if self._model_info.token_limits:
|
281
|
+
return self._model_info.token_limits.token_limit_input
|
282
|
+
|
283
|
+
@property
|
284
|
+
def token_limit_output(self) -> Optional[int]:
|
285
|
+
"""
|
286
|
+
Returns the maximum number of output tokens for the model.
|
287
|
+
"""
|
288
|
+
if self._model_info.token_limits:
|
289
|
+
return self._model_info.token_limits.token_limit_output
|
290
|
+
|
291
|
+
@property
|
292
|
+
def info_cutoff_at(self) -> Optional[date]:
|
293
|
+
"""
|
294
|
+
Returns the date the model was last updated.
|
295
|
+
"""
|
296
|
+
return self._model_info.info_cutoff_at
|
297
|
+
|
298
|
+
@property
|
299
|
+
def published_at(self) -> Optional[date]:
|
300
|
+
"""
|
301
|
+
Returns the date the model was published.
|
302
|
+
"""
|
303
|
+
return self._model_info.published_at
|
304
|
+
|
305
|
+
@property
|
306
|
+
def retirement_at(self) -> Optional[date]:
|
307
|
+
"""
|
308
|
+
Returns the date the model will be retired.
|
309
|
+
"""
|
310
|
+
return self._model_info.retirement_at
|
311
|
+
|
312
|
+
@property
|
313
|
+
def deprecated_at(self) -> Optional[date]:
|
314
|
+
"""
|
315
|
+
Returns the date the model was deprecated.
|
316
|
+
"""
|
317
|
+
return self._model_info.deprecated_at
|
318
|
+
|
319
|
+
@property
|
320
|
+
def retirement_text(self) -> Optional[str]:
|
321
|
+
"""
|
322
|
+
Returns the text that will be displayed when the model is retired.
|
323
|
+
"""
|
324
|
+
return self._model_info.retirement_text
|
325
|
+
|
326
|
+
@property
|
327
|
+
def provider(self) -> LanguageModelProvider:
|
328
|
+
"""
|
329
|
+
Returns the provider of the model.
|
330
|
+
"""
|
331
|
+
return self._model_info.provider
|
332
|
+
|
333
|
+
@classmethod
|
334
|
+
def get_model_info(cls, model_name: LanguageModelName | str) -> LanguageModelInfo:
|
335
|
+
if isinstance(model_name, LanguageModelName):
|
336
|
+
return LanguageModelInfo.from_name(model_name)
|
337
|
+
|
338
|
+
return LanguageModelInfo(
|
339
|
+
name=model_name,
|
340
|
+
version="custom",
|
341
|
+
provider=LanguageModelProvider.CUSTOM,
|
342
|
+
)
|
343
|
+
|
344
|
+
@classmethod
|
345
|
+
def list_models(cls) -> list[LanguageModelInfo]:
|
346
|
+
"""
|
347
|
+
Returns a list of the infos of all available models.
|
348
|
+
"""
|
349
|
+
|
350
|
+
return [
|
351
|
+
LanguageModelInfo.from_name(model_name=name) for name in LanguageModelName
|
352
|
+
]
|
@@ -9,11 +9,13 @@ from pydantic import (
|
|
9
9
|
BaseModel,
|
10
10
|
ConfigDict,
|
11
11
|
Field,
|
12
|
+
PrivateAttr,
|
12
13
|
RootModel,
|
13
14
|
field_validator,
|
14
15
|
model_serializer,
|
15
16
|
model_validator,
|
16
17
|
)
|
18
|
+
from typing_extensions import deprecated
|
17
19
|
|
18
20
|
from unique_toolkit.language_model.utils import format_message
|
19
21
|
|
@@ -163,6 +165,14 @@ class LanguageModelMessages(RootModel):
|
|
163
165
|
def __getitem__(self, item):
|
164
166
|
return self.root[item]
|
165
167
|
|
168
|
+
def builder(self):
|
169
|
+
"""Returns a MessagesBuilder instance pre-populated with existing messages."""
|
170
|
+
from unique_toolkit.language_model.builder import MessagesBuilder
|
171
|
+
|
172
|
+
builder = MessagesBuilder()
|
173
|
+
builder.messages = self.root.copy() # Start with existing messages
|
174
|
+
return builder
|
175
|
+
|
166
176
|
|
167
177
|
class LanguageModelCompletionChoice(BaseModel):
|
168
178
|
model_config = model_config
|
@@ -205,30 +215,50 @@ class LanguageModelStreamResponse(BaseModel):
|
|
205
215
|
|
206
216
|
|
207
217
|
class LanguageModelTokenLimits(BaseModel):
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
@
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
self.
|
228
|
-
self.
|
229
|
-
|
230
|
-
|
231
|
-
|
218
|
+
token_limit_input: int
|
219
|
+
token_limit_output: int
|
220
|
+
|
221
|
+
_fraction_adaptable = PrivateAttr(default=False)
|
222
|
+
|
223
|
+
@property
|
224
|
+
@deprecated("""
|
225
|
+
Deprecated: Use the more specific `token_limit_input` and `token_limit_output` instead.
|
226
|
+
""")
|
227
|
+
def token_limit(self):
|
228
|
+
return self.token_limit_input + self.token_limit_output
|
229
|
+
|
230
|
+
@token_limit.setter
|
231
|
+
@deprecated("""
|
232
|
+
Deprecated: Token limit can only be reduced
|
233
|
+
""")
|
234
|
+
def token_limit(self, token_limit, fraction_input=0.4):
|
235
|
+
if self.token_limit > token_limit:
|
236
|
+
self.token_limit_input = math.floor(fraction_input * token_limit)
|
237
|
+
self.token_limit_output = math.floor((1 - fraction_input) * token_limit)
|
238
|
+
self._fraction_adaptable = True
|
239
|
+
|
240
|
+
def adapt_fraction(self, fraction_input: float):
|
241
|
+
if self._fraction_adaptable:
|
242
|
+
token_limit = self.token_limit_input + self.token_limit_output
|
243
|
+
self.token_limit_input = math.floor(fraction_input * token_limit)
|
244
|
+
self.token_limit_output = math.floor((1 - fraction_input) * token_limit)
|
245
|
+
|
246
|
+
@model_validator(mode="before")
|
247
|
+
def check_required_fields(cls, data):
|
248
|
+
if isinstance(data, dict):
|
249
|
+
if {"token_limit_input", "token_limit_output"}.issubset(data.keys()):
|
250
|
+
return data
|
251
|
+
|
252
|
+
if {"token_limit"}.issubset(data.keys()):
|
253
|
+
token_limit = data.get("token_limit")
|
254
|
+
fraction_input = data.get("fraction_input", 0.4)
|
255
|
+
|
256
|
+
data["token_limit_input"] = math.floor(fraction_input * token_limit)
|
257
|
+
data["token_limit_output"] = math.floor(
|
258
|
+
(1 - fraction_input) * token_limit
|
259
|
+
)
|
260
|
+
data["_fraction_adaptpable"] = True
|
261
|
+
return data
|
232
262
|
|
233
263
|
raise ValueError(
|
234
264
|
'Either "token_limit_input" and "token_limit_output" must be provided together, or "token_limit" must be provided.'
|
File without changes
|
@@ -1,413 +0,0 @@
|
|
1
|
-
from datetime import date
|
2
|
-
from enum import StrEnum
|
3
|
-
from typing import ClassVar, Optional, Type, cast
|
4
|
-
|
5
|
-
from pydantic import BaseModel
|
6
|
-
|
7
|
-
from unique_toolkit.language_model.schemas import LanguageModelTokenLimits
|
8
|
-
|
9
|
-
|
10
|
-
class LanguageModelName(StrEnum):
|
11
|
-
AZURE_GPT_35_TURBO_0613 = "AZURE_GPT_35_TURBO_0613"
|
12
|
-
AZURE_GPT_35_TURBO = "AZURE_GPT_35_TURBO"
|
13
|
-
AZURE_GPT_35_TURBO_16K = "AZURE_GPT_35_TURBO_16K"
|
14
|
-
AZURE_GPT_35_TURBO_0125 = "AZURE_GPT_35_TURBO_0125"
|
15
|
-
AZURE_GPT_4_0613 = "AZURE_GPT_4_0613"
|
16
|
-
AZURE_GPT_4_TURBO_1106 = "AZURE_GPT_4_TURBO_1106"
|
17
|
-
AZURE_GPT_4_VISION_PREVIEW = "AZURE_GPT_4_VISION_PREVIEW"
|
18
|
-
AZURE_GPT_4_32K_0613 = "AZURE_GPT_4_32K_0613"
|
19
|
-
AZURE_GPT_4_TURBO_2024_0409 = "AZURE_GPT_4_TURBO_2024_0409"
|
20
|
-
AZURE_GPT_4o_2024_0513 = "AZURE_GPT_4o_2024_0513"
|
21
|
-
AZURE_GPT_4o_2024_0806 = "AZURE_GPT_4o_2024_0806"
|
22
|
-
AZURE_GPT_4o_MINI_2024_0718 = "AZURE_GPT_4o_MINI_2024_0718"
|
23
|
-
|
24
|
-
|
25
|
-
class EncoderName(StrEnum):
|
26
|
-
O200K_BASE = "o200k_base"
|
27
|
-
CL100K_BASE = "cl100k_base"
|
28
|
-
|
29
|
-
|
30
|
-
def get_encoder_name(model_name: LanguageModelName) -> Optional[EncoderName]:
|
31
|
-
LMN = LanguageModelName
|
32
|
-
match model_name:
|
33
|
-
case (
|
34
|
-
LMN.AZURE_GPT_35_TURBO
|
35
|
-
| LMN.AZURE_GPT_35_TURBO_16K
|
36
|
-
| LMN.AZURE_GPT_35_TURBO_0613
|
37
|
-
| LMN.AZURE_GPT_35_TURBO_0125
|
38
|
-
):
|
39
|
-
return EncoderName.CL100K_BASE
|
40
|
-
case (
|
41
|
-
LMN.AZURE_GPT_4_0613
|
42
|
-
| LMN.AZURE_GPT_4_TURBO_1106
|
43
|
-
| LMN.AZURE_GPT_4_VISION_PREVIEW
|
44
|
-
| LMN.AZURE_GPT_4_32K_0613
|
45
|
-
| LMN.AZURE_GPT_4_TURBO_2024_0409
|
46
|
-
):
|
47
|
-
return EncoderName.CL100K_BASE
|
48
|
-
case (
|
49
|
-
LMN.AZURE_GPT_4o_2024_0513
|
50
|
-
| LMN.AZURE_GPT_4o_2024_0806
|
51
|
-
| LMN.AZURE_GPT_4o_MINI_2024_0718
|
52
|
-
):
|
53
|
-
return EncoderName.O200K_BASE
|
54
|
-
case _:
|
55
|
-
print(f"{model_name} is not supported. Please add encoder information.")
|
56
|
-
return None
|
57
|
-
|
58
|
-
|
59
|
-
class LanguageModelProvider(StrEnum):
|
60
|
-
AZURE = "AZURE"
|
61
|
-
CUSTOM = "CUSTOM"
|
62
|
-
|
63
|
-
|
64
|
-
class LanguageModelInfo(BaseModel):
|
65
|
-
name: LanguageModelName | str
|
66
|
-
version: str
|
67
|
-
provider: LanguageModelProvider
|
68
|
-
|
69
|
-
encoder_name: Optional[EncoderName] = None
|
70
|
-
token_limits: Optional[LanguageModelTokenLimits] = None
|
71
|
-
|
72
|
-
info_cutoff_at: Optional[date] = None
|
73
|
-
published_at: Optional[date] = None
|
74
|
-
retirement_at: Optional[date] = None
|
75
|
-
|
76
|
-
deprecated_at: Optional[date] = None
|
77
|
-
retirement_text: Optional[str] = None
|
78
|
-
|
79
|
-
|
80
|
-
class LanguageModel:
|
81
|
-
_info: ClassVar[LanguageModelInfo]
|
82
|
-
|
83
|
-
def __init__(self, model_name: LanguageModelName | str):
|
84
|
-
self._model_info = self.get_model_info(model_name)
|
85
|
-
|
86
|
-
@property
|
87
|
-
def info(self) -> LanguageModelInfo:
|
88
|
-
"""
|
89
|
-
Returns all infos about the model:
|
90
|
-
- name
|
91
|
-
- version
|
92
|
-
- provider
|
93
|
-
- encoder_name
|
94
|
-
- token_limits
|
95
|
-
- info_cutoff_at
|
96
|
-
- published_at
|
97
|
-
- retirement_at
|
98
|
-
- deprecated_at
|
99
|
-
- retirement_text
|
100
|
-
"""
|
101
|
-
return self._model_info
|
102
|
-
|
103
|
-
@property
|
104
|
-
def name(self) -> LanguageModelName | str:
|
105
|
-
"""
|
106
|
-
Returns the LanguageModelName of the model or the name string when it is a custom / not defined model.
|
107
|
-
"""
|
108
|
-
return self._model_info.name
|
109
|
-
|
110
|
-
@property
|
111
|
-
def display_name(self) -> str:
|
112
|
-
"""
|
113
|
-
Returns the name of the model as a string.
|
114
|
-
"""
|
115
|
-
if isinstance(self._model_info.name, LanguageModelName):
|
116
|
-
return self._model_info.name.name
|
117
|
-
else:
|
118
|
-
return self._model_info.name
|
119
|
-
|
120
|
-
@property
|
121
|
-
def version(self) -> Optional[str]:
|
122
|
-
"""
|
123
|
-
Returns the version of the model.
|
124
|
-
"""
|
125
|
-
return self._model_info.version
|
126
|
-
|
127
|
-
@property
|
128
|
-
def encoder_name(self) -> Optional[EncoderName]:
|
129
|
-
"""
|
130
|
-
Returns the encoder_name used for the model.
|
131
|
-
"""
|
132
|
-
return self._model_info.encoder_name
|
133
|
-
|
134
|
-
@property
|
135
|
-
def token_limit(self) -> Optional[int]:
|
136
|
-
"""
|
137
|
-
Returns the maximum number of tokens for the model.
|
138
|
-
"""
|
139
|
-
if self._model_info.token_limits:
|
140
|
-
return self._model_info.token_limits.token_limit
|
141
|
-
|
142
|
-
@property
|
143
|
-
def token_limit_input(self) -> Optional[int]:
|
144
|
-
"""
|
145
|
-
Returns the maximum number of input tokens for the model.
|
146
|
-
"""
|
147
|
-
if self._model_info.token_limits:
|
148
|
-
return self._model_info.token_limits.token_limit_input
|
149
|
-
|
150
|
-
@property
|
151
|
-
def token_limit_output(self) -> Optional[int]:
|
152
|
-
"""
|
153
|
-
Returns the maximum number of output tokens for the model.
|
154
|
-
"""
|
155
|
-
if self._model_info.token_limits:
|
156
|
-
return self._model_info.token_limits.token_limit_output
|
157
|
-
|
158
|
-
@property
|
159
|
-
def info_cutoff_at(self) -> Optional[date]:
|
160
|
-
"""
|
161
|
-
Returns the date the model was last updated.
|
162
|
-
"""
|
163
|
-
return self._model_info.info_cutoff_at
|
164
|
-
|
165
|
-
@property
|
166
|
-
def published_at(self) -> Optional[date]:
|
167
|
-
"""
|
168
|
-
Returns the date the model was published.
|
169
|
-
"""
|
170
|
-
return self._model_info.published_at
|
171
|
-
|
172
|
-
@property
|
173
|
-
def retirement_at(self) -> Optional[date]:
|
174
|
-
"""
|
175
|
-
Returns the date the model will be retired.
|
176
|
-
"""
|
177
|
-
return self._model_info.retirement_at
|
178
|
-
|
179
|
-
@property
|
180
|
-
def deprecated_at(self) -> Optional[date]:
|
181
|
-
"""
|
182
|
-
Returns the date the model was deprecated.
|
183
|
-
"""
|
184
|
-
return self._model_info.deprecated_at
|
185
|
-
|
186
|
-
@property
|
187
|
-
def retirement_text(self) -> Optional[str]:
|
188
|
-
"""
|
189
|
-
Returns the text that will be displayed when the model is retired.
|
190
|
-
"""
|
191
|
-
return self._model_info.retirement_text
|
192
|
-
|
193
|
-
@property
|
194
|
-
def provider(self) -> LanguageModelProvider:
|
195
|
-
"""
|
196
|
-
Returns the provider of the model.
|
197
|
-
"""
|
198
|
-
return self._model_info.provider
|
199
|
-
|
200
|
-
@classmethod
|
201
|
-
def get_model_info(cls, model_name: LanguageModelName | str) -> LanguageModelInfo:
|
202
|
-
if not model_name:
|
203
|
-
raise ValueError("Model name must be provided to get the model info.")
|
204
|
-
|
205
|
-
for subclass in cls.__subclasses__():
|
206
|
-
if hasattr(subclass, "info") and subclass._info.name == model_name:
|
207
|
-
# TODO find alternative solution for warning
|
208
|
-
# if subclass._info.retirement_at:
|
209
|
-
# warning_text = f"WARNING: {subclass._info.name} will be retired on {subclass._info.retirement_at.isoformat()} and from then on not accessible anymore. {subclass._info.retirement_text}"
|
210
|
-
# print(warning_text)
|
211
|
-
# warnings.warn(warning_text, DeprecationWarning, stacklevel=2)
|
212
|
-
return subclass._info
|
213
|
-
|
214
|
-
return LanguageModelInfo(
|
215
|
-
name=model_name,
|
216
|
-
version="custom",
|
217
|
-
provider=LanguageModelProvider.CUSTOM,
|
218
|
-
)
|
219
|
-
|
220
|
-
@classmethod
|
221
|
-
def list_models(cls) -> list[LanguageModelInfo]:
|
222
|
-
"""
|
223
|
-
Returns a list of the infos of all available models.
|
224
|
-
"""
|
225
|
-
|
226
|
-
return [
|
227
|
-
cast(LanguageModelInfo, subclass._info)
|
228
|
-
for subclass in cls.__subclasses__()
|
229
|
-
if hasattr(subclass, "_info")
|
230
|
-
]
|
231
|
-
|
232
|
-
|
233
|
-
def create_language_model(
|
234
|
-
name: LanguageModelName,
|
235
|
-
version: str,
|
236
|
-
provider: LanguageModelProvider,
|
237
|
-
info_cutoff_at: date,
|
238
|
-
published_at: date,
|
239
|
-
encoder_name: Optional[EncoderName] = None,
|
240
|
-
token_limit: Optional[int] = None,
|
241
|
-
token_limit_input: Optional[int] = None,
|
242
|
-
token_limit_output: Optional[int] = None,
|
243
|
-
retirement_at: Optional[date] = None,
|
244
|
-
deprecated_at: Optional[date] = None,
|
245
|
-
retirement_text: Optional[str] = None,
|
246
|
-
) -> Type[LanguageModel]:
|
247
|
-
info = LanguageModelInfo(
|
248
|
-
name=name,
|
249
|
-
version=version,
|
250
|
-
provider=provider,
|
251
|
-
encoder_name=encoder_name,
|
252
|
-
token_limits=LanguageModelTokenLimits(
|
253
|
-
token_limit=token_limit,
|
254
|
-
token_limit_input=token_limit_input,
|
255
|
-
token_limit_output=token_limit_output,
|
256
|
-
),
|
257
|
-
info_cutoff_at=info_cutoff_at,
|
258
|
-
published_at=published_at,
|
259
|
-
retirement_at=retirement_at,
|
260
|
-
deprecated_at=deprecated_at,
|
261
|
-
retirement_text=retirement_text,
|
262
|
-
)
|
263
|
-
|
264
|
-
class Model(LanguageModel):
|
265
|
-
_info = info
|
266
|
-
|
267
|
-
return Model
|
268
|
-
|
269
|
-
|
270
|
-
############################################################################################################
|
271
|
-
# Define the models here
|
272
|
-
############################################################################################################
|
273
|
-
|
274
|
-
|
275
|
-
AzureGpt35Turbo0613 = create_language_model(
|
276
|
-
name=LanguageModelName.AZURE_GPT_35_TURBO_0613,
|
277
|
-
provider=LanguageModelProvider.AZURE,
|
278
|
-
version="0613",
|
279
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_35_TURBO_0613),
|
280
|
-
token_limit=8192,
|
281
|
-
info_cutoff_at=date(2021, 9, 1),
|
282
|
-
published_at=date(2023, 6, 13),
|
283
|
-
retirement_at=date(2025, 2, 13),
|
284
|
-
)
|
285
|
-
|
286
|
-
AzureGpt35Turbo = create_language_model(
|
287
|
-
name=LanguageModelName.AZURE_GPT_35_TURBO,
|
288
|
-
provider=LanguageModelProvider.AZURE,
|
289
|
-
version="0301",
|
290
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_35_TURBO),
|
291
|
-
token_limit=4096,
|
292
|
-
info_cutoff_at=date(2021, 9, 1),
|
293
|
-
published_at=date(2023, 3, 1),
|
294
|
-
retirement_at=date(2025, 2, 13),
|
295
|
-
)
|
296
|
-
|
297
|
-
|
298
|
-
AzureGpt35Turbo16k = create_language_model(
|
299
|
-
name=LanguageModelName.AZURE_GPT_35_TURBO_16K,
|
300
|
-
provider=LanguageModelProvider.AZURE,
|
301
|
-
version="0613",
|
302
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_35_TURBO_16K),
|
303
|
-
token_limit=16382,
|
304
|
-
info_cutoff_at=date(2021, 9, 1),
|
305
|
-
published_at=date(2023, 6, 13),
|
306
|
-
retirement_at=date(2025, 2, 13),
|
307
|
-
)
|
308
|
-
|
309
|
-
|
310
|
-
AzureGpt35Turbo0125 = create_language_model(
|
311
|
-
name=LanguageModelName.AZURE_GPT_35_TURBO_0125,
|
312
|
-
provider=LanguageModelProvider.AZURE,
|
313
|
-
version="0125",
|
314
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_35_TURBO_0125),
|
315
|
-
token_limit_input=16385,
|
316
|
-
token_limit_output=4096,
|
317
|
-
info_cutoff_at=date(2021, 9, 1),
|
318
|
-
published_at=date(2023, 1, 25),
|
319
|
-
retirement_at=date(5, 3, 31),
|
320
|
-
)
|
321
|
-
|
322
|
-
|
323
|
-
AzureGpt40613 = create_language_model(
|
324
|
-
name=LanguageModelName.AZURE_GPT_4_0613,
|
325
|
-
provider=LanguageModelProvider.AZURE,
|
326
|
-
version="0613",
|
327
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4_0613),
|
328
|
-
token_limit=8192,
|
329
|
-
info_cutoff_at=date(2021, 9, 1),
|
330
|
-
published_at=date(2023, 6, 13),
|
331
|
-
deprecated_at=date(2024, 10, 1),
|
332
|
-
retirement_at=date(2025, 6, 6),
|
333
|
-
)
|
334
|
-
|
335
|
-
|
336
|
-
AzureGpt4Turbo1106 = create_language_model(
|
337
|
-
name=LanguageModelName.AZURE_GPT_4_TURBO_1106,
|
338
|
-
provider=LanguageModelProvider.AZURE,
|
339
|
-
version="1106-preview",
|
340
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4_TURBO_1106),
|
341
|
-
token_limit_input=128000,
|
342
|
-
token_limit_output=4096,
|
343
|
-
info_cutoff_at=date(2023, 4, 1),
|
344
|
-
published_at=date(2023, 11, 6),
|
345
|
-
)
|
346
|
-
|
347
|
-
|
348
|
-
AzureGpt4VisionPreview = create_language_model(
|
349
|
-
name=LanguageModelName.AZURE_GPT_4_VISION_PREVIEW,
|
350
|
-
provider=LanguageModelProvider.AZURE,
|
351
|
-
version="vision-preview",
|
352
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4_VISION_PREVIEW),
|
353
|
-
token_limit_input=128000,
|
354
|
-
token_limit_output=4096,
|
355
|
-
info_cutoff_at=date(2023, 4, 1),
|
356
|
-
published_at=date(2023, 11, 6),
|
357
|
-
)
|
358
|
-
|
359
|
-
AzureGpt432k0613 = create_language_model(
|
360
|
-
name=LanguageModelName.AZURE_GPT_4_32K_0613,
|
361
|
-
provider=LanguageModelProvider.AZURE,
|
362
|
-
version="1106-preview",
|
363
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4_32K_0613),
|
364
|
-
token_limit=32768,
|
365
|
-
info_cutoff_at=date(2021, 9, 1),
|
366
|
-
published_at=date(2023, 6, 13),
|
367
|
-
deprecated_at=date(2024, 10, 1),
|
368
|
-
retirement_at=date(2025, 6, 6),
|
369
|
-
)
|
370
|
-
|
371
|
-
AzureGpt4Turbo20240409 = create_language_model(
|
372
|
-
name=LanguageModelName.AZURE_GPT_4_TURBO_2024_0409,
|
373
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4_TURBO_2024_0409),
|
374
|
-
provider=LanguageModelProvider.AZURE,
|
375
|
-
version="turbo-2024-04-09",
|
376
|
-
token_limit_input=128000,
|
377
|
-
token_limit_output=4096,
|
378
|
-
info_cutoff_at=date(2023, 12, 1),
|
379
|
-
published_at=date(2024, 4, 9),
|
380
|
-
)
|
381
|
-
|
382
|
-
AzureGpt4o20240513 = create_language_model(
|
383
|
-
name=LanguageModelName.AZURE_GPT_4o_2024_0513,
|
384
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4o_2024_0513),
|
385
|
-
provider=LanguageModelProvider.AZURE,
|
386
|
-
version="2024-05-13",
|
387
|
-
token_limit_input=128000,
|
388
|
-
token_limit_output=4096,
|
389
|
-
info_cutoff_at=date(2023, 10, 1),
|
390
|
-
published_at=date(2024, 5, 13),
|
391
|
-
)
|
392
|
-
|
393
|
-
AzureGpt4o20240806 = create_language_model(
|
394
|
-
name=LanguageModelName.AZURE_GPT_4o_2024_0806,
|
395
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4o_2024_0806),
|
396
|
-
provider=LanguageModelProvider.AZURE,
|
397
|
-
version="2024-08-06",
|
398
|
-
token_limit_input=128000,
|
399
|
-
token_limit_output=16384,
|
400
|
-
info_cutoff_at=date(2023, 10, 1),
|
401
|
-
published_at=date(2024, 8, 6),
|
402
|
-
)
|
403
|
-
|
404
|
-
AzureGpt4oMini20240718 = create_language_model(
|
405
|
-
name=LanguageModelName.AZURE_GPT_4o_MINI_2024_0718,
|
406
|
-
provider=LanguageModelProvider.AZURE,
|
407
|
-
version="2024-07-18",
|
408
|
-
encoder_name=get_encoder_name(LanguageModelName.AZURE_GPT_4o_MINI_2024_0718),
|
409
|
-
token_limit_input=128000,
|
410
|
-
token_limit_output=16384,
|
411
|
-
info_cutoff_at=date(2023, 10, 1),
|
412
|
-
published_at=date(2024, 7, 18),
|
413
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/_common/validate_required_values.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/app/performance/async_wrapper.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/context_relevancy/prompts.py
RENAMED
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/context_relevancy/service.py
RENAMED
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/context_relevancy/utils.py
RENAMED
File without changes
|
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/constants.py
RENAMED
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/prompts.py
RENAMED
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/service.py
RENAMED
File without changes
|
{unique_toolkit-0.6.1 → unique_toolkit-0.6.4}/unique_toolkit/evaluators/hallucination/utils.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|