airia 0.1.13__py3-none-any.whl → 0.1.14__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.
Files changed (53) hide show
  1. airia/client/_request_handler/__init__.py +4 -0
  2. airia/client/_request_handler/async_request_handler.py +272 -0
  3. airia/client/_request_handler/base_request_handler.py +108 -0
  4. airia/client/_request_handler/sync_request_handler.py +255 -0
  5. airia/client/async_client.py +25 -678
  6. airia/client/base_client.py +2 -368
  7. airia/client/conversations/__init__.py +4 -0
  8. airia/client/conversations/async_conversations.py +187 -0
  9. airia/client/conversations/base_conversations.py +135 -0
  10. airia/client/conversations/sync_conversations.py +182 -0
  11. airia/client/pipeline_execution/__init__.py +4 -0
  12. airia/client/pipeline_execution/async_pipeline_execution.py +178 -0
  13. airia/client/pipeline_execution/base_pipeline_execution.py +96 -0
  14. airia/client/pipeline_execution/sync_pipeline_execution.py +178 -0
  15. airia/client/pipelines_config/__init__.py +4 -0
  16. airia/client/pipelines_config/async_pipelines_config.py +127 -0
  17. airia/client/pipelines_config/base_pipelines_config.py +76 -0
  18. airia/client/pipelines_config/sync_pipelines_config.py +127 -0
  19. airia/client/project/__init__.py +4 -0
  20. airia/client/project/async_project.py +122 -0
  21. airia/client/project/base_project.py +74 -0
  22. airia/client/project/sync_project.py +120 -0
  23. airia/client/store/__init__.py +4 -0
  24. airia/client/store/async_store.py +377 -0
  25. airia/client/store/base_store.py +243 -0
  26. airia/client/store/sync_store.py +352 -0
  27. airia/client/sync_client.py +25 -656
  28. airia/constants.py +1 -1
  29. airia/exceptions.py +8 -8
  30. airia/logs.py +9 -9
  31. airia/types/_request_data.py +11 -4
  32. airia/types/api/__init__.py +0 -27
  33. airia/types/api/conversations/__init__.py +3 -0
  34. airia/types/api/{conversations.py → conversations/_conversations.py} +49 -12
  35. airia/types/api/pipeline_execution/__init__.py +13 -0
  36. airia/types/api/{pipeline_execution.py → pipeline_execution/_pipeline_execution.py} +30 -13
  37. airia/types/api/pipelines_config/__init__.py +3 -0
  38. airia/types/api/pipelines_config/get_pipeline_config.py +401 -0
  39. airia/types/api/project/__init__.py +3 -0
  40. airia/types/api/{get_projects.py → project/get_projects.py} +16 -4
  41. airia/types/api/store/__init__.py +4 -0
  42. airia/types/api/store/get_file.py +145 -0
  43. airia/types/api/store/get_files.py +21 -0
  44. airia/types/sse/__init__.py +1 -0
  45. airia/types/sse/sse_messages.py +55 -21
  46. airia/utils/sse_parser.py +5 -4
  47. {airia-0.1.13.dist-info → airia-0.1.14.dist-info}/METADATA +4 -2
  48. airia-0.1.14.dist-info/RECORD +55 -0
  49. airia/types/api/get_pipeline_config.py +0 -214
  50. airia-0.1.13.dist-info/RECORD +0 -24
  51. {airia-0.1.13.dist-info → airia-0.1.14.dist-info}/WHEEL +0 -0
  52. {airia-0.1.13.dist-info → airia-0.1.14.dist-info}/licenses/LICENSE +0 -0
  53. {airia-0.1.13.dist-info → airia-0.1.14.dist-info}/top_level.txt +0 -0
airia/constants.py CHANGED
@@ -17,4 +17,4 @@ DEFAULT_ANTHROPIC_GATEWAY_URL = "https://gateway.airia.ai/anthropic"
17
17
 
18
18
  # Default timeouts
19
19
  DEFAULT_TIMEOUT = 30.0
20
- """Default timeout in seconds for API requests."""
20
+ """Default timeout in seconds for API requests."""
airia/exceptions.py CHANGED
@@ -1,20 +1,20 @@
1
1
  class AiriaAPIError(Exception):
2
- '''
2
+ """
3
3
  Custom exception for Airia API errors.
4
-
4
+
5
5
  This exception is raised when an API request to the Airia service fails.
6
6
  It contains both the HTTP status code and error message to help with
7
7
  debugging and proper error handling.
8
-
8
+
9
9
  Attributes:
10
10
  status_code (int): The HTTP status code returned by the API
11
11
  message (str): The error message describing what went wrong
12
- '''
13
-
12
+ """
13
+
14
14
  def __init__(self, status_code: int, message: str):
15
15
  """
