seekrai 0.5.9__tar.gz → 0.5.12__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.
- {seekrai-0.5.9 → seekrai-0.5.12}/PKG-INFO +1 -1
- {seekrai-0.5.9 → seekrai-0.5.12}/pyproject.toml +1 -1
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/agents/agent_inference.py +21 -8
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/runs.py +48 -18
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/files.py +1 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/finetune.py +3 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/LICENSE +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/README.md +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/abstract/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/abstract/api_requestor.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/abstract/response_parsing.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/client.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/constants.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/error.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/filemanager.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/agents/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/agents/agents.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/agents/threads.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/alignment.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/chat/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/chat/completions.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/completions.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/deployments.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/embeddings.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/explainability.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/files.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/finetune.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/images.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/ingestion.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/models.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/projects.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/resource_base.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/resources/vectordb.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/seekrflow_response.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/abstract.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/agent.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/threads.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/env_model_config.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/schemas/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/schemas/file_search.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/schemas/file_search_env.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/schemas/run_python.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/schemas/run_python_env.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/schemas/web_search.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/schemas/web_search_env.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/tool.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/agents/tools/tool_types.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/alignment.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/chat_completions.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/common.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/completions.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/deployments.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/embeddings.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/error.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/explainability.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/images.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/ingestion.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/models.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/projects.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/types/vectordb.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/utils/__init__.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/utils/_log.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/utils/api_helpers.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/utils/files.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/utils/tools.py +0 -0
- {seekrai-0.5.9 → seekrai-0.5.12}/src/seekrai/version.py +0 -0
|
@@ -3,6 +3,7 @@ from typing import Any, AsyncGenerator, Iterator, Optional, Union
|
|
|
3
3
|
from seekrai.abstract import api_requestor
|
|
4
4
|
from seekrai.seekrflow_response import SeekrFlowResponse
|
|
5
5
|
from seekrai.types import ModelSettings, Run, RunRequest, RunResponse, SeekrFlowRequest
|
|
6
|
+
from seekrai.types.agents.runs import ResponseFormat
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class AgentInference:
|
|
@@ -16,7 +17,8 @@ class AgentInference:
|
|
|
16
17
|
thread_id: str,
|
|
17
18
|
*,
|
|
18
19
|
stream: bool = False,
|
|
19
|
-
model_settings:
|
|
20
|
+
model_settings: ModelSettings = ModelSettings(),
|
|
21
|
+
response_format: Optional[Any] = None,
|
|
20
22
|
) -> Union[RunResponse, Iterator[Any]]:
|
|
21
23
|
"""
|
|
22
24
|
Run an inference call on a deployed agent.
|
|
@@ -26,13 +28,18 @@ class AgentInference:
|
|
|
26
28
|
thread_id (str): A thread identifier.
|
|
27
29
|
stream (bool, optional): Whether to stream the response. Defaults to False.
|
|
28
30
|
model_settings (optional): Additional parameters (such as temperature, max_tokens, etc).
|
|
31
|
+
response_format: Optional structured output specification. If provided, the LLM will be constrained to return JSON matching this schema.
|
|
29
32
|
|
|
30
33
|
Returns:
|
|
31
34
|
A dictionary with the response (if non-streaming) or an iterator over response chunks.
|
|
32
35
|
"""
|
|
33
|
-
payload = RunRequest(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
payload = RunRequest(
|
|
37
|
+
agent_id=agent_id,
|
|
38
|
+
model_settings=model_settings,
|
|
39
|
+
response_format=ResponseFormat.from_value(response_format)
|
|
40
|
+
if response_format
|
|
41
|
+
else None,
|
|
42
|
+
).model_dump()
|
|
36
43
|
endpoint = f"threads/{thread_id}/runs"
|
|
37
44
|
if stream:
|
|
38
45
|
endpoint += "/stream"
|
|
@@ -147,7 +154,8 @@ class AsyncAgentInference:
|
|
|
147
154
|
thread_id: str,
|
|
148
155
|
*,
|
|
149
156
|
stream: bool = False,
|
|
150
|
-
model_settings:
|
|
157
|
+
model_settings: ModelSettings = ModelSettings(),
|
|
158
|
+
response_format: Optional[Any] = None,
|
|
151
159
|
) -> Union[RunResponse, AsyncGenerator[Any, None]]:
|
|
152
160
|
"""
|
|
153
161
|
Run an inference call on a deployed agent.
|
|
@@ -157,13 +165,18 @@ class AsyncAgentInference:
|
|
|
157
165
|
thread_id (str): A thread identifier.
|
|
158
166
|
stream (bool, optional): Whether to stream the response. Defaults to False.
|
|
159
167
|
model_settings (optional): Additional parameters (such as temperature, max_tokens, etc).
|
|
168
|
+
response_format: Optional structured output specification. If provided, the LLM will be constrained to return JSON matching this schema.
|
|
160
169
|
|
|
161
170
|
Returns:
|
|
162
171
|
A dictionary with the response (if non-streaming) or an iterator over response chunks.
|
|
163
172
|
"""
|
|
164
|
-
payload = RunRequest(
|
|
165
|
-
|
|
166
|
-
|
|
173
|
+
payload = RunRequest(
|
|
174
|
+
agent_id=agent_id,
|
|
175
|
+
model_settings=model_settings,
|
|
176
|
+
response_format=ResponseFormat.from_value(response_format)
|
|
177
|
+
if response_format
|
|
178
|
+
else None,
|
|
179
|
+
).model_dump()
|
|
167
180
|
endpoint = f"threads/{thread_id}/runs"
|
|
168
181
|
if stream:
|
|
169
182
|
endpoint += "/stream"
|
|
@@ -1,16 +1,63 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
from enum import Enum
|
|
3
|
-
from typing import Any, Optional, Union
|
|
3
|
+
from typing import Any, Dict, Optional, Union
|
|
4
4
|
|
|
5
|
+
import pydantic
|
|
5
6
|
from pydantic import Field
|
|
6
7
|
|
|
7
8
|
from seekrai.types.abstract import BaseModel
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
class ModelSettings(BaseModel):
|
|
12
|
+
"""Settings to use when calling an LLM.
|
|
13
|
+
|
|
14
|
+
This class holds optional model configuration parameters (e.g. temperature,
|
|
15
|
+
top_p, penalties, truncation, etc.).
|
|
16
|
+
|
|
17
|
+
Not all models/providers support all of these parameters, so please check the API documentation
|
|
18
|
+
for the specific model and provider you are using.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
temperature: float = Field(default=1.0, ge=0.0, le=2.0)
|
|
22
|
+
top_p: float = Field(default=1.0, ge=0.0, le=1.0)
|
|
23
|
+
frequency_penalty: float = Field(default=0.0, ge=-2.0, le=2.0)
|
|
24
|
+
presence_penalty: float = Field(default=0.0, ge=-2.0, le=2.0)
|
|
25
|
+
max_tokens: Optional[int] = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ResponseFormat(BaseModel):
|
|
29
|
+
"""Specifies a JSON schema for the response format.
|
|
30
|
+
|
|
31
|
+
When provided, the LLM will be constrained to return a JSON response
|
|
32
|
+
that matches the specified schema.
|
|
33
|
+
|
|
34
|
+
Can be instantiated with:
|
|
35
|
+
- A JSON schema dictionary
|
|
36
|
+
- A Pydantic model class
|
|
37
|
+
- An existing ResponseFormat instance
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
json_schema: Dict[str, Any]
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def from_value(cls, value: Any) -> "ResponseFormat":
|
|
44
|
+
if isinstance(value, cls):
|
|
45
|
+
return value
|
|
46
|
+
if isinstance(value, dict):
|
|
47
|
+
return cls(json_schema=value)
|
|
48
|
+
if isinstance(value, type) and issubclass(value, pydantic.BaseModel):
|
|
49
|
+
return cls(json_schema=value.model_json_schema())
|
|
50
|
+
raise ValueError(
|
|
51
|
+
"ResponseFormat configuration is invalid. Expected ResponseFormat, a valid schema or a Pydantic BaseModel."
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
10
55
|
class RunRequest(BaseModel):
|
|
11
56
|
"""Request model for creating a run."""
|
|
12
57
|
|
|
13
58
|
agent_id: str = Field(default="default_agent")
|
|
59
|
+
model_settings: ModelSettings = ModelSettings()
|
|
60
|
+
response_format: Optional[Union[ResponseFormat, Dict[str, Any], type]] = None
|
|
14
61
|
|
|
15
62
|
|
|
16
63
|
class RunResponse(BaseModel):
|
|
@@ -115,20 +162,3 @@ class RunStep(BaseModel):
|
|
|
115
162
|
completed_at: Optional[datetime.datetime] = None
|
|
116
163
|
meta_data: dict[str, Any] = Field(default_factory=dict)
|
|
117
164
|
usage: Optional[RunStepUsage] = None
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
class ModelSettings(BaseModel):
|
|
121
|
-
"""Settings to use when calling an LLM.
|
|
122
|
-
|
|
123
|
-
This class holds optional model configuration parameters (e.g. temperature,
|
|
124
|
-
top_p, penalties, truncation, etc.).
|
|
125
|
-
|
|
126
|
-
Not all models/providers support all of these parameters, so please check the API documentation
|
|
127
|
-
for the specific model and provider you are using.
|
|
128
|
-
"""
|
|
129
|
-
|
|
130
|
-
temperature: float = Field(default=1.0, ge=0.0, le=2.0)
|
|
131
|
-
top_p: float = Field(default=1.0, ge=0.0, le=1.0)
|
|
132
|
-
frequency_penalty: float = Field(default=0.0, ge=-2.0, le=2.0)
|
|
133
|
-
presence_penalty: float = Field(default=0.0, ge=-2.0, le=2.0)
|
|
134
|
-
max_tokens: Optional[int] = None
|
|
@@ -77,6 +77,7 @@ class FinetuneEventType(str, Enum):
|
|
|
77
77
|
class FineTuneType(str, Enum):
|
|
78
78
|
STANDARD = "STANDARD"
|
|
79
79
|
DPO = "DPO"
|
|
80
|
+
GRPO = "GRPO"
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
class FinetuneEvent(BaseModel):
|
|
@@ -108,6 +109,8 @@ class TrainingConfig(BaseModel):
|
|
|
108
109
|
batch_size: int = Field(..., ge=1, le=1024)
|
|
109
110
|
# up to 40 character suffix for output model name
|
|
110
111
|
experiment_name: str | None = None
|
|
112
|
+
# sequence length
|
|
113
|
+
max_length: int = 2500
|
|
111
114
|
# # weights & biases api key
|
|
112
115
|
# wandb_key: str | None = None
|
|
113
116
|
# IFT by default
|
|
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
|
|
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
|
|
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
|