kurious 0.8.4__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.
kurious/__init__.py ADDED
@@ -0,0 +1,204 @@
1
+ """Kurious Python SDK — client library for the Kurious Engine API."""
2
+
3
+ from kurious._exceptions import (
4
+ KuriousError,
5
+ AIntropyError, # backward-compat alias
6
+ AuthenticationError,
7
+ ConflictError,
8
+ NotFoundError,
9
+ PermissionError,
10
+ RateLimitError,
11
+ ServerError,
12
+ ValidationError,
13
+ )
14
+ from kurious.client import Kurious, AIntropy # AIntropy is backward-compat alias
15
+ from kurious.entitlements import PlanType
16
+ from kurious.jobs import Job, JobsResource, JobThrottled, TERMINAL_STATUSES
17
+ from kurious.types import (
18
+ APIKey,
19
+ APIKeyListItem,
20
+ APIKeyPage,
21
+ AuditLogEntry,
22
+ AuditLogPage,
23
+ AutoIngestConfig,
24
+ BackfillFanoutResponse,
25
+ BlendedAnswer,
26
+ Bookmark,
27
+ BookmarkList,
28
+ BulkResult,
29
+ ChatResponse,
30
+ Conversation,
31
+ ConversationList,
32
+ DailyUsage,
33
+ DocumentResult,
34
+ EmailOtpRequestResult,
35
+ EmailOtpVerifyResult,
36
+ EmbeddingResponse,
37
+ Entitlement,
38
+ EntitlementListPage,
39
+ EvalResult,
40
+ EvalResultPage,
41
+ EvalRun,
42
+ EvalRunPage,
43
+ EvalSet,
44
+ EvalSetPage,
45
+ IndexStats,
46
+ IngestionJob,
47
+ IngestionJobPage,
48
+ IngestStage,
49
+ IngestStatus,
50
+ IntelligentSearchResult,
51
+ JobChildrenRollup,
52
+ JobStatus,
53
+ KGAutoChainConfig,
54
+ KGJobResponse,
55
+ KGJobStatus,
56
+ KGSearchResult,
57
+ LoginResponse,
58
+ Member,
59
+ MemberList,
60
+ Message,
61
+ MessageList,
62
+ NL2SQLDedupResult,
63
+ NL2SQLPipelineJob,
64
+ NL2SQLPipelineStatus,
65
+ NL2SQLResult,
66
+ OperationResult,
67
+ PresignedUpload,
68
+ Project,
69
+ ProjectConfig,
70
+ ProjectFile,
71
+ ProjectFileList,
72
+ ProjectList,
73
+ ProjectMetrics,
74
+ RAGSearchResult,
75
+ RawSearchResult,
76
+ ResumeIngestResult,
77
+ SearchLogEntry,
78
+ ShareInfo,
79
+ SharedConversation,
80
+ SharedMessage,
81
+ SharedMessageList,
82
+ SignupResponse,
83
+ SourceAttribution,
84
+ StepTiming,
85
+ StepTimingsResponse,
86
+ StreamEvent,
87
+ TokenResponse,
88
+ UsageBreakdown,
89
+ UsageSummary,
90
+ VideoInspectResult,
91
+ VideoPipelineJob,
92
+ VideoPipelineStatus,
93
+ VideoSearchHit,
94
+ VideoSearchResult,
95
+ VideoTimeline,
96
+ VideoTimelineEvent,
97
+ WhoAmIResponse,
98
+ )
99
+
100
+ __version__ = "0.8.4"
101
+
102
+ __all__ = [
103
+ # Client
104
+ "Kurious",
105
+ "AIntropy", # backward-compat
106
+ # Exceptions
107
+ "KuriousError",
108
+ "AIntropyError", # backward-compat
109
+ "AuthenticationError",
110
+ "ConflictError",
111
+ "NotFoundError",
112
+ "PermissionError",
113
+ "RateLimitError",
114
+ "ServerError",
115
+ "ValidationError",
116
+ # Enum-like literal type aliases
117
+ "PlanType",
118
+ # Jobs
119
+ "Job",
120
+ "JobsResource",
121
+ "JobThrottled",
122
+ "TERMINAL_STATUSES",
123
+ # Types
124
+ "APIKey",
125
+ "APIKeyListItem",
126
+ "APIKeyPage",
127
+ "AuditLogEntry",
128
+ "AuditLogPage",
129
+ "AutoIngestConfig",
130
+ "BackfillFanoutResponse",
131
+ "BlendedAnswer",
132
+ "Bookmark",
133
+ "BookmarkList",
134
+ "BulkResult",
135
+ "ChatResponse",
136
+ "Conversation",
137
+ "ConversationList",
138
+ "DailyUsage",
139
+ "DocumentResult",
140
+ "EmailOtpRequestResult",
141
+ "EmailOtpVerifyResult",
142
+ "EmbeddingResponse",
143
+ "Entitlement",
144
+ "EntitlementListPage",
145
+ "EvalResult",
146
+ "EvalResultPage",
147
+ "EvalRun",
148
+ "EvalRunPage",
149
+ "EvalSet",
150
+ "EvalSetPage",
151
+ "IndexStats",
152
+ "IngestionJob",
153
+ "IngestionJobPage",
154
+ "IngestStage",
155
+ "IngestStatus",
156
+ "IntelligentSearchResult",
157
+ "JobChildrenRollup",
158
+ "JobStatus",
159
+ "KGAutoChainConfig",
160
+ "KGJobResponse",
161
+ "KGJobStatus",
162
+ "KGSearchResult",
163
+ "LoginResponse",
164
+ "Member",
165
+ "MemberList",
166
+ "Message",
167
+ "MessageList",
168
+ "NL2SQLDedupResult",
169
+ "NL2SQLPipelineJob",
170
+ "NL2SQLPipelineStatus",
171
+ "NL2SQLResult",
172
+ "OperationResult",
173
+ "PresignedUpload",
174
+ "Project",
175
+ "ProjectConfig",
176
+ "ProjectFile",
177
+ "ProjectFileList",
178
+ "ProjectList",
179
+ "ProjectMetrics",
180
+ "RAGSearchResult",
181
+ "RawSearchResult",
182
+ "ResumeIngestResult",
183
+ "SearchLogEntry",
184
+ "ShareInfo",
185
+ "SharedConversation",
186
+ "SharedMessage",
187
+ "SharedMessageList",
188
+ "SignupResponse",
189
+ "SourceAttribution",
190
+ "StepTiming",
191
+ "StepTimingsResponse",
192
+ "StreamEvent",
193
+ "TokenResponse",
194
+ "UsageBreakdown",
195
+ "UsageSummary",
196
+ "VideoInspectResult",
197
+ "VideoPipelineJob",
198
+ "VideoPipelineStatus",
199
+ "VideoSearchHit",
200
+ "VideoSearchResult",
201
+ "VideoTimeline",
202
+ "VideoTimelineEvent",
203
+ "WhoAmIResponse",
204
+ ]
kurious/_config.py ADDED
@@ -0,0 +1,106 @@
1
+ """Local credential config — read/write ``~/.kurious/config.toml``.
2
+
3
+ Written by ``kurious init`` and read back by :meth:`AIntropy.from_config`.
4
+ The file holds a live API key, so it is created with ``0600`` permissions.
5
+
6
+ Kept dependency-free: TOML is read with the stdlib ``tomllib`` (Python 3.11+)
7
+ and falls back to a minimal flat-table parser on 3.9 / 3.10. Writing uses a
8
+ small serialiser since the schema is a flat table of string values.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import os
14
+ from pathlib import Path
15
+
16
+ # Field names — referenced from both the CLI and the client, so centralised.
17
+ KEY_BASE_URL = "base_url"
18
+ KEY_API_KEY = "api_key"
19
+ KEY_COMPANY_ID = "company_id"
20
+ KEY_USER_ID = "user_id"
21
+
22
+ #: Override the config location with this env var (absolute path).
23
+ ENV_CONFIG_PATH = "KURIOUS_CONFIG_PATH"
24
+
25
+ _DEFAULT_CONFIG_PATH = Path.home() / ".kurious" / "config.toml"
26
+ _OWNER_RW = 0o600
27
+
28
+
29
+ def config_path(override: str | os.PathLike[str] | None = None) -> Path:
30
+ """Resolve the config path: explicit arg → ``$KURIOUS_CONFIG_PATH`` → default."""
31
+ if override:
32
+ return Path(override)
33
+ env_value = os.environ.get(ENV_CONFIG_PATH)
34
+ if env_value:
35
+ return Path(env_value)
36
+ return _DEFAULT_CONFIG_PATH
37
+
38
+
39
+ def read_config(path: str | os.PathLike[str] | None = None) -> dict[str, str]:
40
+ """Load the config table. Returns ``{}`` if the file does not exist."""
41
+ target = config_path(path)
42
+ if not target.exists():
43
+ return {}
44
+ text = target.read_text(encoding="utf-8")
45
+ try:
46
+ import tomllib # Python 3.11+
47
+
48
+ return dict(tomllib.loads(text))
49
+ except ModuleNotFoundError:
50
+ return _parse_flat_toml(text)
51
+
52
+
53
+ def write_config(
54
+ data: dict[str, str | None], path: str | os.PathLike[str] | None = None
55
+ ) -> Path:
56
+ """Write the config table to disk with ``0600`` perms. Returns the path.
57
+
58
+ ``None`` values are skipped. The parent directory is created if absent.
59
+ """
60
+ target = config_path(path)
61
+ target.parent.mkdir(parents=True, exist_ok=True)
62
+ body = "".join(
63
+ f"{key} = {_quote(str(value))}\n"
64
+ for key, value in data.items()
65
+ if value is not None
66
+ )
67
+ # Create with 0600 from the start (O_CREAT honours the mode arg) so the
68
+ # file holding a live API key is never briefly world-readable. chmod after
69
+ # to fix perms if the file already existed.
70
+ fd = os.open(target, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, _OWNER_RW)
71
+ try:
72
+ os.write(fd, body.encode("utf-8"))
73
+ finally:
74
+ os.close(fd)
75
+ os.chmod(target, _OWNER_RW)
76
+ return target
77
+
78
+
79
+ def _quote(value: str) -> str:
80
+ """Serialise a string as a basic TOML string literal."""
81
+ escaped = value.replace("\\", "\\\\").replace('"', '\\"')
82
+ return f'"{escaped}"'
83
+
84
+
85
+ def _unquote(value: str) -> str:
86
+ """Inverse of :func:`_quote` for the fallback parser."""
87
+ inner = value.strip()
88
+ if len(inner) >= 2 and inner[0] == '"' and inner[-1] == '"':
89
+ inner = inner[1:-1]
90
+ return inner.replace('\\"', '"').replace("\\\\", "\\")
91
+
92
+
93
+ def _parse_flat_toml(text: str) -> dict[str, str]:
94
+ """Minimal ``key = "value"`` parser for the 3.9 / 3.10 fallback path.
95
+
96
+ Only supports the flat string table this module writes — comments and
97
+ blank lines are ignored; tables / arrays are not expected.
98
+ """
99
+ result: dict[str, str] = {}
100
+ for raw in text.splitlines():
101
+ line = raw.strip()
102
+ if not line or line.startswith("#") or "=" not in line:
103
+ continue
104
+ key, _, value = line.partition("=")
105
+ result[key.strip()] = _unquote(value)
106
+ return result
kurious/_exceptions.py ADDED
@@ -0,0 +1,54 @@
1
+ """AIntropy SDK exceptions."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ class KuriousError(Exception):
7
+ """Base exception for all SDK errors."""
8
+
9
+ def __init__(
10
+ self, message: str, status_code: int | None = None, body: dict | None = None
11
+ ):
12
+ super().__init__(message)
13
+ self.status_code = status_code
14
+ self.body = body or {}
15
+
16
+
17
+ class AuthenticationError(KuriousError):
18
+ """Raised on 401 — missing or invalid credentials."""
19
+
20
+
21
+ class PermissionError(KuriousError):
22
+ """Raised on 403 — insufficient permissions."""
23
+
24
+
25
+ class NotFoundError(KuriousError):
26
+ """Raised on 404 — resource does not exist."""
27
+
28
+
29
+ class ConflictError(KuriousError):
30
+ """Raised on 409 — duplicate resource."""
31
+
32
+
33
+ class ValidationError(KuriousError):
34
+ """Raised on 422 — request validation failed."""
35
+
36
+
37
+ class RateLimitError(KuriousError):
38
+ """Raised on 429 — rate limit exceeded."""
39
+
40
+ def __init__(
41
+ self,
42
+ message: str,
43
+ retry_after: float | None = None,
44
+ **kwargs,
45
+ ):
46
+ super().__init__(message, **kwargs)
47
+ self.retry_after = retry_after
48
+
49
+
50
+ class ServerError(KuriousError):
51
+ """Raised on 5xx — server-side failure."""
52
+
53
+ # Backward-compatibility alias — prefer KuriousError going forward
54
+ AIntropyError = KuriousError