airia 0.1.25__py3-none-any.whl → 0.1.26__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.
- airia/client/_request_handler/async_request_handler.py +29 -8
- airia/client/_request_handler/sync_request_handler.py +25 -8
- airia/client/async_client.py +4 -0
- airia/client/models/__init__.py +4 -0
- airia/client/models/async_models.py +96 -0
- airia/client/models/base_models.py +68 -0
- airia/client/models/sync_models.py +96 -0
- airia/client/pipeline_execution/async_pipeline_execution.py +3 -3
- airia/client/pipeline_execution/base_pipeline_execution.py +1 -1
- airia/client/pipeline_execution/sync_pipeline_execution.py +3 -3
- airia/client/pipeline_import/__init__.py +4 -0
- airia/client/pipeline_import/async_pipeline_import.py +147 -0
- airia/client/pipeline_import/base_pipeline_import.py +95 -0
- airia/client/pipeline_import/sync_pipeline_import.py +143 -0
- airia/client/sync_client.py +4 -0
- airia/exceptions.py +4 -3
- airia/types/api/__init__.py +2 -0
- airia/types/api/models/__init__.py +13 -0
- airia/types/api/models/list_models.py +129 -0
- airia/types/api/pipeline_import/__init__.py +11 -0
- airia/types/api/pipeline_import/create_agent_from_pipeline_definition.py +108 -0
- {airia-0.1.25.dist-info → airia-0.1.26.dist-info}/METADATA +1 -1
- {airia-0.1.25.dist-info → airia-0.1.26.dist-info}/RECORD +26 -14
- {airia-0.1.25.dist-info → airia-0.1.26.dist-info}/WHEEL +0 -0
- {airia-0.1.25.dist-info → airia-0.1.26.dist-info}/licenses/LICENSE +0 -0
- {airia-0.1.25.dist-info → airia-0.1.26.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
from typing import Any, Dict, Literal, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.pipeline_import import CreateAgentFromPipelineDefinitionResponse
|
|
5
|
+
from .._request_handler import AsyncRequestHandler
|
|
6
|
+
from .base_pipeline_import import BasePipelineImport
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncPipelineImport(BasePipelineImport):
|
|
10
|
+
def __init__(self, request_handler: AsyncRequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
async def create_agent_from_pipeline_definition(
|
|
14
|
+
self,
|
|
15
|
+
pipeline_definition: Dict[str, Any],
|
|
16
|
+
agent_import_source: Optional[
|
|
17
|
+
Literal[
|
|
18
|
+
"PlatformApi",
|
|
19
|
+
"ChatCommunity",
|
|
20
|
+
"PlatformCommunity",
|
|
21
|
+
"PlatformJson",
|
|
22
|
+
"Marketplace",
|
|
23
|
+
]
|
|
24
|
+
] = None,
|
|
25
|
+
conflict_resolution_strategy: Literal[
|
|
26
|
+
"SkipConflictingEntities",
|
|
27
|
+
"RecreateExistingEntities",
|
|
28
|
+
"SeededAgent",
|
|
29
|
+
] = "SkipConflictingEntities",
|
|
30
|
+
credential_mappings: Optional[Dict[str, str]] = None,
|
|
31
|
+
default_project_behavior: Optional[
|
|
32
|
+
Literal["Library", "BrainFreezeThenDefault", "DefaultProject"]
|
|
33
|
+
] = None,
|
|
34
|
+
project_id: Optional[str] = None,
|
|
35
|
+
correlation_id: Optional[str] = None,
|
|
36
|
+
) -> CreateAgentFromPipelineDefinitionResponse:
|
|
37
|
+
"""
|
|
38
|
+
Create an agent from a pipeline definition (async).
|
|
39
|
+
|
|
40
|
+
This method imports a complete pipeline from a definition dictionary,
|
|
41
|
+
creating all necessary components including data sources, prompts, tools,
|
|
42
|
+
models, and pipeline steps. The definition structure should match the
|
|
43
|
+
format returned by export_pipeline_definition(), but use JSON-compatible
|
|
44
|
+
types (no enums or Pydantic classes).
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
pipeline_definition (dict): The pipeline definition to import. This should
|
|
48
|
+
be a dictionary with the same structure as the response from
|
|
49
|
+
pipelines_config.export_pipeline_definition(), but using only
|
|
50
|
+
JSON-compatible types (strings, numbers, dicts, lists).
|
|
51
|
+
agent_import_source (str, optional): The source of the agent import.
|
|
52
|
+
Valid values: "PlatformApi", "ChatCommunity", "PlatformCommunity",
|
|
53
|
+
"PlatformJson", "Marketplace". If not provided, the import source
|
|
54
|
+
will not be specified.
|
|
55
|
+
conflict_resolution_strategy (str): Strategy for handling conflicting entities.
|
|
56
|
+
Valid values:
|
|
57
|
+
- "SkipConflictingEntities" (default): Skip entities that already exist
|
|
58
|
+
- "RecreateExistingEntities": Recreate entities that already exist
|
|
59
|
+
- "SeededAgent": Use seeded agent strategy
|
|
60
|
+
credential_mappings (dict, optional): Mapping of exported credential IDs
|
|
61
|
+
to existing credential GUIDs in the database. Key: Exported credential
|
|
62
|
+
ID from agent definition. Value: Existing credential GUID in database
|
|
63
|
+
(must belong to tenant/project).
|
|
64
|
+
default_project_behavior (str, optional): The default project behavior
|
|
65
|
+
if project_id is null. Valid values: "Library", "BrainFreezeThenDefault",
|
|
66
|
+
"DefaultProject".
|
|
67
|
+
project_id (str, optional): The project ID where the pipeline should be
|
|
68
|
+
imported. If null, the provision will happen in a library project
|
|
69
|
+
according to default_project_behavior.
|
|
70
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
71
|
+
and logging. If not provided, one will be automatically generated.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
CreateAgentFromPipelineDefinitionResponse: A response object containing the
|
|
75
|
+
import result, including pipeline ID, department ID, pipeline name,
|
|
76
|
+
deployment ID (if deployed), and lists of created, updated, and
|
|
77
|
+
skipped entities. If the import failed, error_message and error_details
|
|
78
|
+
will contain information about what went wrong.
|
|
79
|
+
|
|
80
|
+
Raises:
|
|
81
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
82
|
+
- The pipeline definition is invalid (400)
|
|
83
|
+
- A referenced project_id doesn't exist (404)
|
|
84
|
+
- Credential mappings are invalid (400)
|
|
85
|
+
- Authentication fails (401)
|
|
86
|
+
- Access is forbidden (403)
|
|
87
|
+
- Server errors (5xx)
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
```python
|
|
91
|
+
from airia import AiriaAsyncClient
|
|
92
|
+
import asyncio
|
|
93
|
+
|
|
94
|
+
async def main():
|
|
95
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
96
|
+
|
|
97
|
+
# First, export a pipeline definition
|
|
98
|
+
exported = await client.pipelines_config.export_pipeline_definition(
|
|
99
|
+
pipeline_id="source_pipeline_id"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Convert the exported definition to a JSON-compatible dictionary
|
|
103
|
+
# (Pydantic models have a .model_dump() method for this)
|
|
104
|
+
pipeline_def = exported.model_dump(by_alias=True, exclude_none=True)
|
|
105
|
+
|
|
106
|
+
# Import the pipeline into a new project
|
|
107
|
+
result = await client.pipeline_import.create_agent_from_pipeline_definition(
|
|
108
|
+
pipeline_definition=pipeline_def,
|
|
109
|
+
project_id="target_project_id",
|
|
110
|
+
conflict_resolution_strategy="SkipConflictingEntities"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
if result.error_message:
|
|
114
|
+
print(f"Import failed: {result.error_message}")
|
|
115
|
+
if result.error_details:
|
|
116
|
+
for detail in result.error_details:
|
|
117
|
+
print(f" - {detail}")
|
|
118
|
+
else:
|
|
119
|
+
print(f"Pipeline imported successfully!")
|
|
120
|
+
print(f"Pipeline ID: {result.pipeline_id}")
|
|
121
|
+
print(f"Pipeline Name: {result.pipeline_name}")
|
|
122
|
+
print(f"Created {len(result.created_entities or [])} entities")
|
|
123
|
+
print(f"Updated {len(result.updated_entities or [])} entities")
|
|
124
|
+
print(f"Skipped {len(result.skipped_entities or [])} entities")
|
|
125
|
+
|
|
126
|
+
asyncio.run(main())
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Note:
|
|
130
|
+
- The pipeline_definition must use JSON-compatible types only
|
|
131
|
+
- Use model_dump(by_alias=True) on Pydantic models to get the correct format
|
|
132
|
+
- Credential mappings must reference existing credentials in the target system
|
|
133
|
+
- The import process will create new GUIDs for most entities
|
|
134
|
+
"""
|
|
135
|
+
request_data = self._pre_create_agent_from_pipeline_definition(
|
|
136
|
+
pipeline_definition=pipeline_definition,
|
|
137
|
+
agent_import_source=agent_import_source,
|
|
138
|
+
conflict_resolution_strategy=conflict_resolution_strategy,
|
|
139
|
+
credential_mappings=credential_mappings,
|
|
140
|
+
default_project_behavior=default_project_behavior,
|
|
141
|
+
project_id=project_id,
|
|
142
|
+
correlation_id=correlation_id,
|
|
143
|
+
api_version=ApiVersion.V1.value,
|
|
144
|
+
)
|
|
145
|
+
resp = await self._request_handler.make_request("POST", request_data)
|
|
146
|
+
|
|
147
|
+
return CreateAgentFromPipelineDefinitionResponse(**resp)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from typing import Any, Dict, Literal, Optional, Union
|
|
2
|
+
from urllib.parse import urljoin
|
|
3
|
+
|
|
4
|
+
from ...types._api_version import ApiVersion
|
|
5
|
+
from .._request_handler import AsyncRequestHandler, RequestHandler
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BasePipelineImport:
|
|
9
|
+
def __init__(self, request_handler: Union[RequestHandler, AsyncRequestHandler]):
|
|
10
|
+
self._request_handler = request_handler
|
|
11
|
+
|
|
12
|
+
def _pre_create_agent_from_pipeline_definition(
|
|
13
|
+
self,
|
|
14
|
+
pipeline_definition: Dict[str, Any],
|
|
15
|
+
agent_import_source: Optional[
|
|
16
|
+
Literal[
|
|
17
|
+
"PlatformApi",
|
|
18
|
+
"ChatCommunity",
|
|
19
|
+
"PlatformCommunity",
|
|
20
|
+
"PlatformJson",
|
|
21
|
+
"Marketplace",
|
|
22
|
+
]
|
|
23
|
+
] = None,
|
|
24
|
+
conflict_resolution_strategy: Literal[
|
|
25
|
+
"SkipConflictingEntities",
|
|
26
|
+
"RecreateExistingEntities",
|
|
27
|
+
"SeededAgent",
|
|
28
|
+
] = "SkipConflictingEntities",
|
|
29
|
+
credential_mappings: Optional[Dict[str, str]] = None,
|
|
30
|
+
default_project_behavior: Optional[
|
|
31
|
+
Literal["Library", "BrainFreezeThenDefault", "DefaultProject"]
|
|
32
|
+
] = None,
|
|
33
|
+
project_id: Optional[str] = None,
|
|
34
|
+
correlation_id: Optional[str] = None,
|
|
35
|
+
api_version: str = ApiVersion.V1.value,
|
|
36
|
+
):
|
|
37
|
+
"""
|
|
38
|
+
Prepare request data for creating an agent from a pipeline definition.
|
|
39
|
+
|
|
40
|
+
This internal method constructs the URL and payload for importing
|
|
41
|
+
a pipeline from a definition.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
pipeline_definition: The pipeline definition to import (dictionary structure
|
|
45
|
+
matching ExportPipelineDefinitionResponse format, but using JSON-compatible types)
|
|
46
|
+
agent_import_source: The source of the agent import (PlatformApi, ChatCommunity,
|
|
47
|
+
PlatformCommunity, PlatformJson, or Marketplace)
|
|
48
|
+
conflict_resolution_strategy: Strategy for handling conflicting entities
|
|
49
|
+
(SkipConflictingEntities, RecreateExistingEntities, or SeededAgent)
|
|
50
|
+
credential_mappings: Optional mapping of exported credential IDs to existing
|
|
51
|
+
credential GUIDs in the database
|
|
52
|
+
default_project_behavior: The default project behavior if project_id is null
|
|
53
|
+
(Library, BrainFreezeThenDefault, or DefaultProject)
|
|
54
|
+
project_id: Optional project ID. If null, provision happens in a library project
|
|
55
|
+
correlation_id: Optional correlation ID for tracing
|
|
56
|
+
api_version: API version to use for the request
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
RequestData: Prepared request data for the pipeline import endpoint
|
|
60
|
+
|
|
61
|
+
Raises:
|
|
62
|
+
ValueError: If an invalid API version is provided
|
|
63
|
+
"""
|
|
64
|
+
if api_version not in ApiVersion.as_list():
|
|
65
|
+
raise ValueError(
|
|
66
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
67
|
+
)
|
|
68
|
+
url = urljoin(
|
|
69
|
+
self._request_handler.base_url,
|
|
70
|
+
f"{api_version}/PipelineImport/definition",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
payload = {
|
|
74
|
+
"pipelineDefinition": pipeline_definition,
|
|
75
|
+
"conflictResolutionStrategy": conflict_resolution_strategy,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Add optional fields only if they are not None
|
|
79
|
+
if agent_import_source is not None:
|
|
80
|
+
payload["agentImportSource"] = agent_import_source
|
|
81
|
+
|
|
82
|
+
if credential_mappings is not None:
|
|
83
|
+
payload["credentialMappings"] = credential_mappings
|
|
84
|
+
|
|
85
|
+
if default_project_behavior is not None:
|
|
86
|
+
payload["defaultProjectBehavior"] = default_project_behavior
|
|
87
|
+
|
|
88
|
+
if project_id is not None:
|
|
89
|
+
payload["projectId"] = project_id
|
|
90
|
+
|
|
91
|
+
request_data = self._request_handler.prepare_request(
|
|
92
|
+
url=url, payload=payload, correlation_id=correlation_id
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return request_data
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
from typing import Any, Dict, Literal, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.pipeline_import import CreateAgentFromPipelineDefinitionResponse
|
|
5
|
+
from .._request_handler import RequestHandler
|
|
6
|
+
from .base_pipeline_import import BasePipelineImport
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PipelineImport(BasePipelineImport):
|
|
10
|
+
def __init__(self, request_handler: RequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
def create_agent_from_pipeline_definition(
|
|
14
|
+
self,
|
|
15
|
+
pipeline_definition: Dict[str, Any],
|
|
16
|
+
agent_import_source: Optional[
|
|
17
|
+
Literal[
|
|
18
|
+
"PlatformApi",
|
|
19
|
+
"ChatCommunity",
|
|
20
|
+
"PlatformCommunity",
|
|
21
|
+
"PlatformJson",
|
|
22
|
+
"Marketplace",
|
|
23
|
+
]
|
|
24
|
+
] = None,
|
|
25
|
+
conflict_resolution_strategy: Literal[
|
|
26
|
+
"SkipConflictingEntities",
|
|
27
|
+
"RecreateExistingEntities",
|
|
28
|
+
"SeededAgent",
|
|
29
|
+
] = "SkipConflictingEntities",
|
|
30
|
+
credential_mappings: Optional[Dict[str, str]] = None,
|
|
31
|
+
default_project_behavior: Optional[
|
|
32
|
+
Literal["Library", "BrainFreezeThenDefault", "DefaultProject"]
|
|
33
|
+
] = None,
|
|
34
|
+
project_id: Optional[str] = None,
|
|
35
|
+
correlation_id: Optional[str] = None,
|
|
36
|
+
) -> CreateAgentFromPipelineDefinitionResponse:
|
|
37
|
+
"""
|
|
38
|
+
Create an agent from a pipeline definition.
|
|
39
|
+
|
|
40
|
+
This method imports a complete pipeline from a definition dictionary,
|
|
41
|
+
creating all necessary components including data sources, prompts, tools,
|
|
42
|
+
models, and pipeline steps. The definition structure should match the
|
|
43
|
+
format returned by export_pipeline_definition(), but use JSON-compatible
|
|
44
|
+
types (no enums or Pydantic classes).
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
pipeline_definition (dict): The pipeline definition to import. This should
|
|
48
|
+
be a dictionary with the same structure as the response from
|
|
49
|
+
pipelines_config.export_pipeline_definition(), but using only
|
|
50
|
+
JSON-compatible types (strings, numbers, dicts, lists).
|
|
51
|
+
agent_import_source (str, optional): The source of the agent import.
|
|
52
|
+
Valid values: "PlatformApi", "ChatCommunity", "PlatformCommunity",
|
|
53
|
+
"PlatformJson", "Marketplace". If not provided, the import source
|
|
54
|
+
will not be specified.
|
|
55
|
+
conflict_resolution_strategy (str): Strategy for handling conflicting entities.
|
|
56
|
+
Valid values:
|
|
57
|
+
- "SkipConflictingEntities" (default): Skip entities that already exist
|
|
58
|
+
- "RecreateExistingEntities": Recreate entities that already exist
|
|
59
|
+
- "SeededAgent": Use seeded agent strategy
|
|
60
|
+
credential_mappings (dict, optional): Mapping of exported credential IDs
|
|
61
|
+
to existing credential GUIDs in the database. Key: Exported credential
|
|
62
|
+
ID from agent definition. Value: Existing credential GUID in database
|
|
63
|
+
(must belong to tenant/project).
|
|
64
|
+
default_project_behavior (str, optional): The default project behavior
|
|
65
|
+
if project_id is null. Valid values: "Library", "BrainFreezeThenDefault",
|
|
66
|
+
"DefaultProject".
|
|
67
|
+
project_id (str, optional): The project ID where the pipeline should be
|
|
68
|
+
imported. If null, the provision will happen in a library project
|
|
69
|
+
according to default_project_behavior.
|
|
70
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
71
|
+
and logging. If not provided, one will be automatically generated.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
CreateAgentFromPipelineDefinitionResponse: A response object containing the
|
|
75
|
+
import result, including pipeline ID, department ID, pipeline name,
|
|
76
|
+
deployment ID (if deployed), and lists of created, updated, and
|
|
77
|
+
skipped entities. If the import failed, error_message and error_details
|
|
78
|
+
will contain information about what went wrong.
|
|
79
|
+
|
|
80
|
+
Raises:
|
|
81
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
82
|
+
- The pipeline definition is invalid (400)
|
|
83
|
+
- A referenced project_id doesn't exist (404)
|
|
84
|
+
- Credential mappings are invalid (400)
|
|
85
|
+
- Authentication fails (401)
|
|
86
|
+
- Access is forbidden (403)
|
|
87
|
+
- Server errors (5xx)
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
```python
|
|
91
|
+
from airia import AiriaClient
|
|
92
|
+
|
|
93
|
+
client = AiriaClient(api_key="your_api_key")
|
|
94
|
+
|
|
95
|
+
# First, export a pipeline definition
|
|
96
|
+
exported = client.pipelines_config.export_pipeline_definition(
|
|
97
|
+
pipeline_id="source_pipeline_id"
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Convert the exported definition to a JSON-compatible dictionary
|
|
101
|
+
# (Pydantic models have a .model_dump() method for this)
|
|
102
|
+
pipeline_def = exported.model_dump(by_alias=True, exclude_none=True)
|
|
103
|
+
|
|
104
|
+
# Import the pipeline into a new project
|
|
105
|
+
result = client.pipeline_import.create_agent_from_pipeline_definition(
|
|
106
|
+
pipeline_definition=pipeline_def,
|
|
107
|
+
project_id="target_project_id",
|
|
108
|
+
conflict_resolution_strategy="SkipConflictingEntities"
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
if result.error_message:
|
|
112
|
+
print(f"Import failed: {result.error_message}")
|
|
113
|
+
if result.error_details:
|
|
114
|
+
for detail in result.error_details:
|
|
115
|
+
print(f" - {detail}")
|
|
116
|
+
else:
|
|
117
|
+
print(f"Pipeline imported successfully!")
|
|
118
|
+
print(f"Pipeline ID: {result.pipeline_id}")
|
|
119
|
+
print(f"Pipeline Name: {result.pipeline_name}")
|
|
120
|
+
print(f"Created {len(result.created_entities or [])} entities")
|
|
121
|
+
print(f"Updated {len(result.updated_entities or [])} entities")
|
|
122
|
+
print(f"Skipped {len(result.skipped_entities or [])} entities")
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Note:
|
|
126
|
+
- The pipeline_definition must use JSON-compatible types only
|
|
127
|
+
- Use model_dump(by_alias=True) on Pydantic models to get the correct format
|
|
128
|
+
- Credential mappings must reference existing credentials in the target system
|
|
129
|
+
- The import process will create new GUIDs for most entities
|
|
130
|
+
"""
|
|
131
|
+
request_data = self._pre_create_agent_from_pipeline_definition(
|
|
132
|
+
pipeline_definition=pipeline_definition,
|
|
133
|
+
agent_import_source=agent_import_source,
|
|
134
|
+
conflict_resolution_strategy=conflict_resolution_strategy,
|
|
135
|
+
credential_mappings=credential_mappings,
|
|
136
|
+
default_project_behavior=default_project_behavior,
|
|
137
|
+
project_id=project_id,
|
|
138
|
+
correlation_id=correlation_id,
|
|
139
|
+
api_version=ApiVersion.V1.value,
|
|
140
|
+
)
|
|
141
|
+
resp = self._request_handler.make_request("POST", request_data)
|
|
142
|
+
|
|
143
|
+
return CreateAgentFromPipelineDefinitionResponse(**resp)
|
airia/client/sync_client.py
CHANGED
|
@@ -15,7 +15,9 @@ from .conversations import Conversations
|
|
|
15
15
|
from .data_vector_search import DataVectorSearch
|
|
16
16
|
from .deployments import Deployments
|
|
17
17
|
from .library import Library
|
|
18
|
+
from .models import Models
|
|
18
19
|
from .pipeline_execution import PipelineExecution
|
|
20
|
+
from .pipeline_import import PipelineImport
|
|
19
21
|
from .pipelines_config import PipelinesConfig
|
|
20
22
|
from .project import Project
|
|
21
23
|
from .store import Store
|
|
@@ -63,6 +65,7 @@ class AiriaClient(AiriaBaseClient):
|
|
|
63
65
|
)
|
|
64
66
|
self.attachments = Attachments(self._request_handler)
|
|
65
67
|
self.pipeline_execution = PipelineExecution(self._request_handler)
|
|
68
|
+
self.pipeline_import = PipelineImport(self._request_handler)
|
|
66
69
|
self.pipelines_config = PipelinesConfig(self._request_handler)
|
|
67
70
|
self.project = Project(self._request_handler)
|
|
68
71
|
self.conversations = Conversations(self._request_handler)
|
|
@@ -70,6 +73,7 @@ class AiriaClient(AiriaBaseClient):
|
|
|
70
73
|
self.deployments = Deployments(self._request_handler)
|
|
71
74
|
self.data_vector_search = DataVectorSearch(self._request_handler)
|
|
72
75
|
self.library = Library(self._request_handler)
|
|
76
|
+
self.models = Models(self._request_handler)
|
|
73
77
|
|
|
74
78
|
@classmethod
|
|
75
79
|
def with_openai_gateway(
|
airia/exceptions.py
CHANGED
|
@@ -11,7 +11,7 @@ class AiriaAPIError(Exception):
|
|
|
11
11
|
message (str): The error message describing what went wrong
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
def __init__(self, status_code: int, message: str):
|
|
14
|
+
def __init__(self, status_code: int, message: str, detailed_message: str):
|
|
15
15
|
"""
|
|
16
16
|
Initialize the exception with a status code and error message.
|
|
17
17
|
|
|
@@ -19,9 +19,10 @@ class AiriaAPIError(Exception):
|
|
|
19
19
|
status_code (int): The HTTP status code of the failed request
|
|
20
20
|
message (str): A descriptive error message
|
|
21
21
|
"""
|
|
22
|
-
super().__init__(f"{status_code}: {message}")
|
|
22
|
+
super().__init__(f"{status_code}: {message} - {detailed_message}")
|
|
23
23
|
self.status_code = status_code
|
|
24
24
|
self.message = message
|
|
25
|
+
self.detailed_message = detailed_message
|
|
25
26
|
|
|
26
27
|
def __str__(self) -> str:
|
|
27
28
|
"""
|
|
@@ -30,4 +31,4 @@ class AiriaAPIError(Exception):
|
|
|
30
31
|
Returns:
|
|
31
32
|
str: A formatted string containing the status code and message
|
|
32
33
|
"""
|
|
33
|
-
return f"{self.status_code}: {self.message}"
|
|
34
|
+
return f"{self.status_code}: {self.message} - {self.detailed_message}"
|
airia/types/api/__init__.py
CHANGED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pydantic models for models management API responses.
|
|
3
|
+
|
|
4
|
+
This module defines the data structures returned by models-related endpoints,
|
|
5
|
+
including model listings and associated configuration information.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from typing import Any, List, Optional
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel, Field
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ModelProject(BaseModel):
|
|
15
|
+
"""
|
|
16
|
+
Basic project information associated with a model.
|
|
17
|
+
|
|
18
|
+
Represents a simplified view of project data within model contexts,
|
|
19
|
+
containing only essential identification information.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
id: str
|
|
23
|
+
name: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ModelSystemPrompt(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
System prompt information associated with a model.
|
|
29
|
+
|
|
30
|
+
Contains details about the system prompt template used by the model,
|
|
31
|
+
including version tracking and project associations.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
id: str
|
|
35
|
+
name: str
|
|
36
|
+
active_version_id: Optional[str] = Field(None, alias="activeVersionId")
|
|
37
|
+
active_version: Optional[Any] = Field(None, alias="activeVersion")
|
|
38
|
+
created_at: datetime = Field(alias="createdAt")
|
|
39
|
+
updated_at: datetime = Field(alias="updatedAt")
|
|
40
|
+
project_id: Optional[str] = Field(None, alias="projectId")
|
|
41
|
+
project_name: Optional[str] = Field(None, alias="projectName")
|
|
42
|
+
project: Optional[Any] = None
|
|
43
|
+
latest_version_number: Optional[int] = Field(None, alias="latestVersionNumber")
|
|
44
|
+
is_agent_specific: bool = Field(alias="isAgentSpecific")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ModelUserProvidedDetails(BaseModel):
|
|
48
|
+
"""
|
|
49
|
+
User-provided configuration details for a model.
|
|
50
|
+
|
|
51
|
+
Contains authentication, pricing, and deployment information
|
|
52
|
+
for models configured by users.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
url: str
|
|
56
|
+
credentials_id: Optional[str] = Field(None, alias="credentialsId")
|
|
57
|
+
deployment_type: str = Field(alias="deploymentType")
|
|
58
|
+
connection_string: Optional[str] = Field(None, alias="connectionString")
|
|
59
|
+
container_name: Optional[str] = Field(None, alias="containerName")
|
|
60
|
+
deployed_key: Optional[str] = Field(None, alias="deployedKey")
|
|
61
|
+
deployed_url: Optional[str] = Field(None, alias="deployedUrl")
|
|
62
|
+
state: Optional[Any] = None
|
|
63
|
+
uploaded_container_id: Optional[str] = Field(None, alias="uploadedContainerId")
|
|
64
|
+
input_token_price: float = Field(alias="inputTokenPrice")
|
|
65
|
+
output_token_price: float = Field(alias="outputTokenPrice")
|
|
66
|
+
token_units: int = Field(alias="tokenUnits")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ModelItem(BaseModel):
|
|
70
|
+
"""
|
|
71
|
+
Comprehensive model information and metadata.
|
|
72
|
+
|
|
73
|
+
This model represents a complete model entity with all associated configuration,
|
|
74
|
+
pricing information, capabilities, and organizational details. Models can be
|
|
75
|
+
either library-provided or user-configured.
|
|
76
|
+
|
|
77
|
+
Attributes:
|
|
78
|
+
category: Model category (e.g., "Multimodal", "NLP", "ImageGeneration")
|
|
79
|
+
id: Unique model identifier
|
|
80
|
+
display_name: Human-readable model name
|
|
81
|
+
model_name: Technical model identifier/name
|
|
82
|
+
prompt_id: Optional system prompt identifier
|
|
83
|
+
system_prompt: Optional system prompt configuration
|
|
84
|
+
source_type: Model source ("Library" or "UserProvided")
|
|
85
|
+
type: Model type (e.g., "Text", "Image")
|
|
86
|
+
provider: AI provider (e.g., "OpenAI", "Anthropic", "Google")
|
|
87
|
+
tenant_id: Tenant/organization identifier
|
|
88
|
+
project_id: Optional project identifier
|
|
89
|
+
project_name: Optional project name
|
|
90
|
+
project: Optional project details
|
|
91
|
+
created_at: Model creation timestamp
|
|
92
|
+
updated_at: Last modification timestamp
|
|
93
|
+
user_id: User who created/configured the model
|
|
94
|
+
has_tool_support: Whether model supports tool calling
|
|
95
|
+
has_stream_support: Whether model supports streaming responses
|
|
96
|
+
library_model_id: Optional library model identifier
|
|
97
|
+
user_provided_details: Configuration details for user-provided models
|
|
98
|
+
allow_airia_credentials: Whether Airia-managed credentials are allowed
|
|
99
|
+
allow_byok_credentials: Whether bring-your-own-key credentials are allowed
|
|
100
|
+
price_type: Pricing model type
|
|
101
|
+
model_parameters: Additional model parameters
|
|
102
|
+
route_through_acc: Whether to route through Airia Credentials Controller
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
category: Optional[str] = None
|
|
106
|
+
id: str
|
|
107
|
+
display_name: str = Field(alias="displayName")
|
|
108
|
+
model_name: str = Field(alias="modelName")
|
|
109
|
+
prompt_id: Optional[str] = Field(None, alias="promptId")
|
|
110
|
+
system_prompt: Optional[ModelSystemPrompt] = Field(None, alias="systemPrompt")
|
|
111
|
+
source_type: str = Field(alias="sourceType")
|
|
112
|
+
type: str
|
|
113
|
+
provider: str
|
|
114
|
+
tenant_id: str = Field(alias="tenantId")
|
|
115
|
+
project_id: Optional[str] = Field(None, alias="projectId")
|
|
116
|
+
project_name: Optional[str] = Field(None, alias="projectName")
|
|
117
|
+
project: Optional[ModelProject] = None
|
|
118
|
+
created_at: datetime = Field(alias="createdAt")
|
|
119
|
+
updated_at: datetime = Field(alias="updatedAt")
|
|
120
|
+
user_id: str = Field(alias="userId")
|
|
121
|
+
has_tool_support: bool = Field(alias="hasToolSupport")
|
|
122
|
+
has_stream_support: bool = Field(alias="hasStreamSupport")
|
|
123
|
+
library_model_id: Optional[str] = Field(None, alias="libraryModelId")
|
|
124
|
+
user_provided_details: ModelUserProvidedDetails = Field(alias="userProvidedDetails")
|
|
125
|
+
allow_airia_credentials: bool = Field(alias="allowAiriaCredentials")
|
|
126
|
+
allow_byok_credentials: bool = Field(alias="allowBYOKCredentials")
|
|
127
|
+
price_type: str = Field(alias="priceType")
|
|
128
|
+
model_parameters: List[Any] = Field(alias="modelParameters")
|
|
129
|
+
route_through_acc: bool = Field(alias="routeThroughACC")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Pipeline import API response types."""
|
|
2
|
+
|
|
3
|
+
from .create_agent_from_pipeline_definition import (
|
|
4
|
+
CreateAgentFromPipelineDefinitionResponse,
|
|
5
|
+
PipelineImportedEntity,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"CreateAgentFromPipelineDefinitionResponse",
|
|
10
|
+
"PipelineImportedEntity",
|
|
11
|
+
]
|