airia 0.1.12__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 (58) 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 -584
  6. airia/client/base_client.py +2 -209
  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 -563
  28. airia/constants.py +13 -2
  29. airia/exceptions.py +8 -8
  30. airia/logs.py +10 -32
  31. airia/types/__init__.py +0 -0
  32. airia/types/_request_data.py +29 -2
  33. airia/types/api/__init__.py +0 -19
  34. airia/types/api/conversations/__init__.py +3 -0
  35. airia/types/api/conversations/_conversations.py +115 -0
  36. airia/types/api/pipeline_execution/__init__.py +13 -0
  37. airia/types/api/pipeline_execution/_pipeline_execution.py +76 -0
  38. airia/types/api/pipelines_config/__init__.py +3 -0
  39. airia/types/api/pipelines_config/get_pipeline_config.py +401 -0
  40. airia/types/api/project/__init__.py +3 -0
  41. airia/types/api/project/get_projects.py +91 -0
  42. airia/types/api/store/__init__.py +4 -0
  43. airia/types/api/store/get_file.py +145 -0
  44. airia/types/api/store/get_files.py +21 -0
  45. airia/types/sse/__init__.py +8 -0
  46. airia/types/sse/sse_messages.py +209 -0
  47. airia/utils/sse_parser.py +40 -7
  48. airia-0.1.14.dist-info/METADATA +221 -0
  49. airia-0.1.14.dist-info/RECORD +55 -0
  50. airia/types/api/conversations.py +0 -14
  51. airia/types/api/get_pipeline_config.py +0 -183
  52. airia/types/api/get_projects.py +0 -35
  53. airia/types/api/pipeline_execution.py +0 -29
  54. airia-0.1.12.dist-info/METADATA +0 -705
  55. airia-0.1.12.dist-info/RECORD +0 -23
  56. {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/WHEEL +0 -0
  57. {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/licenses/LICENSE +0 -0
  58. {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/top_level.txt +0 -0
airia/logs.py CHANGED
@@ -2,19 +2,19 @@ import os
2
2
  import sys
3
3
  import uuid
4
4
  from contextvars import ContextVar
5
- from typing import BinaryIO, Optional, TextIO, Union, overload
5
+ from typing import BinaryIO, Optional, TextIO, Union
6
6
 
7
7
  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
@@ -48,28 +48,6 @@ def correlation_id_filter(record):
48
48
  return record
49
49
 
50
50
 
51
- @overload
52
- def configure_logging(
53
- format_string: str = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
54
- level: str = "INFO",
55
- sink: Union[TextIO, BinaryIO] = ...,
56
- rotation: None = None,
57
- retention: None = None,
58
- include_correlation_id: bool = True,
59
- ) -> "loguru.Logger": ...
60
-
61
-
62
- @overload
63
- def configure_logging(
64
- format_string: str = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
65
- level: str = "INFO",
66
- sink: Union[str, os.PathLike[str]] = ...,
67
- rotation: Optional[str] = None,
68
- retention: Optional[str] = None,
69
- include_correlation_id: bool = True,
70
- ) -> "loguru.Logger": ...
71
-
72
-
73
51
  def configure_logging(
74
52
  format_string: str = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
75
53
  level: str = "INFO",
@@ -120,7 +98,7 @@ def configure_logging(
120
98
 
121
99
  # Add the new handler
122
100
  logger.add(sink, **kwargs)
123
-
101
+
124
102
  return logger
125
103
 
126
104
 
@@ -129,15 +107,15 @@ if __name__ == "__main__":
129
107
  # Basic configuration (uses sys.stderr)
130
108
  log = configure_logging()
131
109
  log.info("Basic logging configured successfully")
132
-
110
+
133
111
  # Set a correlation ID
134
112
  set_correlation_id("request-123")
135
113
  log.info("This log has a correlation ID")
136
-
114
+
137
115
  # Change correlation ID
138
116
  set_correlation_id("request-456")
139
117
  log.info("This log has a different correlation ID")
140
-
118
+
141
119
  # Use auto-generated correlation ID
142
120
  set_correlation_id()
143
121
  log.info("This log has an auto-generated correlation ID")
File without changes
@@ -1,11 +1,38 @@
1
- from typing import Any, Dict, Optional
1
+ """
2
+ Internal data structures for HTTP request preparation.
2
3
 
3
- from pydantic import BaseModel
4
+ This module defines the data models used internally by the SDK clients
5
+ to organize and pass request information between methods.
6
+ """
7
+
8
+ from io import BufferedIOBase
9
+ from typing import Any, Dict, Optional, Tuple
10
+
11
+ from pydantic import BaseModel, ConfigDict
4
12
 
5
13
 
6
14
  class RequestData(BaseModel):
15
+ """
16
+ Structured container for HTTP request components.
17
+
18
+ This internal data structure organizes all the components needed to make
19
+ an HTTP request, including the URL, headers, payload, query parameters,
20
+ and correlation ID for tracing.
21
+
22
+ Attributes:
23
+ url: The complete URL for the HTTP request
24
+ payload: Optional JSON payload for the request body
25
+ params: Optional query parameters to append to the URL
26
+ files: Optional file data to be uploaded in the request body
27
+ headers: HTTP headers including authentication and content-type
28
+ correlation_id: Unique identifier for request tracing and logging
29
+ """
30
+
31
+ model_config = ConfigDict(arbitrary_types_allowed=True)
32
+
7
33
  url: str
8
34
  payload: Optional[Dict[str, Any]]
9
35
  params: Optional[Dict[str, Any]]
36
+ files: Optional[Dict[str, Tuple[str, BufferedIOBase, str]]]
10
37
  headers: Dict[str, Any]
11
38
  correlation_id: str
@@ -1,19 +0,0 @@
1
- from .get_projects import ProjectItem
2
- from .get_pipeline_config import GetPipelineConfigResponse
3
- from .pipeline_execution import (
4
- PipelineExecutionDebugResponse,
5
- PipelineExecutionResponse,
6
- PipelineExecutionAsyncStreamedResponse,
7
- PipelineExecutionStreamedResponse,
8
- )
9
- from .conversations import CreateConversationResponse
10
-
11
- __all__ = [
12
- "PipelineExecutionDebugResponse",
13
- "PipelineExecutionResponse",
14
- "PipelineExecutionStreamedResponse",
15
- "PipelineExecutionAsyncStreamedResponse",
16
- "GetPipelineConfigResponse",
17
- "ProjectItem",
18
- "CreateConversationResponse",
19
- ]
@@ -0,0 +1,3 @@
1
+ from ._conversations import CreateConversationResponse, GetConversationResponse
2
+
3
+ __all__ = ["CreateConversationResponse", "GetConversationResponse"]
@@ -0,0 +1,115 @@
1
+ """
2
+ Pydantic models for conversation management API responses.
3
+
4
+ This module defines data structures for conversation operations including
5
+ creation, retrieval, and message management within the Airia platform.
6
+ """
7
+
8
+ from typing import Optional, List, Dict
9
+ from datetime import datetime
10
+
11
+ from pydantic import BaseModel, Field
12
+
13
+
14
+ class PolicyRedaction(BaseModel):
15
+ """Information about content that was redacted due to policy violations.
16
+
17
+ When content in a conversation violates platform policies, this model
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
23
+ """
24
+
25
+ violating_text: str = Field(alias="violatingText")
26
+ violating_message_index: int = Field(alias="violatingMessageIndex")
27
+
28
+
29
+ class ConversationMessage(BaseModel):
30
+ """Individual message within a conversation.
31
+
32
+ Represents a single message exchange in a conversation, which can be
33
+ from a user, assistant, or system. Messages may include text content
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
44
+ """
45
+
46
+ id: str
47
+ conversation_id: str = Field(alias="conversationId")
48
+ message: Optional[str] = None
49
+ created_at: datetime = Field(alias="createdAt")
50
+ updated_at: datetime = Field(alias="updatedAt")
51
+ role: str
52
+ images: Optional[List[str]] = None
53
+
54
+
55
+ class GetConversationResponse(BaseModel):
56
+ """Complete conversation data including messages and metadata.
57
+
58
+ This response contains all information about a conversation including
59
+ its message history, associated files, execution status, and any
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
74
+ """
75
+
76
+ user_id: str = Field(alias="userId")
77
+ conversation_id: str = Field(alias="conversationId")
78
+ messages: List[ConversationMessage]
79
+ title: Optional[str] = None
80
+ websocket_url: Optional[str] = Field(None, alias="websocketUrl")
81
+ deployment_id: Optional[str] = Field(None, alias="deploymentId")
82
+ data_source_files: Dict[str, List[str]] = Field(alias="dataSourceFiles")
83
+ is_bookmarked: bool = Field(alias="isBookmarked")
84
+ policy_redactions: Optional[Dict[str, PolicyRedaction]] = Field(
85
+ None, alias="policyRedactions"
86
+ )
87
+ last_execution_status: Optional[str] = Field(None, alias="lastExecutionStatus")
88
+ last_execution_id: Optional[str] = Field(None, alias="lastExecutionId")
89
+
90
+
91
+ class CreateConversationResponse(BaseModel):
92
+ """Response data for newly created conversations.
93
+
94
+ Contains the essential information needed to begin interacting with
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
106
+ """
107
+
108
+ user_id: str = Field(alias="userId")
109
+ conversation_id: str = Field(alias="conversationId")
110
+ websocket_url: str = Field(alias="websocketUrl")
111
+ deployment_id: str = Field(alias="deploymentId")
112
+ icon_id: Optional[str] = Field(None, alias="iconId")
113
+ icon_url: Optional[str] = Field(None, alias="iconUrl")
114
+ description: Optional[str] = None
115
+ space_name: Optional[str] = Field(None, alias="spaceName")
@@ -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
+ ]
@@ -0,0 +1,76 @@
1
+ """
2
+ Pydantic models for pipeline execution API responses.
3
+
4
+ This module defines the response models returned by pipeline execution endpoints,
5
+ including both synchronous and streaming response types.
6
+ """
7
+
8
+ from typing import Any, AsyncIterator, Dict, Iterator
9
+
10
+ from pydantic import BaseModel, ConfigDict, Field
11
+
12
+ from ...sse import SSEMessage
13
+
14
+
15
+ class PipelineExecutionResponse(BaseModel):
16
+ """Response model for standard pipeline execution requests.
17
+
18
+ This model represents the response when executing a pipeline in normal mode
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
25
+ """
26
+
27
+ result: str
28
+ report: None
29
+ is_backup_pipeline: bool = Field(alias="isBackupPipeline")
30
+
31
+
32
+ class PipelineExecutionDebugResponse(BaseModel):
33
+ """Response model for pipeline execution requests in debug mode.
34
+
35
+ This model includes additional debugging information in the report field
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
42
+ """
43
+
44
+ result: str
45
+ report: Dict[str, Any]
46
+ is_backup_pipeline: bool = Field(alias="isBackupPipeline")
47
+
48
+
49
+ class PipelineExecutionStreamedResponse(BaseModel):
50
+ """Response model for streaming pipeline execution requests (synchronous client).
51
+
52
+ This model contains an iterator that yields SSEMessage objects as they
53
+ are received from the streaming response.
54
+
55
+ Attributes:
56
+ stream: Iterator that yields SSEMessage objects from the streaming response
57
+ """
58
+
59
+ model_config = ConfigDict(arbitrary_types_allowed=True)
60
+
61
+ stream: Iterator[SSEMessage]
62
+
63
+
64
+ class PipelineExecutionAsyncStreamedResponse(BaseModel):
65
+ """Response model for streaming pipeline execution requests (asynchronous client).
66
+
67
+ This model contains an async iterator that yields SSEMessage objects as they
68
+ are received from the streaming response.
69
+
70
+ Attributes:
71
+ stream: Async iterator that yields SSEMessage objects from the streaming response
72
+ """
73
+
74
+ model_config = ConfigDict(arbitrary_types_allowed=True)
75
+
76
+ stream: AsyncIterator[SSEMessage]
@@ -0,0 +1,3 @@
1
+ from .get_pipeline_config import GetPipelineConfigResponse
2
+
3
+ __all__ = ["GetPipelineConfigResponse"]