airia 0.1.16__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.
- airia/client/_request_handler/base_request_handler.py +1 -1
- airia/client/async_client.py +2 -0
- airia/client/data_vector_search/__init__.py +4 -0
- airia/client/data_vector_search/async_data_vector_search.py +74 -0
- airia/client/data_vector_search/base_data_vector_search.py +50 -0
- airia/client/data_vector_search/sync_data_vector_search.py +68 -0
- airia/client/sync_client.py +2 -0
- airia/types/api/data_vector_search/__init__.py +3 -0
- airia/types/api/data_vector_search/get_file_chunks.py +45 -0
- {airia-0.1.16.dist-info → airia-0.1.17.dist-info}/METADATA +1 -1
- {airia-0.1.16.dist-info → airia-0.1.17.dist-info}/RECORD +14 -8
- {airia-0.1.16.dist-info → airia-0.1.17.dist-info}/WHEEL +0 -0
- {airia-0.1.16.dist-info → airia-0.1.17.dist-info}/licenses/LICENSE +0 -0
- {airia-0.1.16.dist-info → airia-0.1.17.dist-info}/top_level.txt +0 -0
airia/client/async_client.py
CHANGED
|
@@ -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,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)
|
airia/client/sync_client.py
CHANGED
|
@@ -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,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")
|
|
@@ -3,17 +3,21 @@ airia/constants.py,sha256=oKABowOTsJPIQ1AgtVpNN73oKuhh1DekBC5axYSm8lY,647
|
|
|
3
3
|
airia/exceptions.py,sha256=M98aESxodebVLafqDQSqCKLUUT_b-lNSVOpYGJ6Cmn0,1114
|
|
4
4
|
airia/logs.py,sha256=oHU8ByekHu-udBB-5abY39wUct_26t8io-A1Kcl7D3U,4538
|
|
5
5
|
airia/client/__init__.py,sha256=6gSQ9bl7j79q1HPE0o5py3IRdkwWWuU_7J4h05Dd2o8,127
|
|
6
|
-
airia/client/async_client.py,sha256=
|
|
6
|
+
airia/client/async_client.py,sha256=H1GFozhV2jq5-m1Gplx2OTbVR5l4sU-gAhaoH75bxtI,7034
|
|
7
7
|
airia/client/base_client.py,sha256=ftyLi2E3Hb4CQFYfiknitJA0sWDTylCiUbde0qkWYhg,3182
|
|
8
|
-
airia/client/sync_client.py,sha256=
|
|
8
|
+
airia/client/sync_client.py,sha256=bCU92G7eo9I1tGYV1lRxXELDPsyVn0nbte5EFrwrMCg,6893
|
|
9
9
|
airia/client/_request_handler/__init__.py,sha256=FOdJMfzjN0Tw0TeD8mDJwHgte70Fw_j08EljtfulCvw,157
|
|
10
10
|
airia/client/_request_handler/async_request_handler.py,sha256=8225uM82kgOFu1E2DULVuk0qBN7vmPmcBtYXstUZaR8,10931
|
|
11
|
-
airia/client/_request_handler/base_request_handler.py,sha256=
|
|
11
|
+
airia/client/_request_handler/base_request_handler.py,sha256=BsYP_o1vyGT7IPdezxNy9gfCUAhMj1qoUt2esEeOpe8,3825
|
|
12
12
|
airia/client/_request_handler/sync_request_handler.py,sha256=IFMauU8Fk3AvrMQrSOMTuWwUw44zmWimeW8LkIYj7Ws,10132
|
|
13
13
|
airia/client/conversations/__init__.py,sha256=5gbcHEYLHOn5cK95tlM52GPOmar8gpyK-BivyASmFEo,149
|
|
14
14
|
airia/client/conversations/async_conversations.py,sha256=XbSErt_6RKcQwDdGHKr_roSf2EkxhR6ogBiN3oMFNhk,7448
|
|
15
15
|
airia/client/conversations/base_conversations.py,sha256=YpIvA66xFZbOC4L8P17pISCqyWlJvju34FHX7Pcj8Aw,4848
|
|
16
16
|
airia/client/conversations/sync_conversations.py,sha256=IelRpGuoV0sBwOfZd44igV3i5P35Hv-zzZwCC7y6mlA,7200
|
|
17
|
+
airia/client/data_vector_search/__init__.py,sha256=RmeB9wdIWubjnmoco321dx0T2h5tV0-rTsuHQdXOwI0,171
|
|
18
|
+
airia/client/data_vector_search/async_data_vector_search.py,sha256=S-g0DYJ9flAhGL5t-A8G18fMcHzZFZEVgpx2ZDzpx1Q,2714
|
|
19
|
+
airia/client/data_vector_search/base_data_vector_search.py,sha256=AwES-JBlEYlZHuBWdDtcWsviRpcyKxgJq-oPUEVCsWM,1662
|
|
20
|
+
airia/client/data_vector_search/sync_data_vector_search.py,sha256=g5ZMU3TW0J1b747v_CPDgKoJaCxDs5zv-XnAW2_rnfY,2495
|
|
17
21
|
airia/client/deployments/__init__.py,sha256=Xu_MqbeUrtqYE4tH6hbmvUk8eQScWJ6MEyYFlVEwlRw,310
|
|
18
22
|
airia/client/deployments/async_deployments.py,sha256=IqRQZtkulBxxuviHpbcoi4UFQ-XRH4oRqZ90Q4H-FXs,4321
|
|
19
23
|
airia/client/deployments/base_deployments.py,sha256=luiw4Fuj2YxD0j0-rXrsWkae_CNipxwRV7wIrHBFxpI,3230
|
|
@@ -40,6 +44,8 @@ airia/types/_request_data.py,sha256=q8t7KfO2WvgbPVYPvPWiwYb8LyP0kovlOgHFhZIU6ns,
|
|
|
40
44
|
airia/types/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
45
|
airia/types/api/conversations/__init__.py,sha256=W6GlNVZCAY5eViJOoPl1bY9_etRBWeUnYZJJt7WHtfI,269
|
|
42
46
|
airia/types/api/conversations/_conversations.py,sha256=O7VHs2_Ykg0s6Phe0sAVvbO7YVu6d6R2M2-JkWAipxI,4845
|
|
47
|
+
airia/types/api/data_vector_search/__init__.py,sha256=TXomyrDRlsFmiBWUNoSyD3-dSK5ahYHvn9-s8CIS5xI,112
|
|
48
|
+
airia/types/api/data_vector_search/get_file_chunks.py,sha256=ywP1zH_OXnyP5ZyJ_epaZWRLvOxC72RnL235ySYSZA0,1597
|
|
43
49
|
airia/types/api/deployments/__init__.py,sha256=ONQgkKr_8i6FhcBsHyzT4mYOP_H0OPUAsxvxroZWBMU,538
|
|
44
50
|
airia/types/api/deployments/get_deployment.py,sha256=KBr9edTu-e-tC3u9bpAdz0CMWzk0DFQxusrVU6OZ7mc,4398
|
|
45
51
|
airia/types/api/deployments/get_deployments.py,sha256=5Dm7pTkEFmIZ4p4Scle9x9p3Nqy5tnXxeft3H4O_Fa8,8718
|
|
@@ -56,8 +62,8 @@ airia/types/api/store/get_files.py,sha256=v22zmOuTSFqzrS73L5JL_FgBeF5a5wutv1nK4I
|
|
|
56
62
|
airia/types/sse/__init__.py,sha256=KWnNTfsQnthfrU128pUX6ounvSS7DvjC-Y21FE-OdMk,1863
|
|
57
63
|
airia/types/sse/sse_messages.py,sha256=asq9KG5plT2XSgQMz-Nqo0WcKlXvE8UT3E-WLhCegPk,30244
|
|
58
64
|
airia/utils/sse_parser.py,sha256=XCTkuaroYWaVQOgBq8VpbseQYSAVruF69AvKUwZQKTA,4251
|
|
59
|
-
airia-0.1.
|
|
60
|
-
airia-0.1.
|
|
61
|
-
airia-0.1.
|
|
62
|
-
airia-0.1.
|
|
63
|
-
airia-0.1.
|
|
65
|
+
airia-0.1.17.dist-info/licenses/LICENSE,sha256=R3ClUMMKPRItIcZ0svzyj2taZZnFYw568YDNzN9KQ1Q,1066
|
|
66
|
+
airia-0.1.17.dist-info/METADATA,sha256=pP08UIGUu4E4mC0n5QXaF27Ew_Aw_CIHgBrVRFz2FhI,4506
|
|
67
|
+
airia-0.1.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
68
|
+
airia-0.1.17.dist-info/top_level.txt,sha256=qUQEKfs_hdOYTwjKj1JZbRhS5YeXDNaKQaVTrzabS6w,6
|
|
69
|
+
airia-0.1.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|