unique_toolkit 0.8.23__py3-none-any.whl → 0.8.25__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.
- unique_toolkit/__init__.py +8 -1
- unique_toolkit/_common/endpoint_builder.py +145 -0
- unique_toolkit/app/schemas.py +11 -0
- unique_toolkit/app/unique_settings.py +102 -1
- unique_toolkit/chat/service.py +4 -0
- unique_toolkit/evals/evaluation_manager.py +13 -7
- unique_toolkit/framework_utilities/__init__.py +1 -0
- unique_toolkit/framework_utilities/langchain/client.py +3 -1
- unique_toolkit/framework_utilities/openai/__init__.py +6 -0
- unique_toolkit/framework_utilities/openai/client.py +4 -1
- {unique_toolkit-0.8.23.dist-info → unique_toolkit-0.8.25.dist-info}/METADATA +12 -1
- {unique_toolkit-0.8.23.dist-info → unique_toolkit-0.8.25.dist-info}/RECORD +14 -11
- {unique_toolkit-0.8.23.dist-info → unique_toolkit-0.8.25.dist-info}/LICENSE +0 -0
- {unique_toolkit-0.8.23.dist-info → unique_toolkit-0.8.25.dist-info}/WHEEL +0 -0
unique_toolkit/__init__.py
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
from unique_toolkit.chat import ChatService
|
|
3
3
|
from unique_toolkit.content import ContentService
|
|
4
4
|
from unique_toolkit.embedding import EmbeddingService
|
|
5
|
-
from unique_toolkit.language_model import
|
|
5
|
+
from unique_toolkit.language_model import (
|
|
6
|
+
LanguageModelMessages,
|
|
7
|
+
LanguageModelName,
|
|
8
|
+
LanguageModelService,
|
|
9
|
+
LanguageModelToolDescription,
|
|
10
|
+
)
|
|
6
11
|
from unique_toolkit.short_term_memory import ShortTermMemoryService
|
|
7
12
|
|
|
8
13
|
# You can add other classes you frequently use here as well
|
|
@@ -10,6 +15,8 @@ from unique_toolkit.short_term_memory import ShortTermMemoryService
|
|
|
10
15
|
__all__ = [
|
|
11
16
|
"LanguageModelService",
|
|
12
17
|
"LanguageModelMessages",
|
|
18
|
+
"LanguageModelName",
|
|
19
|
+
"LanguageModelToolDescription",
|
|
13
20
|
"ChatService",
|
|
14
21
|
"ContentService",
|
|
15
22
|
"EmbeddingService",
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides a minimal framework for building endpoint classes such that a client can use
|
|
3
|
+
the endpoints without having to know the details of the endpoints.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from string import Formatter, Template
|
|
8
|
+
from typing import (
|
|
9
|
+
Any,
|
|
10
|
+
Generic,
|
|
11
|
+
ParamSpec,
|
|
12
|
+
Protocol,
|
|
13
|
+
TypeVar,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from pydantic import BaseModel
|
|
17
|
+
|
|
18
|
+
# Type variables
|
|
19
|
+
ResponseType = TypeVar("ResponseType", bound=BaseModel)
|
|
20
|
+
PathParamsType = TypeVar("PathParamsType", bound=BaseModel)
|
|
21
|
+
RequestBodyType = TypeVar("RequestBodyType", bound=BaseModel)
|
|
22
|
+
|
|
23
|
+
# ParamSpecs for function signatures
|
|
24
|
+
RequestConstructorSpec = ParamSpec("RequestConstructorSpec")
|
|
25
|
+
PathParamsSpec = ParamSpec("PathParamsSpec")
|
|
26
|
+
RequestBodySpec = ParamSpec("RequestBodySpec")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Necessary for typing of make_endpoint_class
|
|
30
|
+
class EndpointClassProtocol(Protocol, Generic[PathParamsSpec, RequestBodySpec]):
|
|
31
|
+
@staticmethod
|
|
32
|
+
def create_url(
|
|
33
|
+
*args: PathParamsSpec.args, **kwargs: PathParamsSpec.kwargs
|
|
34
|
+
) -> str: ...
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def create_payload(
|
|
38
|
+
*args: RequestBodySpec.args, **kwargs: RequestBodySpec.kwargs
|
|
39
|
+
) -> dict[str, Any]: ...
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Model for any client to implement
|
|
43
|
+
class Client(Protocol):
|
|
44
|
+
def request(
|
|
45
|
+
self,
|
|
46
|
+
endpoint: EndpointClassProtocol,
|
|
47
|
+
) -> dict[str, Any]: ...
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def build_endpoint_class(
|
|
51
|
+
*,
|
|
52
|
+
url_template: Template,
|
|
53
|
+
path_params_model: Callable[PathParamsSpec, PathParamsType],
|
|
54
|
+
payload_model: Callable[RequestBodySpec, RequestBodyType],
|
|
55
|
+
response_model: type[ResponseType],
|
|
56
|
+
dump_options: dict | None = None,
|
|
57
|
+
) -> type[EndpointClassProtocol[PathParamsSpec, RequestBodySpec]]:
|
|
58
|
+
"""Generate a class with static methods for endpoint handling.
|
|
59
|
+
|
|
60
|
+
Uses separate models for path parameters and request body for clean API design.
|
|
61
|
+
|
|
62
|
+
Returns a class with static methods:
|
|
63
|
+
- create_url: Creates URL from path parameters
|
|
64
|
+
- create_payload: Creates request body payload
|
|
65
|
+
"""
|
|
66
|
+
if not dump_options:
|
|
67
|
+
dump_options = {
|
|
68
|
+
"exclude_unset": True,
|
|
69
|
+
"by_alias": True,
|
|
70
|
+
"exclude_defaults": True,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class EndpointClass(EndpointClassProtocol):
|
|
74
|
+
@staticmethod
|
|
75
|
+
def create_url(
|
|
76
|
+
*args: PathParamsSpec.args, **kwargs: PathParamsSpec.kwargs
|
|
77
|
+
) -> str:
|
|
78
|
+
"""Create URL from path parameters."""
|
|
79
|
+
path_model = path_params_model(*args, **kwargs)
|
|
80
|
+
path_dict = path_model.model_dump(**dump_options)
|
|
81
|
+
|
|
82
|
+
# Extract expected path parameters from template
|
|
83
|
+
template_params = [
|
|
84
|
+
fname
|
|
85
|
+
for _, fname, _, _ in Formatter().parse(url_template.template)
|
|
86
|
+
if fname is not None
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
# Verify all required path parameters are present
|
|
90
|
+
missing_params = [
|
|
91
|
+
param for param in template_params if param not in path_dict
|
|
92
|
+
]
|
|
93
|
+
if missing_params:
|
|
94
|
+
raise ValueError(f"Missing path parameters: {missing_params}")
|
|
95
|
+
|
|
96
|
+
return url_template.substitute(**path_dict)
|
|
97
|
+
|
|
98
|
+
@staticmethod
|
|
99
|
+
def create_payload(
|
|
100
|
+
*args: RequestBodySpec.args, **kwargs: RequestBodySpec.kwargs
|
|
101
|
+
) -> dict[str, Any]:
|
|
102
|
+
"""Create request body payload."""
|
|
103
|
+
request_model = payload_model(*args, **kwargs)
|
|
104
|
+
return request_model.model_dump(**dump_options)
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def handle_response(response: dict[str, Any]) -> ResponseType:
|
|
108
|
+
return response_model.model_validate(response)
|
|
109
|
+
|
|
110
|
+
return EndpointClass
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if __name__ == "__main__":
|
|
114
|
+
# Example models
|
|
115
|
+
class GetUserPathParams(BaseModel):
|
|
116
|
+
"""Path parameters for the user endpoint."""
|
|
117
|
+
|
|
118
|
+
user_id: int
|
|
119
|
+
|
|
120
|
+
class GetUserRequestBody(BaseModel):
|
|
121
|
+
"""Request body/query parameters for the user endpoint."""
|
|
122
|
+
|
|
123
|
+
include_profile: bool = False
|
|
124
|
+
|
|
125
|
+
class UserResponse(BaseModel):
|
|
126
|
+
"""Response model for user data."""
|
|
127
|
+
|
|
128
|
+
id: int
|
|
129
|
+
name: str
|
|
130
|
+
|
|
131
|
+
# Example usage of make_endpoint_class
|
|
132
|
+
UserEndpoint = build_endpoint_class(
|
|
133
|
+
url_template=Template("/users/${user_id}"),
|
|
134
|
+
path_params_model=GetUserPathParams,
|
|
135
|
+
payload_model=GetUserRequestBody,
|
|
136
|
+
response_model=UserResponse,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Create URL from path parameters
|
|
140
|
+
url = UserEndpoint.create_url(user_id=123)
|
|
141
|
+
print(f"URL: {url}")
|
|
142
|
+
|
|
143
|
+
# Create payload from request body parameters
|
|
144
|
+
payload = UserEndpoint.create_payload(include_profile=True)
|
|
145
|
+
print(f"Payload: {payload}")
|
unique_toolkit/app/schemas.py
CHANGED
|
@@ -227,6 +227,17 @@ class ChatEvent(BaseEvent):
|
|
|
227
227
|
data = json.load(f)
|
|
228
228
|
return cls.model_validate(data)
|
|
229
229
|
|
|
230
|
+
def get_initial_debug_info(self) -> dict[str, Any]:
|
|
231
|
+
"""Get the debug information for the chat event"""
|
|
232
|
+
|
|
233
|
+
# TODO: Make sure this coincides with what is shown in the first user message
|
|
234
|
+
return {
|
|
235
|
+
"user_metadata": self.payload.user_metadata,
|
|
236
|
+
"tool_parameters": self.payload.tool_parameters,
|
|
237
|
+
"chosen_module": self.payload.name,
|
|
238
|
+
"assistant": {"id": self.payload.assistant_id},
|
|
239
|
+
}
|
|
240
|
+
|
|
230
241
|
|
|
231
242
|
@deprecated(
|
|
232
243
|
"""Use the more specific `ChatEvent` instead that has the same properties. \
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import os
|
|
1
2
|
from logging import getLogger
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
from typing import Self, TypeVar
|
|
4
5
|
from urllib.parse import urlparse, urlunparse
|
|
5
6
|
|
|
7
|
+
import unique_sdk
|
|
8
|
+
from platformdirs import user_config_dir
|
|
6
9
|
from pydantic import AliasChoices, Field, SecretStr, model_validator
|
|
7
10
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
8
11
|
|
|
@@ -100,7 +103,9 @@ class UniqueApi(BaseSettings):
|
|
|
100
103
|
parsed = urlparse(self.base_url)
|
|
101
104
|
|
|
102
105
|
path = "/public/chat"
|
|
103
|
-
if parsed.hostname and
|
|
106
|
+
if parsed.hostname and (
|
|
107
|
+
"qa.unique" in parsed.hostname or ".unique" in parsed.hostname
|
|
108
|
+
):
|
|
104
109
|
path = "/public/chat-gen2"
|
|
105
110
|
return urlunparse(parsed._replace(path=path, query=None, fragment=None))
|
|
106
111
|
|
|
@@ -142,12 +147,57 @@ class UniqueAuth(BaseSettings):
|
|
|
142
147
|
return warn_about_defaults(self)
|
|
143
148
|
|
|
144
149
|
|
|
150
|
+
class EnvFileNotFoundError(FileNotFoundError):
|
|
151
|
+
"""Raised when no environment file can be found in any of the expected locations."""
|
|
152
|
+
|
|
153
|
+
|
|
145
154
|
class UniqueSettings:
|
|
146
155
|
def __init__(self, auth: UniqueAuth, app: UniqueApp, api: UniqueApi):
|
|
147
156
|
self.app = app
|
|
148
157
|
self.auth = auth
|
|
149
158
|
self.api = api
|
|
150
159
|
|
|
160
|
+
@classmethod
|
|
161
|
+
def _find_env_file(cls, filename: str = "unique.env") -> Path:
|
|
162
|
+
"""Find environment file using cross-platform fallback locations.
|
|
163
|
+
|
|
164
|
+
Search order:
|
|
165
|
+
1. UNIQUE_ENV_FILE environment variable
|
|
166
|
+
2. Current working directory
|
|
167
|
+
3. User config directory (cross-platform via platformdirs)
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
filename: Name of the environment file (default: 'unique.env')
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
Path to the environment file.
|
|
174
|
+
|
|
175
|
+
Raises:
|
|
176
|
+
EnvFileNotFoundError: If no environment file is found in any location.
|
|
177
|
+
"""
|
|
178
|
+
locations = [
|
|
179
|
+
# 1. Explicit environment variable
|
|
180
|
+
Path(env_path) if (env_path := os.environ.get("UNIQUE_ENV_FILE")) else None,
|
|
181
|
+
# 2. Current working directory
|
|
182
|
+
Path.cwd() / filename,
|
|
183
|
+
# 3. User config directory (cross-platform)
|
|
184
|
+
Path(user_config_dir("unique", "unique-toolkit")) / filename,
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
for location in locations:
|
|
188
|
+
if location and location.exists() and location.is_file():
|
|
189
|
+
return location
|
|
190
|
+
|
|
191
|
+
# If no file found, provide helpful error message
|
|
192
|
+
searched_locations = [str(loc) for loc in locations if loc is not None]
|
|
193
|
+
raise EnvFileNotFoundError(
|
|
194
|
+
f"Environment file '{filename}' not found. Searched locations:\n"
|
|
195
|
+
+ "\n".join(f" - {loc}" for loc in searched_locations)
|
|
196
|
+
+ "\n\nTo fix this:\n"
|
|
197
|
+
+ f" 1. Create {filename} in one of the above locations, or\n"
|
|
198
|
+
+ f" 2. Set UNIQUE_ENV_FILE environment variable to point to your {filename} file"
|
|
199
|
+
)
|
|
200
|
+
|
|
151
201
|
@classmethod
|
|
152
202
|
def from_env(cls, env_file: Path | None = None) -> "UniqueSettings":
|
|
153
203
|
"""Initialize settings from environment variables and/or env file.
|
|
@@ -171,3 +221,54 @@ class UniqueSettings:
|
|
|
171
221
|
app = UniqueApp(_env_file=env_file_str) # type: ignore[call-arg]
|
|
172
222
|
api = UniqueApi(_env_file=env_file_str) # type: ignore[call-arg]
|
|
173
223
|
return cls(auth=auth, app=app, api=api)
|
|
224
|
+
|
|
225
|
+
@classmethod
|
|
226
|
+
def from_env_auto(cls, filename: str = "unique.env") -> "UniqueSettings":
|
|
227
|
+
"""Initialize settings by automatically finding environment file.
|
|
228
|
+
|
|
229
|
+
This method will automatically search for an environment file in standard locations
|
|
230
|
+
and fall back to environment variables only if no file is found.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
filename: Name of the environment file to search for (default: '.env')
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
UniqueSettings instance with values loaded from found env file or environment variables.
|
|
237
|
+
"""
|
|
238
|
+
try:
|
|
239
|
+
env_file = cls._find_env_file(filename)
|
|
240
|
+
return cls.from_env(env_file=env_file)
|
|
241
|
+
except EnvFileNotFoundError:
|
|
242
|
+
logger.warning(
|
|
243
|
+
f"Environment file '{filename}' not found. Falling back to environment variables only."
|
|
244
|
+
)
|
|
245
|
+
# Fall back to environment variables only
|
|
246
|
+
return cls.from_env()
|
|
247
|
+
|
|
248
|
+
def init_sdk(self) -> None:
|
|
249
|
+
"""Initialize the unique_sdk global configuration with these settings.
|
|
250
|
+
|
|
251
|
+
This method configures the global unique_sdk module with the API key,
|
|
252
|
+
app ID, and base URL from these settings.
|
|
253
|
+
"""
|
|
254
|
+
unique_sdk.api_key = self.app.key.get_secret_value()
|
|
255
|
+
unique_sdk.app_id = self.app.id.get_secret_value()
|
|
256
|
+
unique_sdk.api_base = self.api.sdk_url()
|
|
257
|
+
|
|
258
|
+
@classmethod
|
|
259
|
+
def from_env_auto_with_sdk_init(
|
|
260
|
+
cls, filename: str = "unique.env"
|
|
261
|
+
) -> "UniqueSettings":
|
|
262
|
+
"""Initialize settings and SDK in one convenient call.
|
|
263
|
+
|
|
264
|
+
This method combines from_env_auto() and init_sdk() for the most common use case.
|
|
265
|
+
|
|
266
|
+
Args:
|
|
267
|
+
filename: Name of the environment file to search for (default: '.env')
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
UniqueSettings instance with SDK already initialized.
|
|
271
|
+
"""
|
|
272
|
+
settings = cls.from_env_auto(filename)
|
|
273
|
+
settings.init_sdk()
|
|
274
|
+
return settings
|
unique_toolkit/chat/service.py
CHANGED
|
@@ -479,6 +479,10 @@ class ChatService:
|
|
|
479
479
|
set_completed_at=set_completed_at or False,
|
|
480
480
|
)
|
|
481
481
|
|
|
482
|
+
def free_user_input(self) -> None:
|
|
483
|
+
"""Unblocks the next user input"""
|
|
484
|
+
self.modify_assistant_message(set_completed_at=True)
|
|
485
|
+
|
|
482
486
|
def get_full_history(self) -> list[ChatMessage]:
|
|
483
487
|
"""Loads the full chat history for the chat session synchronously.
|
|
484
488
|
|
|
@@ -78,11 +78,9 @@ class EvaluationManager:
|
|
|
78
78
|
self,
|
|
79
79
|
logger: Logger,
|
|
80
80
|
chat_service: ChatService,
|
|
81
|
-
assistant_message_id: str,
|
|
82
81
|
):
|
|
83
82
|
self._logger = logger
|
|
84
83
|
self._chat_service = chat_service
|
|
85
|
-
self._assistant_message_id = assistant_message_id
|
|
86
84
|
self._evaluations: dict[EvaluationMetricName, Evaluation] = {}
|
|
87
85
|
self._evaluation_passed: bool = True
|
|
88
86
|
|
|
@@ -96,6 +94,7 @@ class EvaluationManager:
|
|
|
96
94
|
self,
|
|
97
95
|
selected_evaluation_names: list[EvaluationMetricName],
|
|
98
96
|
loop_response: LanguageModelStreamResponse,
|
|
97
|
+
assistant_message_id: str,
|
|
99
98
|
) -> list[EvaluationMetricResult]:
|
|
100
99
|
task_executor = SafeTaskExecutor(
|
|
101
100
|
logger=self._logger,
|
|
@@ -106,6 +105,7 @@ class EvaluationManager:
|
|
|
106
105
|
self.execute_evaluation_call,
|
|
107
106
|
loop_response=loop_response,
|
|
108
107
|
evaluation_name=evaluation_name,
|
|
108
|
+
assistant_message_id=assistant_message_id,
|
|
109
109
|
)
|
|
110
110
|
for evaluation_name in selected_evaluation_names
|
|
111
111
|
]
|
|
@@ -126,6 +126,7 @@ class EvaluationManager:
|
|
|
126
126
|
self,
|
|
127
127
|
evaluation_name: EvaluationMetricName,
|
|
128
128
|
loop_response: LanguageModelStreamResponse,
|
|
129
|
+
assistant_message_id: str,
|
|
129
130
|
) -> EvaluationMetricResult:
|
|
130
131
|
self._logger.info(f"Processing tool call: {evaluation_name}")
|
|
131
132
|
|
|
@@ -133,13 +134,15 @@ class EvaluationManager:
|
|
|
133
134
|
|
|
134
135
|
if evaluation_instance:
|
|
135
136
|
# Execute the evaluation
|
|
136
|
-
await self._create_assistant_message(
|
|
137
|
+
await self._create_assistant_message(
|
|
138
|
+
evaluation_instance, assistant_message_id
|
|
139
|
+
)
|
|
137
140
|
evaluation_metric_result: EvaluationMetricResult = (
|
|
138
141
|
await evaluation_instance.run(loop_response)
|
|
139
142
|
)
|
|
140
143
|
# show results to the user
|
|
141
144
|
await self._show_message_assessment(
|
|
142
|
-
evaluation_instance, evaluation_metric_result
|
|
145
|
+
evaluation_instance, evaluation_metric_result, assistant_message_id
|
|
143
146
|
)
|
|
144
147
|
|
|
145
148
|
return evaluation_metric_result
|
|
@@ -182,6 +185,7 @@ class EvaluationManager:
|
|
|
182
185
|
self,
|
|
183
186
|
evaluation_instance: Evaluation,
|
|
184
187
|
evaluation_metric_result: EvaluationMetricResult,
|
|
188
|
+
assistant_message_id: str,
|
|
185
189
|
) -> None:
|
|
186
190
|
evaluation_assessment_message = (
|
|
187
191
|
await evaluation_instance.evaluation_metric_to_assessment(
|
|
@@ -189,7 +193,7 @@ class EvaluationManager:
|
|
|
189
193
|
)
|
|
190
194
|
)
|
|
191
195
|
await self._chat_service.modify_message_assessment_async(
|
|
192
|
-
assistant_message_id=
|
|
196
|
+
assistant_message_id=assistant_message_id,
|
|
193
197
|
status=evaluation_assessment_message.status,
|
|
194
198
|
title=evaluation_assessment_message.title,
|
|
195
199
|
explanation=evaluation_assessment_message.explanation,
|
|
@@ -197,9 +201,11 @@ class EvaluationManager:
|
|
|
197
201
|
type=evaluation_assessment_message.type,
|
|
198
202
|
)
|
|
199
203
|
|
|
200
|
-
async def _create_assistant_message(
|
|
204
|
+
async def _create_assistant_message(
|
|
205
|
+
self, evaluation_instance: Evaluation, assistant_message_id: str
|
|
206
|
+
):
|
|
201
207
|
await self._chat_service.create_message_assessment_async(
|
|
202
|
-
assistant_message_id=
|
|
208
|
+
assistant_message_id=assistant_message_id,
|
|
203
209
|
status=ChatMessageAssessmentStatus.PENDING,
|
|
204
210
|
type=evaluation_instance.get_assessment_type(),
|
|
205
211
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Framework utilities for integrating with external frameworks."""
|
|
@@ -23,7 +23,7 @@ else:
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def get_client(
|
|
26
|
-
unique_settings: UniqueSettings, model: str = "AZURE_GPT_4o_2024_0806"
|
|
26
|
+
unique_settings: UniqueSettings | None = None, model: str = "AZURE_GPT_4o_2024_0806"
|
|
27
27
|
) -> ChatOpenAI:
|
|
28
28
|
"""Get a Langchain ChatOpenAI client instance.
|
|
29
29
|
|
|
@@ -36,6 +36,8 @@ def get_client(
|
|
|
36
36
|
Raises:
|
|
37
37
|
LangchainNotInstalledError: If langchain-openai package is not installed
|
|
38
38
|
"""
|
|
39
|
+
if unique_settings is None:
|
|
40
|
+
unique_settings = UniqueSettings.from_env_auto()
|
|
39
41
|
|
|
40
42
|
return ChatOpenAI(
|
|
41
43
|
base_url=unique_settings.api.openai_proxy_url(),
|
|
@@ -22,7 +22,7 @@ else:
|
|
|
22
22
|
raise OpenAINotInstalledError()
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def get_openai_client(unique_settings: UniqueSettings) -> OpenAI:
|
|
25
|
+
def get_openai_client(unique_settings: UniqueSettings | None = None) -> OpenAI:
|
|
26
26
|
"""Get an OpenAI client instance.
|
|
27
27
|
|
|
28
28
|
Args:
|
|
@@ -34,6 +34,9 @@ def get_openai_client(unique_settings: UniqueSettings) -> OpenAI:
|
|
|
34
34
|
Raises:
|
|
35
35
|
OpenAINotInstalledError: If OpenAI package is not installed
|
|
36
36
|
"""
|
|
37
|
+
if unique_settings is None:
|
|
38
|
+
unique_settings = UniqueSettings.from_env_auto()
|
|
39
|
+
|
|
37
40
|
default_headers = get_default_headers(unique_settings.app, unique_settings.auth)
|
|
38
41
|
|
|
39
42
|
return OpenAI(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unique_toolkit
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.25
|
|
4
4
|
Summary:
|
|
5
5
|
License: Proprietary
|
|
6
6
|
Author: Martin Fadler
|
|
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Requires-Dist: numpy (>=1.26.4,<2.0.0)
|
|
14
14
|
Requires-Dist: openai (>=1.99.9,<2.0.0)
|
|
15
|
+
Requires-Dist: platformdirs (>=4.0.0,<5.0.0)
|
|
15
16
|
Requires-Dist: pydantic (>=2.8.2,<3.0.0)
|
|
16
17
|
Requires-Dist: pydantic-settings (>=2.10.1,<3.0.0)
|
|
17
18
|
Requires-Dist: pyhumps (>=3.8.0,<4.0.0)
|
|
@@ -114,9 +115,19 @@ All notable changes to this project will be documented in this file.
|
|
|
114
115
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
115
116
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
116
117
|
|
|
118
|
+
## [0.8.25] - 2025-08-27
|
|
119
|
+
- Load environment variables automatically from plattform dirs or environment
|
|
120
|
+
- General Endpoint definition utility
|
|
121
|
+
- Expose `LanguageModelToolDescription` and `LanguageModelName` directly
|
|
122
|
+
- Get initial debug information from chat payload
|
|
123
|
+
|
|
124
|
+
## [0.8.24] - 2025-08-25
|
|
125
|
+
- Optimized hallucination manager
|
|
126
|
+
|
|
117
127
|
## [0.8.23] - 2025-08-27
|
|
118
128
|
- Add MCP manager that handles MCP related logic
|
|
119
129
|
|
|
130
|
+
|
|
120
131
|
## [0.8.22] - 2025-08-25
|
|
121
132
|
- Add DeepSeek-R1, DeepSeek-V3.1, Qwen3-235B-A22B and Qwen3-235B-A22B-Thinking-2507 to supported model list
|
|
122
133
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
unique_toolkit/__init__.py,sha256=
|
|
1
|
+
unique_toolkit/__init__.py,sha256=nbOYPIKERt-ITsgifrnJhatn1YNR38Ntumw-dCn_tsA,714
|
|
2
2
|
unique_toolkit/_common/_base_service.py,sha256=S8H0rAebx7GsOldA7xInLp3aQJt9yEPDQdsGSFRJsGg,276
|
|
3
3
|
unique_toolkit/_common/_time_utils.py,sha256=ztmTovTvr-3w71Ns2VwXC65OKUUh-sQlzbHdKTQWm-w,135
|
|
4
4
|
unique_toolkit/_common/default_language_model.py,sha256=tmHSqg6e8G7RmKqmdE_tmLxkSN0x-aGoyUdy6Pl2oAE,334
|
|
5
|
+
unique_toolkit/_common/endpoint_builder.py,sha256=oM6uDmxUqTAJut6MuJQj3bIX4yOccyErWD5bJ1d1lcY,4526
|
|
5
6
|
unique_toolkit/_common/exception.py,sha256=caQIE1btsQnpKCHqL2cgWUSbHup06enQu_Pt7uGUTTE,727
|
|
6
7
|
unique_toolkit/_common/token/image_token_counting.py,sha256=VpFfZyY0GIH27q_Wy4YNjk2algqvbCtJyzuuROoFQPw,2189
|
|
7
8
|
unique_toolkit/_common/token/token_counting.py,sha256=Jo5B11GLlnaZDi4u7xCzIboLl8zn5cY_dmrogHixVdk,6132
|
|
@@ -13,14 +14,14 @@ unique_toolkit/app/init_logging.py,sha256=Sh26SRxOj8i8dzobKhYha2lLrkrMTHfB1V4jR3
|
|
|
13
14
|
unique_toolkit/app/init_sdk.py,sha256=5_oDoETr6akwYyBCb0ivTdMNu3SVgPSkrXcDS6ELyY8,2269
|
|
14
15
|
unique_toolkit/app/performance/async_tasks.py,sha256=H0l3OAcosLwNHZ8d2pd-Di4wHIXfclEvagi5kfqLFPA,1941
|
|
15
16
|
unique_toolkit/app/performance/async_wrapper.py,sha256=yVVcRDkcdyfjsxro-N29SBvi-7773wnfDplef6-y8xw,1077
|
|
16
|
-
unique_toolkit/app/schemas.py,sha256=
|
|
17
|
-
unique_toolkit/app/unique_settings.py,sha256=
|
|
17
|
+
unique_toolkit/app/schemas.py,sha256=uh7PR-YYXfdTnuO5V_eGrW96eJmP5tJ4jeePyU8tsNI,7888
|
|
18
|
+
unique_toolkit/app/unique_settings.py,sha256=hsQ4ViOs-E5K_bq96PwDvuVpfMJ-vNPq01B2gCK5R5g,9802
|
|
18
19
|
unique_toolkit/app/verification.py,sha256=GxFFwcJMy25fCA_Xe89wKW7bgqOu8PAs5y8QpHF0GSc,3861
|
|
19
20
|
unique_toolkit/chat/__init__.py,sha256=LRs2G-JTVuci4lbtHTkVUiNcZcSR6uqqfnAyo7af6nY,619
|
|
20
21
|
unique_toolkit/chat/constants.py,sha256=05kq6zjqUVB2d6_P7s-90nbljpB3ryxwCI-CAz0r2O4,83
|
|
21
22
|
unique_toolkit/chat/functions.py,sha256=I6r81PpWNu-j9DvHxNFKN3V6T5E5q42FhW9kF8pJJSY,29950
|
|
22
23
|
unique_toolkit/chat/schemas.py,sha256=ekmDzxZRnO4pF-8DAnP4JqKmYuJnSC5RpYcO7j5T3aI,4927
|
|
23
|
-
unique_toolkit/chat/service.py,sha256
|
|
24
|
+
unique_toolkit/chat/service.py,sha256=-agXxkB_cl7Mcr3aFVHbBXhO-RioiouAfoHAHmlhQJs,37981
|
|
24
25
|
unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,1445
|
|
25
26
|
unique_toolkit/chat/utils.py,sha256=ihm-wQykBWhB4liR3LnwPVPt_qGW6ETq21Mw4HY0THE,854
|
|
26
27
|
unique_toolkit/content/__init__.py,sha256=EdJg_A_7loEtCQf4cah3QARQreJx6pdz89Rm96YbMVg,940
|
|
@@ -40,7 +41,7 @@ unique_toolkit/evals/config.py,sha256=ywHIrJs5SFdKr1WXfrofWuFfzb0iPQw8iZDpq5oEug
|
|
|
40
41
|
unique_toolkit/evals/context_relevancy/prompts.py,sha256=EdHFUOB581yVxcOL8482KUv_LzaRjuiem71EF8udYMc,1331
|
|
41
42
|
unique_toolkit/evals/context_relevancy/schema.py,sha256=lm9x0jExOinUk9itqC8ZpgReC7yj1VDwEMppxlZGqpY,2923
|
|
42
43
|
unique_toolkit/evals/context_relevancy/service.py,sha256=txTWIhV65QGFhxG1jCb5TTqZc_c7K9I8pi2HVDTAfm8,8384
|
|
43
|
-
unique_toolkit/evals/evaluation_manager.py,sha256=
|
|
44
|
+
unique_toolkit/evals/evaluation_manager.py,sha256=g-8qa_6_p53C9Okx8iNkuoIXYSJrf-6sQ-xku7bo9kI,7895
|
|
44
45
|
unique_toolkit/evals/exception.py,sha256=7lcVbCyoN4Md1chNJDFxpUYyWbVrcr9dcc3TxWykJTc,115
|
|
45
46
|
unique_toolkit/evals/hallucination/constants.py,sha256=FLcXl5XU07jCvS8YPX9l6UjTaqyQ8YvnSKpx4Z6wZ2Y,1997
|
|
46
47
|
unique_toolkit/evals/hallucination/hallucination_evaluation.py,sha256=TuZ88jeVn0tVr9d0GhWyJSxKNA16nhvr2xRPo-yK8OM,3063
|
|
@@ -65,9 +66,11 @@ unique_toolkit/evaluators/hallucination/service.py,sha256=k8qro5Lw4Ak58m4HYp3G4H
|
|
|
65
66
|
unique_toolkit/evaluators/hallucination/utils.py,sha256=gO2AOzDQwVTev2_5vDKgJ9A6A9e0himJyAta_wglVG8,8326
|
|
66
67
|
unique_toolkit/evaluators/output_parser.py,sha256=eI72qkzK1dZyUvnfP2SOAQCGBj_-PwX5wy_aLPMsJMY,883
|
|
67
68
|
unique_toolkit/evaluators/schemas.py,sha256=Jaue6Uhx75X1CyHKWj8sT3RE1JZXTqoLtfLt2xQNCX8,2507
|
|
68
|
-
unique_toolkit/framework_utilities/
|
|
69
|
+
unique_toolkit/framework_utilities/__init__.py,sha256=fvAn9y4MRL1JgoO14ufQtLVRPRHn4jP07XRqt-TItCA,68
|
|
70
|
+
unique_toolkit/framework_utilities/langchain/client.py,sha256=9LDRS2l9XGxL0HoFLh0ZrFUXrlt8o_J-o-1rU8j-uMQ,1432
|
|
69
71
|
unique_toolkit/framework_utilities/langchain/history.py,sha256=R9RuCeSFNaUO3OZ0G_LmIC4gmOCIANcl91MfyWLnZ1c,650
|
|
70
|
-
unique_toolkit/framework_utilities/openai/
|
|
72
|
+
unique_toolkit/framework_utilities/openai/__init__.py,sha256=UDigDBIXPAfGgnaopg8Yvcr1S8RDbXyv3RsJDclAIGw,180
|
|
73
|
+
unique_toolkit/framework_utilities/openai/client.py,sha256=CiQjTq2erh8mPJ5gOSKUW4DUQqykB7Qhb9azjtOk1u8,1309
|
|
71
74
|
unique_toolkit/framework_utilities/openai/message_builder.py,sha256=VU6mJm_upLcarJQKFft_t1RlLRncWDxDuLC5LIJ5lQQ,4339
|
|
72
75
|
unique_toolkit/framework_utilities/utils.py,sha256=JK7g2yMfEx3eMprug26769xqNpS5WJcizf8n2zWMBng,789
|
|
73
76
|
unique_toolkit/history_manager/history_construction_with_contents.py,sha256=c8Zy3erSbHGT8AdICRRlSK91T_FN6tNpTznvUzpLbWk,9023
|
|
@@ -112,7 +115,7 @@ unique_toolkit/tools/utils/execution/execution.py,sha256=vjG2Y6awsGNtlvyQAGCTthQ
|
|
|
112
115
|
unique_toolkit/tools/utils/source_handling/schema.py,sha256=vzAyf6ZWNexjMO0OrnB8y2glGkvAilmGGQXd6zcDaKw,870
|
|
113
116
|
unique_toolkit/tools/utils/source_handling/source_formatting.py,sha256=C7uayNbdkNVJdEARA5CENnHtNY1SU6etlaqbgHNyxaQ,9152
|
|
114
117
|
unique_toolkit/tools/utils/source_handling/tests/test_source_formatting.py,sha256=oM5ZxEgzROrnX1229KViCAFjRxl9wCTzWZoinYSHleM,6979
|
|
115
|
-
unique_toolkit-0.8.
|
|
116
|
-
unique_toolkit-0.8.
|
|
117
|
-
unique_toolkit-0.8.
|
|
118
|
-
unique_toolkit-0.8.
|
|
118
|
+
unique_toolkit-0.8.25.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
|
|
119
|
+
unique_toolkit-0.8.25.dist-info/METADATA,sha256=VSgIOC7Zd7mtwd0Ay4azu35JH7TO-aKIqTusVDXX2cQ,28900
|
|
120
|
+
unique_toolkit-0.8.25.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
121
|
+
unique_toolkit-0.8.25.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|