16
16
  Initialize the exception with a status code and error message.
17
-
17
+
18
18
  Args:
19
19
  status_code (int): The HTTP status code of the failed request
20
20
  message (str): A descriptive error message
@@ -22,11 +22,11 @@ class AiriaAPIError(Exception):
22
22
  super().__init__(f"{status_code}: {message}")
23
23
  self.status_code = status_code
24
24
  self.message = message
25
-
25
+
26
26
  def __str__(self) -> str:
27
27
  """
28
28
  Return a string representation of the exception.
29
-
29
+
30
30
  Returns:
31
31
  str: A formatted string containing the status code and message
32
32
  """
airia/logs.py CHANGED
@@ -8,13 +8,13 @@ import loguru
8
8
  from loguru import logger
9
9
 
10
10
  # Create a context variable to store correlation ID
11
- correlation_id_context: ContextVar[str] = ContextVar('correlation_id', default='')
11
+ correlation_id_context: ContextVar[str] = ContextVar("correlation_id", default="")
12
12
 
13
13
 
14
14
  def get_correlation_id() -> str:
15
15
  """
16
16
  Get the current correlation ID from context or return empty string if not set.
17
-
17
+
18
18
  Returns:
19
19
  str: The current correlation ID
20
20
  """
@@ -24,10 +24,10 @@ def get_correlation_id() -> str:
24
24
  def set_correlation_id(correlation_id: Optional[str] = None) -> str:
25
25
  """
26
26
  Set a correlation ID in the current context.
27
-
27
+
28
28
  Args:
29
29
  correlation_id (Optional[str]): The correlation ID to set. If None, a new UUID will be generated.
30
-
30
+
31
31
  Returns:
32
32
  str: The correlation ID that was set
33
33
  """
@@ -39,7 +39,7 @@ def set_correlation_id(correlation_id: Optional[str] = None) -> str:
39
39
 
40
40
  def clear_correlation_id() -> None:
41
41
  """Clear the correlation ID from the current context."""
42
- correlation_id_context.set('')
42
+ correlation_id_context.set("")
43
43
 
44
44
 
45
45
  # Define a function to be used as a filter to inject correlation_id
