agent-lab-sdk 0.1.14__py3-none-any.whl → 0.1.16__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.
Potentially problematic release.
This version of agent-lab-sdk might be problematic. Click here for more details.
- agent_lab_sdk/schema/__init__.py +24 -1
- agent_lab_sdk/schema/input_types.py +193 -0
- agent_lab_sdk-0.1.16.dist-info/METADATA +352 -0
- {agent_lab_sdk-0.1.14.dist-info → agent_lab_sdk-0.1.16.dist-info}/RECORD +7 -6
- agent_lab_sdk-0.1.14.dist-info/METADATA +0 -65
- {agent_lab_sdk-0.1.14.dist-info → agent_lab_sdk-0.1.16.dist-info}/WHEEL +0 -0
- {agent_lab_sdk-0.1.14.dist-info → agent_lab_sdk-0.1.16.dist-info}/licenses/LICENSE +0 -0
- {agent_lab_sdk-0.1.14.dist-info → agent_lab_sdk-0.1.16.dist-info}/top_level.txt +0 -0
agent_lab_sdk/schema/__init__.py
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
1
|
from .log_message import LogMessage
|
|
2
|
-
|
|
2
|
+
from .input_types import (
|
|
3
|
+
MainInput,
|
|
4
|
+
StringInput,
|
|
5
|
+
StringArrayInput,
|
|
6
|
+
NumberInput,
|
|
7
|
+
SelectInput,
|
|
8
|
+
CheckboxInput,
|
|
9
|
+
FileInput,
|
|
10
|
+
FilesInput,
|
|
11
|
+
SelectOption
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"LogMessage",
|
|
16
|
+
"MainInput",
|
|
17
|
+
"StringInput",
|
|
18
|
+
"StringArrayInput",
|
|
19
|
+
"NumberInput",
|
|
20
|
+
"SelectInput",
|
|
21
|
+
"CheckboxInput",
|
|
22
|
+
"FileInput",
|
|
23
|
+
"FilesInput",
|
|
24
|
+
"SelectOption"
|
|
25
|
+
]
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
from typing import List, Optional, Any
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
from pydantic.json_schema import WithJsonSchema
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def MainInput(placeholder: str | None = None) -> type:
|
|
7
|
+
"""
|
|
8
|
+
Factory function for creating a main input type with optional placeholder.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
placeholder: Optional placeholder text for the input field
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
Type annotation for main input field
|
|
15
|
+
"""
|
|
16
|
+
return WithJsonSchema({
|
|
17
|
+
"type": "main-input",
|
|
18
|
+
"placeholder": placeholder,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def StringInput(default: str | None = None, title: str | None = None, description: str | None = None, hidden: bool | None = False) -> type:
|
|
23
|
+
"""
|
|
24
|
+
Factory function for creating a string input type.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
default: Default value for the string input
|
|
28
|
+
title: Title for the string input
|
|
29
|
+
description: Description text for the string input
|
|
30
|
+
hidden: Whether the input should be hidden in the UI
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Type annotation for string input field
|
|
34
|
+
"""
|
|
35
|
+
return WithJsonSchema({
|
|
36
|
+
"type": "input-string",
|
|
37
|
+
"default": default,
|
|
38
|
+
"title": title,
|
|
39
|
+
"description": description,
|
|
40
|
+
"hidden": hidden,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def StringArrayInput(placeholder: str | None = None, title: str | None = None, description: str | None = None, group: str | None = None, hidden: bool | None = False) -> type:
|
|
45
|
+
"""
|
|
46
|
+
Factory function for creating a string array input type.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
placeholder: Placeholder text for the input field
|
|
50
|
+
title: Title for the string array input
|
|
51
|
+
description: Description text for the string array input
|
|
52
|
+
group: Group name for organizing inputs in the UI
|
|
53
|
+
hidden: Whether the input should be hidden in the UI
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
Type annotation for string array input field
|
|
57
|
+
"""
|
|
58
|
+
return WithJsonSchema({
|
|
59
|
+
"type": "string[]-inline",
|
|
60
|
+
"placeholder": placeholder,
|
|
61
|
+
"title": title,
|
|
62
|
+
"description": description,
|
|
63
|
+
"group": group,
|
|
64
|
+
"hidden": hidden,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def NumberInput(default: float | None = None, title: str | None = None, description: str | None = None, hidden: bool | None = False) -> type:
|
|
69
|
+
"""
|
|
70
|
+
Factory function for creating a number input type.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
default: Default value for the number input
|
|
74
|
+
title: Title for the number input
|
|
75
|
+
description: Description text for the number input
|
|
76
|
+
hidden: Whether the input should be hidden in the UI
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Type annotation for number input field
|
|
80
|
+
"""
|
|
81
|
+
return WithJsonSchema({
|
|
82
|
+
"type": "input-number",
|
|
83
|
+
"default": default,
|
|
84
|
+
"title": title,
|
|
85
|
+
"description": description,
|
|
86
|
+
"hidden": hidden,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class SelectOption(BaseModel):
|
|
91
|
+
"""
|
|
92
|
+
Model representing an option in a select input.
|
|
93
|
+
|
|
94
|
+
Attributes:
|
|
95
|
+
label: Display label for the option
|
|
96
|
+
value: Actual value of the option
|
|
97
|
+
description: Optional description for the option
|
|
98
|
+
"""
|
|
99
|
+
label: str
|
|
100
|
+
value: str
|
|
101
|
+
description: Optional[str] = None
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def SelectInput(items: List[Any] = [], title: str | None = None, group: str | None = None, default: str | None = None, hidden: bool | None = False) -> type:
|
|
105
|
+
"""
|
|
106
|
+
Factory function for creating a select input type.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
items: List of SelectOption objects or dictionaries
|
|
110
|
+
title: Title for the select input
|
|
111
|
+
group: Group name for organizing inputs in the UI
|
|
112
|
+
default: Default selected value
|
|
113
|
+
hidden: Whether the input should be hidden in the UI
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Type annotation for select input field
|
|
117
|
+
"""
|
|
118
|
+
return WithJsonSchema({
|
|
119
|
+
"type": "select",
|
|
120
|
+
"title": title,
|
|
121
|
+
"items": items,
|
|
122
|
+
"group": group,
|
|
123
|
+
"default": default,
|
|
124
|
+
"hidden": hidden,
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def CheckboxInput(title: str | None = None, group: str | None = None, description: str | None = None, default: bool | None = False, hidden: bool | None = False) -> type:
|
|
129
|
+
"""
|
|
130
|
+
Factory function for creating a checkbox input type.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
title: Title for the checkbox
|
|
134
|
+
group: Group name for organizing inputs in the UI
|
|
135
|
+
description: Description text for the checkbox
|
|
136
|
+
default: Default checked state
|
|
137
|
+
hidden: Whether the input should be hidden in the UI
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
Type annotation for checkbox input field
|
|
141
|
+
"""
|
|
142
|
+
return WithJsonSchema({
|
|
143
|
+
"type": "checkbox",
|
|
144
|
+
"title": title,
|
|
145
|
+
"group": group,
|
|
146
|
+
"description": description,
|
|
147
|
+
"default": default,
|
|
148
|
+
"hidden": hidden,
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def FileInput(title: str | None = None, file_extensions: str | None = None, group: str | None = None, hidden: bool | None = False) -> type:
|
|
153
|
+
"""
|
|
154
|
+
Factory function for creating a single file input type.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
title: Title for the file input
|
|
158
|
+
file_extensions: Comma-separated list of allowed file extensions (e.g., ".pdf,.txt")
|
|
159
|
+
group: Group name for organizing inputs in the UI
|
|
160
|
+
hidden: Whether the input should be hidden in the UI
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
Type annotation for file input field
|
|
164
|
+
"""
|
|
165
|
+
return WithJsonSchema({
|
|
166
|
+
"type": "files",
|
|
167
|
+
"title": title,
|
|
168
|
+
"fileExtensions": file_extensions,
|
|
169
|
+
"group": group,
|
|
170
|
+
"hidden": hidden,
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def FilesInput(title: str | None = None, file_extensions: str | None = None, group: str | None = None, hidden: bool | None = False) -> type:
|
|
175
|
+
"""
|
|
176
|
+
Factory function for creating a multiple files input type.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
title: Title for the files input
|
|
180
|
+
file_extensions: Comma-separated list of allowed file extensions (e.g., ".pdf,.txt")
|
|
181
|
+
group: Group name for organizing inputs in the UI
|
|
182
|
+
hidden: Whether the input should be hidden in the UI
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
Type annotation for files input field
|
|
186
|
+
"""
|
|
187
|
+
return WithJsonSchema({
|
|
188
|
+
"type": "files",
|
|
189
|
+
"title": title,
|
|
190
|
+
"fileExtensions": file_extensions,
|
|
191
|
+
"group": group,
|
|
192
|
+
"hidden": hidden,
|
|
193
|
+
})
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-lab-sdk
|
|
3
|
+
Version: 0.1.16
|
|
4
|
+
Summary: SDK для работы с Agent Lab
|
|
5
|
+
Author-email: Andrew Ohurtsov <andermirik@yandex.com>
|
|
6
|
+
License: Proprietary and Confidential — All Rights Reserved
|
|
7
|
+
Keywords: agent,lab,sdk
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: License :: Other/Proprietary License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Requires-Python: <4.0,>=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: requests
|
|
22
|
+
Requires-Dist: langgraph~=0.4.1
|
|
23
|
+
Requires-Dist: langchain_gigachat
|
|
24
|
+
Requires-Dist: prometheus-client
|
|
25
|
+
Requires-Dist: langchain
|
|
26
|
+
Requires-Dist: httpx~=0.27.2
|
|
27
|
+
Requires-Dist: orjson>=3.9.7
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Agent Lab SDK
|
|
31
|
+
|
|
32
|
+
Набор утилит и обёрток для упрощённой работы с LLM, Agent Gateway и метриками в проектах Giga Labs.
|
|
33
|
+
|
|
34
|
+
## Установка
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install agent_lab_sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Содержание
|
|
41
|
+
|
|
42
|
+
1. [Модуль `agent_lab_sdk.llm`](#1-модуль-agent_lab_sdkllm)
|
|
43
|
+
2. [Модуль `agent_lab_sdk.llm.throttled`](#2-модуль-agent_lab_sdkllmthrottled)
|
|
44
|
+
3. [Модуль `agent_lab_sdk.metrics`](#3-модуль-agent_lab_sdkmetrics)
|
|
45
|
+
4. [Хранилище](#4-хранилище)
|
|
46
|
+
5. [Схема](#5-схема)
|
|
47
|
+
6. [Сборка и публикация](#6-сборка-и-публикация)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 1. Модуль `agent_lab_sdk.llm`
|
|
52
|
+
|
|
53
|
+
### 1.1. Получение модели
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from agent_lab_sdk.llm import get_model
|
|
57
|
+
|
|
58
|
+
# Использует токен из окружения по умолчанию
|
|
59
|
+
model = get_model()
|
|
60
|
+
|
|
61
|
+
# Передача явных параметров
|
|
62
|
+
model = get_model(
|
|
63
|
+
access_token="YOUR_TOKEN",
|
|
64
|
+
timeout=60,
|
|
65
|
+
scope="GIGACHAT_API_CORP"
|
|
66
|
+
)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> если не передавать access_token, токен будет выбран через GigaChatTokenManager
|
|
70
|
+
|
|
71
|
+
### 1.2. Менеджеры токенов
|
|
72
|
+
|
|
73
|
+
| Класс | Описание | Пример использования |
|
|
74
|
+
| ---------------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
75
|
+
| `AgwTokenManager` | Кеширование + получение токена через Agent Gateway | `token = AgwTokenManager.get_token("provider")` |
|
|
76
|
+
| `GigaChatTokenManager` | Кеширование + получение через GigaChat OAuth с использованием пользовательских секретов | `token = GigaChatTokenManager.get_token()` |
|
|
77
|
+
|
|
78
|
+
### 1.3. Переменные окружения
|
|
79
|
+
|
|
80
|
+
| Переменная | Описание | Значение по умолчанию / Пример |
|
|
81
|
+
| ---------------------------------------- | -------------------------------------------------------- | --------------------------------------------------- |
|
|
82
|
+
| `GIGACHAT_SCOPE` | Scope GigaChat API | `GIGACHAT_API_PERS` |
|
|
83
|
+
| `GLOBAL_GIGACHAT_TIMEOUT` | Таймаут запросов к GigaChat (секунды) | `120` |
|
|
84
|
+
| `USE_TOKEN_PROVIDER_AGW` | Использовать `AgwTokenManager` | `true` |
|
|
85
|
+
| `GIGACHAT_CREDENTIALS` | Базовые креды для GigaChat (`b64(clientId:secretId)`) | `Y2xpZW50SWQ6c2VjcmV0SWQ=` |
|
|
86
|
+
| `GIGACHAT_TOKEN_PATH` | Путь к файлу кеша токена GigaChat | `/tmp/gigachat_token.json` |
|
|
87
|
+
| `GIGACHAT_TOKEN_FETCH_RETRIES` | Количество попыток получения токена (GigaChat) | `3` |
|
|
88
|
+
| `USE_GIGACHAT_ADVANCED` | Включает запрос токена GigaChat API в продвинутом режиме | `true` |
|
|
89
|
+
| `GIGACHAT_BASE_URL` | Базовый URL GigaChat для расширенного режима | `https://ngw.devices.sberbank.ru:9443/api/v2/oauth` |
|
|
90
|
+
| `TOKEN_PROVIDER_AGW_URL` | URL Agent Gateway для получения AGW-токена | `https://agent-gateway.apps.advosd.sberdevices.ru` |
|
|
91
|
+
| `TOKEN_PROVIDER_AGW_DEFAULT_MAX_RETRIES` | Макс. попыток запроса токена (AGW) | `3` |
|
|
92
|
+
| `TOKEN_PROVIDER_AGW_TIMEOUT_SEC` | Таймаут запроса к AGW (секунды) | `5` |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 2. Модуль `agent_lab_sdk.llm.throttled`
|
|
97
|
+
|
|
98
|
+
Позволяет ограничивать число одновременных вызовов к GigaChat и сервису эмбеддингов, автоматически собирая соответствующие метрики.
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from agent_lab_sdk.llm import GigaChatTokenManager
|
|
102
|
+
from agent_lab_sdk.llm.throttled import ThrottledGigaChat, ThrottledGigaChatEmbeddings
|
|
103
|
+
|
|
104
|
+
access_token = GigaChatTokenManager.get_token()
|
|
105
|
+
|
|
106
|
+
# Чат с учётом ограничений
|
|
107
|
+
chat = ThrottledGigaChat(access_token=access_token)
|
|
108
|
+
response = chat.invoke("Привет!")
|
|
109
|
+
|
|
110
|
+
# Эмбеддинги с учётом ограничений
|
|
111
|
+
emb = ThrottledGigaChatEmbeddings(access_token=access_token)
|
|
112
|
+
vectors = emb.embed_documents(["Text1", "Text2"])
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 2.1. Переменные окружения для ограничения
|
|
116
|
+
|
|
117
|
+
| Переменная | Описание | Значение по умолчанию |
|
|
118
|
+
| --------------------------------- | ------------------------------------------- | --------------------- |
|
|
119
|
+
| `MAX_CHAT_CONCURRENCY` | Максимум одновременных чат-запросов | `100000` |
|
|
120
|
+
| `MAX_EMBED_CONCURRENCY` | Максимум одновременных запросов эмбеддингов | `100000` |
|
|
121
|
+
| `EMBEDDINGS_MAX_BATCH_SIZE_PARTS` | Макс. размер батча частей для эмбеддингов | `90` |
|
|
122
|
+
|
|
123
|
+
### 2.2. Метрики
|
|
124
|
+
|
|
125
|
+
Метрики доступны через `agent_lab_sdk.metrics.get_metric`:
|
|
126
|
+
|
|
127
|
+
| Метрика | Описание | Тип |
|
|
128
|
+
| ------------------------- | ---------------------------------------------- | --------- |
|
|
129
|
+
| `chat_slots_in_use` | Число занятых слотов для чата | Gauge |
|
|
130
|
+
| `chat_waiting_tasks` | Число задач, ожидающих освобождения слота чата | Gauge |
|
|
131
|
+
| `chat_wait_time_seconds` | Время ожидания слота чата (секунды) | Histogram |
|
|
132
|
+
| `embed_slots_in_use` | Число занятых слотов для эмбеддингов | Gauge |
|
|
133
|
+
| `embed_waiting_tasks` | Число задач, ожидающих слота эмбеддингов | Gauge |
|
|
134
|
+
| `embed_wait_time_seconds` | Время ожидания слота эмбеддингов (секунды) | Histogram |
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 3. Модуль `agent_lab_sdk.metrics`
|
|
139
|
+
|
|
140
|
+
Предоставляет удобный интерфейс для создания и управления метриками через Prometheus-клиент.
|
|
141
|
+
|
|
142
|
+
### 3.1. Основные функции
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from agent_lab_sdk.metrics import get_metric
|
|
146
|
+
|
|
147
|
+
# Создать метрику
|
|
148
|
+
g = get_metric(
|
|
149
|
+
metric_type="gauge", # тип: "gauge", "counter" или "histogram"
|
|
150
|
+
name="my_gauge", # имя метрики в Prometheus
|
|
151
|
+
documentation="Моя метрика gauge" # описание
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# Увеличить счётчик
|
|
155
|
+
g.inc()
|
|
156
|
+
|
|
157
|
+
# Установить конкретное значение
|
|
158
|
+
g.set(42)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 3.2. Пример использования в коде
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from agent_lab_sdk.metrics import get_metric
|
|
165
|
+
import time
|
|
166
|
+
|
|
167
|
+
# Счётчик HTTP-запросов с метками
|
|
168
|
+
reqs = get_metric(
|
|
169
|
+
metric_type="counter",
|
|
170
|
+
name="http_requests_total",
|
|
171
|
+
documentation="Всего HTTP-запросов",
|
|
172
|
+
labelnames=["method", "endpoint"]
|
|
173
|
+
)
|
|
174
|
+
reqs.labels("GET", "/api").inc()
|
|
175
|
+
|
|
176
|
+
# Гистограмма задержек
|
|
177
|
+
lat = get_metric(
|
|
178
|
+
metric_type="histogram",
|
|
179
|
+
name="http_request_latency_seconds",
|
|
180
|
+
documentation="Длительность HTTP-запроса",
|
|
181
|
+
buckets=[0.1, 0.5, 1.0, 5.0]
|
|
182
|
+
)
|
|
183
|
+
with lat.time():
|
|
184
|
+
time.sleep(0.5)
|
|
185
|
+
|
|
186
|
+
print(reqs.collect())
|
|
187
|
+
print(lat.collect())
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## 4. Хранилище
|
|
191
|
+
|
|
192
|
+
### 4.1 SD Ассетница
|
|
193
|
+
|
|
194
|
+
функция `store_file_in_sd_asset` сохраняет base64‑файл в хранилище S3 и отдаёт публичную ссылку на файл
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
from agent_lab_sdk.storage import store_file_in_sd_asset
|
|
198
|
+
|
|
199
|
+
store_file_in_storage("my-agent-name-filename.png", file_b64, "giga-agents")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### 4.2 AGW Checkpointer
|
|
203
|
+
|
|
204
|
+
AGW поддерживает langgraph checkpoint API и в SDK представлен `AsyncAGWCheckpointSaver`, который позволяет сохранять состояние графа в AGW напрямую.
|
|
205
|
+
|
|
206
|
+
## 5. Схема
|
|
207
|
+
|
|
208
|
+
### 5.1. Типы входных данных
|
|
209
|
+
|
|
210
|
+
Модуль `agent_lab_sdk.schema.input_types` предоставляет фабричные функции для создания аннотированных типов полей, которые могут использоваться в Pydantic моделях для описания интерфейса агентов.
|
|
211
|
+
|
|
212
|
+
#### Основные типы полей
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
from typing import List, Annotated
|
|
216
|
+
from pydantic import BaseModel, Field
|
|
217
|
+
from agent_lab_sdk.schema import (
|
|
218
|
+
MainInput, StringInput, StringArrayInput, NumberInput,
|
|
219
|
+
SelectInput, CheckboxInput, FileInput, FilesInput, SelectOption
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
class AgentState(BaseModel):
|
|
223
|
+
# Основное поле ввода
|
|
224
|
+
query: Annotated[str, MainInput(placeholder="Введите ваш запрос")]
|
|
225
|
+
|
|
226
|
+
# Строковое поле
|
|
227
|
+
title: Annotated[str, StringInput(
|
|
228
|
+
default="Без названия",
|
|
229
|
+
title="Заголовок",
|
|
230
|
+
description="Название для вашего запроса"
|
|
231
|
+
)]
|
|
232
|
+
|
|
233
|
+
# Массив строк
|
|
234
|
+
keywords: Annotated[List[str], StringArrayInput(
|
|
235
|
+
placeholder="Добавьте ключевые слова...",
|
|
236
|
+
title="Ключевые слова",
|
|
237
|
+
description="Список ключевых слов для поиска",
|
|
238
|
+
group="Параметры"
|
|
239
|
+
)]
|
|
240
|
+
|
|
241
|
+
# Числовое поле
|
|
242
|
+
temperature: Annotated[float, NumberInput(
|
|
243
|
+
default=0.7,
|
|
244
|
+
title="Температура",
|
|
245
|
+
description="Параметр креативности модели (0.0 - 1.0)",
|
|
246
|
+
hidden=True
|
|
247
|
+
)]
|
|
248
|
+
|
|
249
|
+
# Выпадающий список
|
|
250
|
+
mode: Annotated[str, SelectInput(
|
|
251
|
+
title="Режим работы",
|
|
252
|
+
items=[
|
|
253
|
+
SelectOption(label="Быстрый", value="fast").model_dump(),
|
|
254
|
+
SelectOption(label="Точный", value="precise").model_dump()
|
|
255
|
+
],
|
|
256
|
+
default="fast",
|
|
257
|
+
group="Настройки"
|
|
258
|
+
)]
|
|
259
|
+
|
|
260
|
+
# Чекбокс
|
|
261
|
+
save_history: Annotated[bool, CheckboxInput(
|
|
262
|
+
title="Сохранять историю",
|
|
263
|
+
description="Сохранять диалог для последующего анализа",
|
|
264
|
+
default=True,
|
|
265
|
+
group="Опции"
|
|
266
|
+
)]
|
|
267
|
+
|
|
268
|
+
# Загрузка одного файла
|
|
269
|
+
document: Annotated[str, FileInput(
|
|
270
|
+
title="Документ",
|
|
271
|
+
file_extensions=".pdf,.docx,.txt"
|
|
272
|
+
)]
|
|
273
|
+
|
|
274
|
+
# Загрузка нескольких файлов
|
|
275
|
+
attachments: Annotated[List[str], FilesInput(
|
|
276
|
+
title="Прикрепленные файлы",
|
|
277
|
+
file_extensions=".pdf,.csv,.xlsx",
|
|
278
|
+
group="Файлы"
|
|
279
|
+
)]
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
#### Доступные фабричные функции
|
|
283
|
+
|
|
284
|
+
| Тип | Описание | Основные параметры |
|
|
285
|
+
|--------------------| ------------------------------------- | ----------------------------------------------------- |
|
|
286
|
+
| `MainInput` | Основное поле ввода | `placeholder` |
|
|
287
|
+
| `StringInput` | Текстовое поле | `default`, `title`, `description`, `hidden` |
|
|
288
|
+
| `StringArrayInput` | Массив строк | `placeholder`, `title`, `description`, `group`, `hidden` |
|
|
289
|
+
| `NumberInput` | Числовое поле | `default`, `title`, `description`, `hidden` |
|
|
290
|
+
| `SelectInput` | Выпадающий список | `items`, `title`, `group`, `default`, `hidden` |
|
|
291
|
+
| `CheckboxInput` | Чекбокс | `title`, `group`, `description`, `default`, `hidden` |
|
|
292
|
+
| `FileInput` | Загрузка одного файла | `title`, `file_extensions`, `group`, `hidden` |
|
|
293
|
+
| `FilesInput` | Загрузка нескольких файлов | `title`, `file_extensions`, `group`, `hidden` |
|
|
294
|
+
|
|
295
|
+
#### Группировка полей
|
|
296
|
+
|
|
297
|
+
Используйте параметр `group` для логической группировки полей в интерфейсе:
|
|
298
|
+
|
|
299
|
+
```python
|
|
300
|
+
class TaskConfig(BaseModel):
|
|
301
|
+
# Группа "Основные параметры"
|
|
302
|
+
task_type: Annotated[str, SelectInput(
|
|
303
|
+
title="Тип задачи",
|
|
304
|
+
items=[...],
|
|
305
|
+
group="Основные параметры"
|
|
306
|
+
)]
|
|
307
|
+
|
|
308
|
+
priority: Annotated[str, SelectInput(
|
|
309
|
+
title="Приоритет",
|
|
310
|
+
items=[...],
|
|
311
|
+
group="Основные параметры"
|
|
312
|
+
)]
|
|
313
|
+
|
|
314
|
+
# Группа "Дополнительно"
|
|
315
|
+
notifications: Annotated[bool, CheckboxInput(
|
|
316
|
+
title="Уведомления",
|
|
317
|
+
group="Дополнительно"
|
|
318
|
+
)]
|
|
319
|
+
|
|
320
|
+
tags: Annotated[List[str], StringArrayInput(
|
|
321
|
+
placeholder="Теги...",
|
|
322
|
+
group="Дополнительно"
|
|
323
|
+
)]
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### 5.2. LogMessage
|
|
327
|
+
|
|
328
|
+
TODO: описание LogMessage
|
|
329
|
+
|
|
330
|
+
## 6. Сборка и публикация
|
|
331
|
+
|
|
332
|
+
1. Установка twine
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
pip install --upgrade build twine
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
2. Собрать и загрузить в pypi
|
|
339
|
+
|
|
340
|
+
перед обновлением сборки нужно не забыть поменять версию в [pyproject.toml](/pyproject.toml)
|
|
341
|
+
```bash
|
|
342
|
+
python -m build && python -m twine upload dist/*
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
3. Ссылка на проект pypi
|
|
346
|
+
|
|
347
|
+
> https://pypi.org/project/agent-lab-sdk/
|
|
348
|
+
|
|
349
|
+
4. установка локально в editable mode. Предварительно может потребоваться выбрать необходимое окружение
|
|
350
|
+
```bash
|
|
351
|
+
pip install -e .
|
|
352
|
+
```
|
|
@@ -8,12 +8,13 @@ agent_lab_sdk/llm/llm.py,sha256=NOEH9TOH66EIJXGevxPm6w6px7Z0cZl9DJ-9A7jOnd0,873
|
|
|
8
8
|
agent_lab_sdk/llm/throttled.py,sha256=9_nm1i3Uuep0VEWsY1KNCllZA-vM202XVdlgXhgC8BA,7005
|
|
9
9
|
agent_lab_sdk/metrics/__init__.py,sha256=G4VSlzKwupPMM4c6vZaF1rnd0KusKarezDMjli9pVFw,57
|
|
10
10
|
agent_lab_sdk/metrics/metrics.py,sha256=2e0c7BanThUNtCxpS6BUlAIDoLSidQsuaaBP5EB48Yo,3432
|
|
11
|
-
agent_lab_sdk/schema/__init__.py,sha256=
|
|
11
|
+
agent_lab_sdk/schema/__init__.py,sha256=RJW9WaZyyF4TT-rxHJMb9iq40yYYZoCcmUWVtOefQz4,427
|
|
12
|
+
agent_lab_sdk/schema/input_types.py,sha256=mL-gkZ0SohdzWzHZyemomG0NIl3NcnJ2UAuXAFTnhLY,6097
|
|
12
13
|
agent_lab_sdk/schema/log_message.py,sha256=nadi6lZGRuDSPmfbYs9QPpRJUT9Pfy8Y7pGCvyFF5Mw,638
|
|
13
14
|
agent_lab_sdk/storage/__init__.py,sha256=ik1_v1DMTwehvcAEXIYxuvLuCjJCa3y5qAuJqoQpuSA,81
|
|
14
15
|
agent_lab_sdk/storage/storage.py,sha256=ELpt7GRwFD-aWa6ctinfA_QwcvzWLvKS0Wz8FlxVqAs,2075
|
|
15
|
-
agent_lab_sdk-0.1.
|
|
16
|
-
agent_lab_sdk-0.1.
|
|
17
|
-
agent_lab_sdk-0.1.
|
|
18
|
-
agent_lab_sdk-0.1.
|
|
19
|
-
agent_lab_sdk-0.1.
|
|
16
|
+
agent_lab_sdk-0.1.16.dist-info/licenses/LICENSE,sha256=_TRXHkF3S9ilWBPdZcHLI_S-PRjK0L_SeOb2pcPAdV4,417
|
|
17
|
+
agent_lab_sdk-0.1.16.dist-info/METADATA,sha256=YwTbxw0__wp5ssCOquC3KhaOjCgNGDD9TVE7hvvm9A8,15949
|
|
18
|
+
agent_lab_sdk-0.1.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
agent_lab_sdk-0.1.16.dist-info/top_level.txt,sha256=E1efqkJ89KNmPBWdLzdMHeVtH0dYyCo4fhnSb81_15I,14
|
|
20
|
+
agent_lab_sdk-0.1.16.dist-info/RECORD,,
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: agent-lab-sdk
|
|
3
|
-
Version: 0.1.14
|
|
4
|
-
Summary: SDK для работы с Agent Lab
|
|
5
|
-
Author-email: Andrew Ohurtsov <andermirik@yandex.com>
|
|
6
|
-
License: Proprietary and Confidential — All Rights Reserved
|
|
7
|
-
Keywords: agent,lab,sdk
|
|
8
|
-
Classifier: Development Status :: 4 - Beta
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
11
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: License :: Other/Proprietary License
|
|
17
|
-
Classifier: Operating System :: OS Independent
|
|
18
|
-
Requires-Python: <4.0,>=3.11
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
License-File: LICENSE
|
|
21
|
-
Requires-Dist: requests
|
|
22
|
-
Requires-Dist: langgraph~=0.4.1
|
|
23
|
-
Requires-Dist: langchain_gigachat
|
|
24
|
-
Requires-Dist: prometheus-client
|
|
25
|
-
Requires-Dist: langchain
|
|
26
|
-
Requires-Dist: httpx~=0.27.2
|
|
27
|
-
Requires-Dist: orjson>=3.9.7
|
|
28
|
-
Dynamic: license-file
|
|
29
|
-
|
|
30
|
-
# Agent Lab SDK
|
|
31
|
-
|
|
32
|
-
Набор утилит и обёрток для работы с LLM, AGW и метриками в проектах Agent Lab.
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
1. Установка twine
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
pip install --upgrade build twine
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
2. Собрать и загрузить в pypi
|
|
43
|
-
|
|
44
|
-
перед обновлением сборки нужно не забыть поменять версию в pyproject.toml
|
|
45
|
-
```
|
|
46
|
-
python -m build && python -m twine upload dist/*
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
3. Ссылка на проект pypi
|
|
50
|
-
|
|
51
|
-
> https://pypi.org/project/agent-lab-sdk/
|
|
52
|
-
|
|
53
|
-
4. установка локально
|
|
54
|
-
```
|
|
55
|
-
pip install -e .
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
5. установка из интернета
|
|
59
|
-
```
|
|
60
|
-
pip install agent-lab-sdk
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
# Примеры использования
|
|
64
|
-
|
|
65
|
-
TBD
|
|
File without changes
|
|
File without changes
|
|
File without changes
|