airia 0.1.15__py3-none-any.whl → 0.1.17__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.
@@ -89,7 +89,7 @@ class BaseRequestHandler:
89
89
  log_payload = json.dumps(log_payload)
90
90
 
91
91
  self.logger.info(
92
- f"API Request: POST {url}\n"
92
+ f"URL: {url}\n"
93
93
  f"Headers: {json.dumps(log_headers)}\n"
94
94
  f"Payload: {log_payload}\n"
95
95
  f"Files: {log_files}\n"
@@ -11,6 +11,7 @@ from ..constants import (
11
11
  from ._request_handler import AsyncRequestHandler
12
12
  from .base_client import AiriaBaseClient
13
13
  from .conversations import AsyncConversations
14
+ from .data_vector_search import AsyncDataVectorSearch
14
15
  from .deployments import AsyncDeployments
15
16
  from .pipeline_execution import AsyncPipelineExecution
16
17
  from .pipelines_config import AsyncPipelinesConfig
@@ -64,6 +65,7 @@ class AiriaAsyncClient(AiriaBaseClient):
64
65
  self.conversations = AsyncConversations(self._request_handler)
65
66
  self.store = AsyncStore(self._request_handler)
66
67
  self.deployments = AsyncDeployments(self._request_handler)
68
+ self.data_vector_search = AsyncDataVectorSearch(self._request_handler)
67
69
 
68
70
  @classmethod
69
71
  def with_openai_gateway(
@@ -0,0 +1,4 @@
1
+ from .async_data_vector_search import AsyncDataVectorSearch
2
+ from .sync_data_vector_search import DataVectorSearch
3
+
4
+ __all__ = ["DataVectorSearch", "AsyncDataVectorSearch"]
@@ -0,0 +1,74 @@
1
+ from typing import Optional
2
+
3
+ from ...types._api_version import ApiVersion
4
+ from ...types.api.data_vector_search import GetFileChunksResponse
5
+ from .._request_handler import AsyncRequestHandler
6
+ from .base_data_vector_search import BaseDataVectorSearch
7
+
8
+
9
+ class AsyncDataVectorSearch(BaseDataVectorSearch):
10
+ def __init__(self, request_handler: AsyncRequestHandler):
11
+ super().__init__(request_handler)
12
+
13
+ async def get_file_chunks(
14
+ self, data_store_id: str, file_id: str, correlation_id: Optional[str] = None
15
+ ) -> GetFileChunksResponse:
16
+ """
17
+ Retrieve chunks from a specific file in a data store.
18
+
19
+ This method retrieves chunks from a file in the specified data store.
20
+
21
+ Args:
22
+ data_store_id: The unique identifier of the data store (GUID format)
23
+ file_id: The unique identifier of the file (GUID format)
24
+ correlation_id: Optional correlation ID for request tracing
25
+
26
+ Returns:
27
+ GetFileChunksResponse: Object containing the chunks and pagination information
28
+
29
+ Raises:
30
+ AiriaAPIError: If the API request fails, including cases where:
31
+ - The data_store_id doesn't exist (404)
32
+ - The file_id doesn't exist (404)
33
+ - Authentication fails (401)
34
+ - Access is forbidden (403)
35
+ - Server errors (5xx)
36
+ ValueError: If required parameters are missing or invalid
37
+
38
+ Example:
39
+ ```python
40
+ from airia import AiriaAsyncClient
41
+ import asyncio
42
+
43
+ async def main():
44
+ client = AiriaAsyncClient(api_key="your_api_key")
45
+
46
+ # Get file chunks with default pagination
47
+ chunks_response = await client.data_vector_search.get_file_chunks(
48
+ data_store_id="your_data_store_id",
49
+ file_id="your_file_id"
50
+ )
51
+
52
+ # Access the chunks
53
+ for chunk in chunks_response.chunks:
54
+ print(f"Chunk: {chunk.chunk}")
55
+ print(f"Document: {chunk.document_name}")
56
+ if chunk.score is not None:
57
+ print(f"Score: {chunk.score}")
58
+
59
+ await client.close()
60
+
61
+ asyncio.run(main())
62
+ ```
63
+ """
64
+ request_data = self._pre_get_file_chunks(
65
+ data_store_id=data_store_id,
66
+ file_id=file_id,
67
+ correlation_id=correlation_id,
68
+ api_version=ApiVersion.V1.value,
69
+ )
70
+
71
+ response = await self._request_handler.make_request(
72
+ "GET", request_data, return_json=True
73
+ )
74
+ return GetFileChunksResponse(**response)
@@ -0,0 +1,50 @@
1
+ from typing import 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 BaseDataVectorSearch:
9
+ def __init__(self, request_handler: Union[RequestHandler, AsyncRequestHandler]):
10
+ self._request_handler = request_handler
11
+
12
+ def _pre_get_file_chunks(
13
+ self,
14
+ data_store_id: str,
15
+ file_id: str,
16
+ correlation_id: Optional[str] = None,
17
+ api_version: str = ApiVersion.V1.value,
18
+ ):
19
+ """
20
+ Prepare request data for get file chunks endpoint.
21
+
22
+ This internal method constructs the URL for file chunks retrieval requests.
23
+
24
+ Args:
25
+ data_store_id: ID of the data store
26
+ file_id: ID of the file
27
+ correlation_id: Optional correlation ID for tracing
28
+ api_version: API version to use for the request
29
+
30
+ Returns:
31
+ RequestData: Prepared request data for the get file chunks endpoint
32
+
33
+ Raises:
34
+ ValueError: If an invalid API version is provided
35
+ """
36
+ if api_version not in ApiVersion.as_list():
37
+ raise ValueError(
38
+ f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
39
+ )
40
+
41
+ url = urljoin(
42
+ self._request_handler.base_url,
43
+ f"{api_version}/DataVectorSearch/chunks/{data_store_id}/{file_id}",
44
+ )
45
+
46
+ request_data = self._request_handler.prepare_request(
47
+ url, correlation_id=correlation_id, params={"pageNumber": 1, "pageSize": 50}
48
+ )
49
+
50
+ return request_data
@@ -0,0 +1,68 @@
1
+ from typing import Optional
2
+
3
+ from ...types._api_version import ApiVersion
4
+ from ...types.api.data_vector_search import GetFileChunksResponse
5
+ from .._request_handler import RequestHandler
6
+ from .base_data_vector_search import BaseDataVectorSearch
7
+
8
+
9
+ class DataVectorSearch(BaseDataVectorSearch):
10
+ def __init__(self, request_handler: RequestHandler):
11
+ super().__init__(request_handler)
12
+
13
+ def get_file_chunks(
14
+ self, data_store_id: str, file_id: str, correlation_id: Optional[str] = None
15
+ ) -> GetFileChunksResponse:
16
+ """
17
+ Retrieve chunks from a specific file in a data store.
18
+
19
+ This method retrieves chunks from a file in the specified data store.
20
+
21
+ Args:
22
+ data_store_id: The unique identifier of the data store (GUID format)
23
+ file_id: The unique identifier of the file (GUID format)
24
+ correlation_id: Optional correlation ID for request tracing
25
+
26
+ Returns:
27
+ GetFileChunksResponse: Object containing the chunks and pagination information
28
+
29
+ Raises:
30
+ AiriaAPIError: If the API request fails, including cases where:
31
+ - The data_store_id doesn't exist (404)
32
+ - The file_id doesn't exist (404)
33
+ - Authentication fails (401)
34
+ - Access is forbidden (403)
35
+ - Server errors (5xx)
36
+ ValueError: If required parameters are missing or invalid
37
+
38
+ Example:
39
+ ```python
40
+ from airia import AiriaClient
41
+
42
+ client = AiriaClient(api_key="your_api_key")
43
+
44
+ # Get file chunks with default pagination
45
+ chunks_response = client.data_vector_search.get_file_chunks(
46
+ data_store_id="your_data_store_id",
47
+ file_id="your_file_id"
48
+ )
49
+
50
+ # Access the chunks
51
+ for chunk in chunks_response.chunks:
52
+ print(f"Chunk: {chunk.chunk}")
53
+ print(f"Document: {chunk.document_name}")
54
+ if chunk.score is not None:
55
+ print(f"Score: {chunk.score}")
56
+ ```
57
+ """
58
+ request_data = self._pre_get_file_chunks(
59
+ data_store_id=data_store_id,
60
+ file_id=file_id,
61
+ correlation_id=correlation_id,
62
+ api_version=ApiVersion.V1.value,
63
+ )
64
+
65
+ response = self._request_handler.make_request(
66
+ "GET", request_data, return_json=True
67
+ )
68
+ return GetFileChunksResponse(**response)
@@ -1,7 +1,10 @@
1
1
  from typing import Optional
2
2
 
3
3
  from ...types._api_version import ApiVersion
4
- from ...types.api.pipelines_config import PipelineConfigResponse
4
+ from ...types.api.pipelines_config import (
5
+ PipelineConfigResponse,
6
+ ExportPipelineDefinitionResponse,
7
+ )
5
8
  from .._request_handler import AsyncRequestHandler
6
9
  from .base_pipelines_config import BasePipelinesConfig
7
10
 
@@ -63,3 +66,60 @@ class AsyncPipelinesConfig(BasePipelinesConfig):
63
66
  resp = await self._request_handler.make_request("GET", request_data)
64
67
 
65
68
  return PipelineConfigResponse(**resp)
69
+
70
+ async def export_pipeline_definition(
71
+ self, pipeline_id: str, correlation_id: Optional[str] = None
72
+ ) -> ExportPipelineDefinitionResponse:
73
+ """
74
+ Export the complete definition of a pipeline including all its components.
75
+
76
+ This method retrieves a comprehensive export of a pipeline definition including
77
+ metadata, agent configuration, data sources, prompts, tools, models, memories,
78
+ Python code blocks, routers, and deployment information.
79
+
80
+ Args:
81
+ pipeline_id (str): The unique identifier of the pipeline to export
82
+ definition for.
83
+ correlation_id (str, optional): A unique identifier for request tracing
84
+ and logging. If not provided, one will be automatically generated.
85
+
86
+ Returns:
87
+ ExportPipelineDefinitionResponse: A response object containing the complete
88
+ pipeline definition export.
89
+
90
+ Raises:
91
+ AiriaAPIError: If the API request fails, including cases where:
92
+ - The pipeline_id doesn't exist (404)
93
+ - Authentication fails (401)
94
+ - Access is forbidden (403)
95
+ - Server errors (5xx)
96
+
97
+ Example:
98
+ ```python
99
+ from airia import AiriaAsyncClient
100
+
101
+ client = AiriaAsyncClient(api_key="your_api_key")
102
+
103
+ # Export pipeline definition
104
+ export = await client.pipelines_config.export_pipeline_definition(
105
+ pipeline_id="your_pipeline_id"
106
+ )
107
+
108
+ print(f"Pipeline: {export.agent.name}")
109
+ print(f"Export version: {export.metadata.export_version}")
110
+ print(f"Data sources: {len(export.data_sources or [])}")
111
+ print(f"Tools: {len(export.tools or [])}")
112
+ ```
113
+
114
+ Note:
115
+ This method exports the complete pipeline definition which can be used
116
+ for backup, version control, or importing into other environments.
117
+ """
118
+ request_data = self._pre_export_pipeline_definition(
119
+ pipeline_id=pipeline_id,
120
+ correlation_id=correlation_id,
121
+ api_version=ApiVersion.V1.value,
122
+ )
123
+ resp = await self._request_handler.make_request("GET", request_data)
124
+
125
+ return ExportPipelineDefinitionResponse(**resp)
@@ -42,3 +42,37 @@ class BasePipelinesConfig:
42
42
  )
43
43
 
44
44
  return request_data
45
+
46
+ def _pre_export_pipeline_definition(
47
+ self,
48
+ pipeline_id: str,
49
+ correlation_id: Optional[str] = None,
50
+ api_version: str = ApiVersion.V1.value,
51
+ ):
52
+ """
53
+ Prepare request data for exporting pipeline definition endpoint.
54
+
55
+ Args:
56
+ pipeline_id: ID of the pipeline to export definition for
57
+ correlation_id: Optional correlation ID for tracing
58
+ api_version: API version to use for the request
59
+
60
+ Returns:
61
+ RequestData: Prepared request data for the export pipeline definition endpoint
62
+
63
+ Raises:
64
+ ValueError: If an invalid API version is provided
65
+ """
66
+ if api_version not in ApiVersion.as_list():
67
+ raise ValueError(
68
+ f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
69
+ )
70
+ url = urljoin(
71
+ self._request_handler.base_url,
72
+ f"{api_version}/PipelinesConfig/export/{pipeline_id}",
73
+ )
74
+ request_data = self._request_handler.prepare_request(
75
+ url, correlation_id=correlation_id
76
+ )
77
+
78
+ return request_data
@@ -1,7 +1,10 @@
1
1
  from typing import Optional
2
2
 
3
3
  from ...types._api_version import ApiVersion
4
- from ...types.api.pipelines_config import PipelineConfigResponse
4
+ from ...types.api.pipelines_config import (
5
+ PipelineConfigResponse,
6
+ ExportPipelineDefinitionResponse,
7
+ )
5
8
  from .._request_handler import RequestHandler
6
9
  from .base_pipelines_config import BasePipelinesConfig
7
10
 
@@ -63,3 +66,60 @@ class PipelinesConfig(BasePipelinesConfig):
63
66
  resp = self._request_handler.make_request("GET", request_data)
64
67
 
65
68
  return PipelineConfigResponse(**resp)
69
+
70
+ def export_pipeline_definition(
71
+ self, pipeline_id: str, correlation_id: Optional[str] = None
72
+ ) -> ExportPipelineDefinitionResponse:
73
+ """
74
+ Export the complete definition of a pipeline including all its components.
75
+
76
+ This method retrieves a comprehensive export of a pipeline definition including
77
+ metadata, agent configuration, data sources, prompts, tools, models, memories,
78
+ Python code blocks, routers, and deployment information.
79
+
80
+ Args:
81
+ pipeline_id (str): The unique identifier of the pipeline to export
82
+ definition for.
83
+ correlation_id (str, optional): A unique identifier for request tracing
84
+ and logging. If not provided, one will be automatically generated.
85
+
86
+ Returns:
87
+ ExportPipelineDefinitionResponse: A response object containing the complete
88
+ pipeline definition export.
89
+
90
+ Raises:
91
+ AiriaAPIError: If the API request fails, including cases where:
92
+ - The pipeline_id doesn't exist (404)
93
+ - Authentication fails (401)
94
+ - Access is forbidden (403)
95
+ - Server errors (5xx)
96
+
97
+ Example:
98
+ ```python
99
+ from airia import AiriaClient
100
+
101
+ client = AiriaClient(api_key="your_api_key")
102
+
103
+ # Export pipeline definition
104
+ export = client.pipelines_config.export_pipeline_definition(
105
+ pipeline_id="your_pipeline_id"
106
+ )
107
+
108
+ print(f"Pipeline: {export.agent.name}")
109
+ print(f"Export version: {export.metadata.export_version}")
110
+ print(f"Data sources: {len(export.data_sources or [])}")
111
+ print(f"Tools: {len(export.tools or [])}")
112
+ ```
113
+
114
+ Note:
115
+ This method exports the complete pipeline definition which can be used
116
+ for backup, version control, or importing into other environments.
117
+ """
118
+ request_data = self._pre_export_pipeline_definition(
119
+ pipeline_id=pipeline_id,
120
+ correlation_id=correlation_id,
121
+ api_version=ApiVersion.V1.value,
122
+ )
123
+ resp = self._request_handler.make_request("GET", request_data)
124
+
125
+ return ExportPipelineDefinitionResponse(**resp)
@@ -11,6 +11,7 @@ from ..constants import (
11
11
  from ._request_handler import RequestHandler
12
12
  from .base_client import AiriaBaseClient
13
13
  from .conversations import Conversations
14
+ from .data_vector_search import DataVectorSearch
14
15
  from .deployments import Deployments
15
16
  from .pipeline_execution import PipelineExecution
16
17
  from .pipelines_config import PipelinesConfig
@@ -64,6 +65,7 @@ class AiriaClient(AiriaBaseClient):
64
65
  self.conversations = Conversations(self._request_handler)
65
66
  self.store = Store(self._request_handler)
66
67
  self.deployments = Deployments(self._request_handler)
68
+ self.data_vector_search = DataVectorSearch(self._request_handler)
67
69
 
68
70
  @classmethod
69
71
  def with_openai_gateway(
@@ -0,0 +1,3 @@
1
+ from .get_file_chunks import GetFileChunksResponse, FileChunk
2
+
3
+ __all__ = ["GetFileChunksResponse", "FileChunk"]
@@ -0,0 +1,45 @@
1
+ from typing import List, Optional
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+
6
+ class FileChunk(BaseModel):
7
+ """Represents a chunk of a file with score and metadata.
8
+
9
+ Attributes:
10
+ path: Path of the chunk
11
+ score: Optional relevance score for the chunk
12
+ chunk: The text content of the chunk
13
+ sequence_number: Optional sequence number of the chunk in the document
14
+ document_id: Unique identifier of the document (GUID format)
15
+ document_name: Name of the document
16
+ """
17
+
18
+ path: Optional[str] = None
19
+ score: Optional[float] = None
20
+ chunk: str
21
+ sequence_number: Optional[int] = Field(None, alias="sequenceNumber")
22
+ document_id: Optional[str] = Field(None, alias="documentId")
23
+ document_name: Optional[str] = Field(None, alias="documentName")
24
+
25
+
26
+ class GetFileChunksResponse(BaseModel):
27
+ """Response model for file chunks retrieval.
28
+
29
+ Attributes:
30
+ data_store_id: The data store identifier (GUID format)
31
+ file_id: The file identifier (GUID format)
32
+ chunks: List of chunks from the file
33
+ page_number: Current page number
34
+ page_size: Page size used for pagination
35
+ total_count: Total count of chunks
36
+ total_pages: Total number of pages
37
+ """
38
+
39
+ data_store_id: Optional[str] = Field(None, alias="dataStoreId")
40
+ file_id: Optional[str] = Field(None, alias="fileId")
41
+ chunks: List[FileChunk]
42
+ page_number: int = Field(alias="pageNumber")
43
+ page_size: int = Field(alias="pageSize")
44
+ total_count: int = Field(alias="totalCount")
45
+ total_pages: int = Field(alias="totalPages")
@@ -16,6 +16,33 @@ from .get_pipeline_config import (
16
16
  PipelineStepPosition,
17
17
  PipelineVersion,
18
18
  )
19
+ from .export_pipeline_definition import (
20
+ AgentDetailItemDefinition,
21
+ ExportPipelineDefinitionResponse,
22
+ ExportChunkingConfig,
23
+ ExportCredentialDataList,
24
+ ExportCredentials,
25
+ ExportDataSource,
26
+ ExportDataSourceFile,
27
+ ExportDependency,
28
+ ExportDeployment,
29
+ ExportHandle,
30
+ ExportMemory,
31
+ ExportMetadata,
32
+ ExportModel,
33
+ ExportPipeline,
34
+ ExportPipelineStep,
35
+ ExportPosition,
36
+ ExportPrompt,
37
+ ExportPromptMessageList,
38
+ ExportPythonCodeBlock,
39
+ ExportRouter,
40
+ ExportRouterConfig,
41
+ ExportTool,
42
+ ExportToolHeaders,
43
+ ExportToolParameters,
44
+ ExportUserPrompt,
45
+ )
19
46
 
20
47
  __all__ = [
21
48
  "AboutDeploymentMetadata",
@@ -24,6 +51,7 @@ __all__ = [
24
51
  "Deployment",
25
52
  "DeploymentAssignment",
26
53
  "DeploymentUserPrompt",
54
+ "ExportPipelineDefinitionResponse",
27
55
  "Pipeline",
28
56
  "PipelineConfigResponse",
29
57
  "PipelineExecutionStats",
@@ -32,4 +60,28 @@ __all__ = [
32
60
  "PipelineStepHandle",
33
61
  "PipelineStepPosition",
34
62
  "PipelineVersion",
63
+ "AgentDetailItemDefinition",
64
+ "ExportChunkingConfig",
65
+ "ExportCredentialDataList",
66
+ "ExportCredentials",
67
+ "ExportDataSource",
68
+ "ExportDataSourceFile",
69
+ "ExportDependency",
70
+ "ExportDeployment",
71
+ "ExportHandle",
72
+ "ExportMemory",
73
+ "ExportMetadata",
74
+ "ExportModel",
75
+ "ExportPipeline",
76
+ "ExportPipelineStep",
77
+ "ExportPosition",
78
+ "ExportPrompt",
79
+ "ExportPromptMessageList",
80
+ "ExportPythonCodeBlock",
81
+ "ExportRouter",
82
+ "ExportRouterConfig",
83
+ "ExportTool",
84
+ "ExportToolHeaders",
85
+ "ExportToolParameters",
86
+ "ExportUserPrompt",
35
87
  ]