@@ -98,7 +98,7 @@ def configure_logging(
98
98
 
99
99
  # Add the new handler
100
100
  logger.add(sink, **kwargs)
101
-
101
+
102
102
  return logger
103
103
 
104
104
 
@@ -107,15 +107,15 @@ if __name__ == "__main__":
107
107
  # Basic configuration (uses sys.stderr)
108
108
  log = configure_logging()
109
109
  log.info("Basic logging configured successfully")
110
-
110
+
111
111
  # Set a correlation ID
112
112
  set_correlation_id("request-123")
113
113
  log.info("This log has a correlation ID")
114
-
114
+
115
115
  # Change correlation ID
116
116
  set_correlation_id("request-456")
117
117
  log.info("This log has a different correlation ID")
118
-
118
+
119
119
  # Use auto-generated correlation ID
120
120
  set_correlation_id()
121
121
  log.info("This log has an auto-generated correlation ID")
@@ -4,28 +4,35 @@ Internal data structures for HTTP request preparation.
4
4
  This module defines the data models used internally by the SDK clients
5
5
  to organize and pass request information between methods.
6
6
  """
7
- from typing import Any, Dict, Optional
8
7
 
9
- from pydantic import BaseModel
8
+ from io import BufferedIOBase
9
+ from typing import Any, Dict, Optional, Tuple
10
+
11
+ from pydantic import BaseModel, ConfigDict
10
12
 
11
13
 
12
14
  class RequestData(BaseModel):
13
15
  """
14
16
  Structured container for HTTP request components.
15
-
17
+
16
18
  This internal data structure organizes all the components needed to make
17
19
  an HTTP request, including the URL, headers, payload, query parameters,
18
20
  and correlation ID for tracing.
19
-
21
+
20
22
  Attributes:
21
23
  url: The complete URL for the HTTP request
22
24
  payload: Optional JSON payload for the request body
23
25
  params: Optional query parameters to append to the URL
26
+ files: Optional file data to be uploaded in the request body
24
27
  headers: HTTP headers including authentication and content-type
25
28
  correlation_id: Unique identifier for request tracing and logging
26
29
  """
30
+
31
+ model_config = ConfigDict(arbitrary_types_allowed=True)
32
+
27
33
  url: str
28
34
  payload: Optional[Dict[str, Any]]
29
35
  params: Optional[Dict[str, Any]]
36
+ files: Optional[Dict[str, Tuple[str, BufferedIOBase, str]]]
30
37
  headers: Dict[str, Any]
31
38
  correlation_id: str
@@ -1,27 +0,0 @@
1
- """
2
- API response models for the Airia SDK.
3
-
4
- This package contains Pydantic models that define the structure of responses
5
- from various Airia API endpoints, including pipeline execution, project management,
6
- conversation handling, and configuration retrieval.
7
- """
8
- from .get_projects import ProjectItem
9
- from .get_pipeline_config import GetPipelineConfigResponse
10
- from .pipeline_execution import (
11
- PipelineExecutionDebugResponse,
12
- PipelineExecutionResponse,
13
- PipelineExecutionAsyncStreamedResponse,
14
- PipelineExecutionStreamedResponse,
15
- )
16
- from .conversations import CreateConversationResponse, GetConversationResponse
17
-
18
- __all__ = [
19
- "PipelineExecutionDebugResponse",
20
- "PipelineExecutionResponse",
21
- "PipelineExecutionStreamedResponse",
22
- "PipelineExecutionAsyncStreamedResponse",
23
- "GetPipelineConfigResponse",
24
- "ProjectItem",
25
- "CreateConversationResponse",
26
- "GetConversationResponse",
27
- ]
@@ -0,0 +1,3 @@
1
+ from ._conversations import CreateConversationResponse, GetConversationResponse
2
+
3
+ __all__ = ["CreateConversationResponse", "GetConversationResponse"]
@@ -4,6 +4,7 @@ Pydantic models for conversation management API responses.
4
4
  This module defines data structures for conversation operations including
5
5
  creation, retrieval, and message management within the Airia platform.
6
6
  """
7
+
7
8
  from typing import Optional, List, Dict
8
9
  from datetime import datetime
9
10
 
@@ -11,24 +12,37 @@ from pydantic import BaseModel, Field
11
12
 
12
13
 
13
14
  class PolicyRedaction(BaseModel):
14
- """
15
- Information about content that was redacted due to policy violations.
16
-
15
+ """Information about content that was redacted due to policy violations.
16
+
17
17
  When content in a conversation violates platform policies, this model
18
18
  tracks what was redacted and where it occurred.
19
+
20
+ Attributes:
21
+ violating_text: The text content that violated platform policies
22
+ violating_message_index: Index of the message containing the violation
19
23
  """
24
+
20
25
  violating_text: str = Field(alias="violatingText")
21
26
  violating_message_index: int = Field(alias="violatingMessageIndex")
22
27
 
23
28
 
24
29
  class ConversationMessage(BaseModel):
25
- """
26
- Individual message within a conversation.
27
-
30
+ """Individual message within a conversation.
31
+
28
32
  Represents a single message exchange in a conversation, which can be
29
33
  from a user, assistant, or system. Messages may include text content
30
34
  and optional image attachments.
35
+
36
+ Attributes:
37
+ id: Unique identifier for the message
38
+ conversation_id: ID of the conversation this message belongs to
39
+ message: Optional text content of the message
40
+ created_at: Timestamp when the message was created
41
+ updated_at: Timestamp when the message was last updated
42
+ role: Role of the message sender (user, assistant, system)
43
+ images: Optional list of image URLs or identifiers
31
44
  """
45
+
32
46
  id: str
33
47
  conversation_id: str = Field(alias="conversationId")
34
48
  message: Optional[str] = None
@@ -39,13 +53,26 @@ class ConversationMessage(BaseModel):
39
53
 
40
54
 
41
55
  class GetConversationResponse(BaseModel):
42
- """
43
- Complete conversation data including messages and metadata.
44
-
56
+ """Complete conversation data including messages and metadata.
57
+
45
58
  This response contains all information about a conversation including
46
59
  its message history, associated files, execution status, and any
47
60
  content moderation actions that have been applied.
61
+
62
+ Attributes:
63
+ user_id: ID of the user who owns the conversation
64
+ conversation_id: Unique identifier for the conversation
65
+ messages: List of messages in the conversation
66
+ title: Optional title for the conversation
67
+ websocket_url: Optional WebSocket URL for real-time updates
68
+ deployment_id: Optional ID of the deployment handling the conversation
69
+ data_source_files: Dictionary mapping data sources to their files
70
+ is_bookmarked: Whether the conversation is bookmarked by the user
71
+ policy_redactions: Optional dictionary of policy violations and redactions
72
+ last_execution_status: Optional status of the last execution
73
+ last_execution_id: Optional ID of the last execution
48
74
  """
75
+
49
76
  user_id: str = Field(alias="userId")
50
77
  conversation_id: str = Field(alias="conversationId")
51
78
  messages: List[ConversationMessage]
@@ -62,12 +89,22 @@ class GetConversationResponse(BaseModel):
62
89
 
63
90
 
64
91
  class CreateConversationResponse(BaseModel):
65
- """
66
- Response data for newly created conversations.
67
-
92
+ """Response data for newly created conversations.
93
+
68
94
  Contains the essential information needed to begin interacting with
69
95
  a new conversation, including connection details and visual metadata.
96
+
97
+ Attributes:
98
+ user_id: ID of the user who created the conversation
99
+ conversation_id: Unique identifier for the new conversation
100
+ websocket_url: WebSocket URL for real-time conversation updates
101
+ deployment_id: ID of the deployment handling the conversation
102
+ icon_id: Optional ID of the conversation icon
103
+ icon_url: Optional URL of the conversation icon
104
+ description: Optional description of the conversation
105
+ space_name: Optional name of the space containing the conversation
70
106
  """
107
+
71
108
  user_id: str = Field(alias="userId")
72
109
  conversation_id: str = Field(alias="conversationId")
73
110
  websocket_url: str = Field(alias="websocketUrl")
@@ -0,0 +1,13 @@
1
+ from ._pipeline_execution import (
2
+ PipelineExecutionAsyncStreamedResponse,
3
+ PipelineExecutionDebugResponse,
4
+ PipelineExecutionResponse,
5
+ PipelineExecutionStreamedResponse,
6
+ )
7
+
8
+ __all__ = [
9
+ "PipelineExecutionDebugResponse",
10
+ "PipelineExecutionResponse",
11
+ "PipelineExecutionStreamedResponse",
12
+ "PipelineExecutionAsyncStreamedResponse",
13
+ ]
@@ -4,56 +4,73 @@ Pydantic models for pipeline execution API responses.
4
4
  This module defines the response models returned by pipeline execution endpoints,
5
5
  including both synchronous and streaming response types.
6
6
  """
7
+
7
8
  from typing import Any, AsyncIterator, Dict, Iterator
8
9
 
9
10
  from pydantic import BaseModel, ConfigDict, Field
10
11
 
11
- from ..sse import SSEMessage
12
+ from ...sse import SSEMessage
12
13
 
13
14
 
14
15
  class PipelineExecutionResponse(BaseModel):
15
- """
16
- Response model for standard pipeline execution requests.
17
-
16
+ """Response model for standard pipeline execution requests.
17
+
18
18
  This model represents the response when executing a pipeline in normal mode
19
19
  (not debug mode and not streaming).
20
+
21
+ Attributes:
22
+ result: The execution result as a string
23
+ report: Always None for standard executions
24
+ is_backup_pipeline: Whether a backup pipeline was used for execution
20
25
  """
26
+
21
27
  result: str
22
28
  report: None
23
29
  is_backup_pipeline: bool = Field(alias="isBackupPipeline")
24
30
 
25
31
 
26
32
  class PipelineExecutionDebugResponse(BaseModel):
27
- """
28
- Response model for pipeline execution requests in debug mode.
29
-
33
+ """Response model for pipeline execution requests in debug mode.
34
+
30
35
  This model includes additional debugging information in the report field
31
36
  that provides insights into the pipeline's execution process.
37
+
38
+ Attributes:
39
+ result: The execution result as a string
40
+ report: Dictionary containing debugging information and execution details
41
+ is_backup_pipeline: Whether a backup pipeline was used for execution
32
42
  """
43
+
33
44
  result: str
34
45
  report: Dict[str, Any]
35
46
  is_backup_pipeline: bool = Field(alias="isBackupPipeline")
36
47
 
37
48
 
38
49
  class PipelineExecutionStreamedResponse(BaseModel):
39
- """
40
- Response model for streaming pipeline execution requests (synchronous client).
41
-
50
+ """Response model for streaming pipeline execution requests (synchronous client).
51
+
42
52
  This model contains an iterator that yields SSEMessage objects as they
43
53
  are received from the streaming response.
54
+
55
+ Attributes:
56
+ stream: Iterator that yields SSEMessage objects from the streaming response
44
57
  """
58
+
45
59
  model_config = ConfigDict(arbitrary_types_allowed=True)
46
60
 
47
61
  stream: Iterator[SSEMessage]
48
62
 
49
63
 
50
64
  class PipelineExecutionAsyncStreamedResponse(BaseModel):
51
- """
52
- Response model for streaming pipeline execution requests (asynchronous client).
53
-
65
+ """Response model for streaming pipeline execution requests (asynchronous client).
66
+
54
67
  This model contains an async iterator that yields SSEMessage objects as they
55
68
  are received from the streaming response.
69
+
70
+ Attributes:
71
+ stream: Async iterator that yields SSEMessage objects from the streaming response
56
72
  """
73
+
57
74
  model_config = ConfigDict(arbitrary_types_allowed=True)
58
75
 
59
76
  stream: AsyncIterator[SSEMessage]
@@ -0,0 +1,3 @@
1
+ from .get_pipeline_config import GetPipelineConfigResponse
2
+
3
+ __all__ = ["GetPipelineConfigResponse"]